Skip to content
This repository has been archived by the owner on Jun 15, 2019. It is now read-only.

Commit

Permalink
working on zaach#20 / zaach/jison#341: pass parser analysis info bits…
Browse files Browse the repository at this point in the history
… to the lexer compiler using better names, so they are confused once in there.
  • Loading branch information
GerHobbelt committed Mar 27, 2017
1 parent 8c1fa11 commit e1f3d87
Showing 1 changed file with 47 additions and 49 deletions.
96 changes: 47 additions & 49 deletions regexp-lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@ function RegExpLexer(dict, input, tokens, build_options) {
function test_me(tweak_cb, description, src_exception, ex_callback) {
opts = processGrammar(dict, tokens, build_options);
opts.__in_rules_failure_analysis_mode__ = false;
assert(opts.options);
if (tweak_cb) {
tweak_cb();
}
Expand Down Expand Up @@ -1901,30 +1902,31 @@ function processGrammar(dict, tokens, build_options) {
//
// (this stuff comes straight from the jison Optimization Analysis.)
//
opts.actionsAreAllDefault = build_options.actionsAreAllDefault;
opts.actionsUseYYLENG = build_options.actionsUseYYLENG;
opts.actionsUseYYLINENO = build_options.actionsUseYYLINENO;
opts.actionsUseYYTEXT = build_options.actionsUseYYTEXT;
opts.actionsUseYYLOC = build_options.actionsUseYYLOC;
opts.actionsUseParseError = build_options.actionsUseParseError;
opts.actionsUseYYERROR = build_options.actionsUseYYERROR;
opts.actionsUseYYERROK = build_options.actionsUseYYERROK;
opts.actionsUseYYCLEARIN = build_options.actionsUseYYCLEARIN;
opts.actionsUseValueTracking = build_options.actionsUseValueTracking;
opts.actionsUseValueAssignment = build_options.actionsUseValueAssignment;
opts.actionsUseLocationTracking = build_options.actionsUseLocationTracking;
opts.actionsUseLocationAssignment = build_options.actionsUseLocationAssignment;
opts.actionsUseYYSTACK = build_options.actionsUseYYSTACK;
opts.actionsUseYYSSTACK = build_options.actionsUseYYSSTACK;
opts.actionsUseYYSTACKPOINTER = build_options.actionsUseYYSTACKPOINTER;
opts.hasErrorRecovery = build_options.hasErrorRecovery;
opts.parseActionsAreAllDefault = build_options.parseActionsAreAllDefault;
opts.parseActionsUseYYLENG = build_options.parseActionsUseYYLENG;
opts.parseActionsUseYYLINENO = build_options.parseActionsUseYYLINENO;
opts.parseActionsUseYYTEXT = build_options.parseActionsUseYYTEXT;
opts.parseActionsUseYYLOC = build_options.parseActionsUseYYLOC;
opts.parseActionsUseParseError = build_options.parseActionsUseParseError;
opts.parseActionsUseYYERROR = build_options.parseActionsUseYYERROR;
opts.parseActionsUseYYERROK = build_options.parseActionsUseYYERROK;
opts.parseActionsUseYYCLEARIN = build_options.parseActionsUseYYCLEARIN;
opts.parseActionsUseValueTracking = build_options.parseActionsUseValueTracking;
opts.parseActionsUseValueAssignment = build_options.parseActionsUseValueAssignment;
opts.parseActionsUseLocationTracking = build_options.parseActionsUseLocationTracking;
opts.parseActionsUseLocationAssignment = build_options.parseActionsUseLocationAssignment;
opts.parseActionsUseYYSTACK = build_options.parseActionsUseYYSTACK;
opts.parseActionsUseYYSSTACK = build_options.parseActionsUseYYSSTACK;
opts.parseActionsUseYYSTACKPOINTER = build_options.parseActionsUseYYSTACKPOINTER;
opts.parserHasErrorRecovery = build_options.parserHasErrorRecovery;

dict = autodetectAndConvertToJSONformat(dict, build_options) || {};

// Feed the possibly reprocessed 'dictionary' above back to the caller
// (for use by our error diagnostic assistance code)
opts.lex_rule_dictionary = dict;

// Always provide the lexer with an options object, even if it's empty!
// Make sure to camelCase all options:
opts.options = mkStdOptions(build_options, dict.options);

Expand Down Expand Up @@ -2023,23 +2025,23 @@ function generateModuleBody(opt) {
backtrack_lexer: 0,
caseInsensitive: 0,
showSource: 1,
actionsAreAllDefault: 1,
actionsUseYYLENG: 1,
actionsUseYYLINENO: 1,
actionsUseYYTEXT: 1,
actionsUseYYLOC: 1,
actionsUseParseError: 1,
actionsUseYYERROR: 1,
actionsUseYYERROK: 1,
actionsUseYYCLEARIN: 1,
actionsUseValueTracking: 1,
actionsUseValueAssignment: 1,
actionsUseLocationTracking: 1,
actionsUseLocationAssignment: 1,
actionsUseYYSTACK: 1,
actionsUseYYSSTACK: 1,
actionsUseYYSTACKPOINTER: 1,
hasErrorRecovery: 1,
parseActionsAreAllDefault: 1,
parseActionsUseYYLENG: 1,
parseActionsUseYYLINENO: 1,
parseActionsUseYYTEXT: 1,
parseActionsUseYYLOC: 1,
parseActionsUseParseError: 1,
parseActionsUseYYERROR: 1,
parseActionsUseYYERROK: 1,
parseActionsUseYYCLEARIN: 1,
parseActionsUseValueTracking: 1,
parseActionsUseValueAssignment: 1,
parseActionsUseLocationTracking: 1,
parseActionsUseLocationAssignment: 1,
parseActionsUseYYSTACK: 1,
parseActionsUseYYSSTACK: 1,
parseActionsUseYYSTACKPOINTER: 1,
parserHasErrorRecovery: 1,
};
for (var k in opts) {
if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) {
Expand Down Expand Up @@ -2087,13 +2089,13 @@ var lexer = {
// location.ranges: ${opt.options.ranges}
//
// Forwarded Parser Analysis flags:
// uses yyleng: ${opt.actionsUseYYLENG}
// uses yylineno: ${opt.actionsUseYYLINENO}
// uses yytext: ${opt.actionsUseYYTEXT}
// uses yylloc: ${opt.actionsUseYYLOC}
// uses lexer values: ${opt.actionsUseValueTracking} / ${opt.actionsUseValueAssignment}
// location tracking: ${opt.actionsUseLocationTracking}
// location assignment: ${opt.actionsUseLocationAssignment}
// uses yyleng: ${opt.parseActionsUseYYLENG}
// uses yylineno: ${opt.parseActionsUseYYLINENO}
// uses yytext: ${opt.parseActionsUseYYTEXT}
// uses yylloc: ${opt.parseActionsUseYYLOC}
// uses lexer values: ${opt.parseActionsUseValueTracking} / ${opt.parseActionsUseValueAssignment}
// location tracking: ${opt.parseActionsUseLocationTracking}
// location assignment: ${opt.parseActionsUseLocationAssignment}
//
// --------- END OF REPORT -----------
Expand All @@ -2109,15 +2111,11 @@ var lexer = {
protosrc = stripUnusedLexerCode(protosrc, opt);
out += protosrc + ',\n';

if (opt.options) {
// Assure all options are camelCased:
assert(typeof opt.options['case-insensitive'] === 'undefined');
assert(opt.options);
// Assure all options are camelCased:
assert(typeof opt.options['case-insensitive'] === 'undefined');

out += ' options: ' + produceOptions(opt.options);
} else {
// always provide the lexer with an options object, even if it's empty!
out += ' options: {}';
}
out += ' options: ' + produceOptions(opt.options);

out += ',\n JisonLexerError: JisonLexerError';
out += ',\n performAction: ' + String(opt.performAction);
Expand Down

0 comments on commit e1f3d87

Please sign in to comment.