From e2c154403835508fc80a7fc3f6c7722c2663d2f4 Mon Sep 17 00:00:00 2001 From: Ger Hobbelt Date: Tue, 31 Jan 2017 22:14:50 +0100 Subject: [PATCH] The `--no-xxx` CLI options did not work! Fix CLI option set: see also https://github.com/harthur/nomnom/issues/75 --- lib/cli.js | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index c86480778..0f5be7924 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -77,24 +77,24 @@ function getCommandlineOptions() { default: false, help: 'Output extra parser tables (rules list + look-ahead analysis) in generated modules to assist debugging / diagnostics purposes' }, - noDefaultResolve: { - full: 'no-default-resolve', + hasDefaultResolve: { + full: 'default-resolve', abbr: 'X', flag: true, - default: false, - help: 'Act another way when a conflict is found in the grammar' + default: true, + help: 'Turn this OFF to make jison act another way when a conflict is found in the grammar' }, - noDefaultAction: { - full: 'no-default-action', + hasDefaultAction: { + full: 'default-action', flag: true, - default: false, - help: 'Generate a parser which does NOT include the default "$$ = $1" action for every rule. This produces a slightly faster parser but now you are solely responsible for propagating rule action "$$" results.' + default: true, + help: 'Generate a parser which includes the default "$$ = $1" action for every rule. When you turn this OFF, it will produce a slightly faster parser but then you are solely responsible for propagating rule action "$$" results.' }, - noTryCatch: { - full: 'no-try-catch', + hasTryCatch: { + full: 'try-catch', flag: true, - default: false, - help: 'Generate a parser which does NOT try/catch exceptions (from the grammar action code or parseError error reporting calls. This produces a slightly faster parser at the cost of enhanced code safety.' + default: true, + help: 'Generate a parser which catches exceptions from the grammar action code or parseError error reporting calls using a try/catch/finally code block. When you turn this OFF, it will produce a slightly faster parser at the cost of reduced code safety.' }, errorRecoveryTokenDiscardCount: { full: 'error-recovery-token-discard-count', @@ -142,6 +142,16 @@ function getCommandlineOptions() { } }).parse(); + opts.noMain = !opts.main; + opts.noDefaultResolve = !opts.hasDefaultResolve; + opts.noDefaultAction = !opts.hasDefaultAction; + opts.noTryCatch = !opts.hasTryCatch; + + delete opts.main; + delete opts.hasDefaultResolve; + delete opts.hasDefaultAction; + delete opts.hasTryCatch; + return opts; } @@ -305,7 +315,6 @@ cli.generateParserString = function generateParserString(grammar, optionalLexSec if (opts.parserType) { settings.type = opts.parserType; } - settings.noMain = !opts.main; for (var key in opts) { if (opts[key] || opts[key] === 0) {