From 58cc5b739d972ace6ca66ee1f122b6c095cdbd73 Mon Sep 17 00:00:00 2001 From: David Majda Date: Sun, 25 Mar 2012 17:03:47 +0200 Subject: [PATCH] Implement "--track-line-and-column" command-line option --- bin/pegjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/pegjs b/bin/pegjs index 24dd9e6..2ba2427 100755 --- a/bin/pegjs +++ b/bin/pegjs @@ -23,6 +23,7 @@ function printHelp() { util.puts("Options:"); util.puts(" -e, --export-var name of the variable where the parser object"); util.puts(" will be stored (default: \"module.exports\")"); + util.puts(" --track-line-and-column make generated parser track line and column"); util.puts(" -v, --version print version information and exit"); util.puts(" -h, --help print help and exit"); } @@ -64,6 +65,7 @@ function readStream(inputStream, callback) { /* This makes the generated parser a CommonJS module by default. */ var exportVar = "module.exports"; +var options = { trackLineAndColumn: false }; while (args.length > 0 && isOption(args[0])) { switch (args[0]) { @@ -76,6 +78,10 @@ while (args.length > 0 && isOption(args[0])) { exportVar = args[0]; break; + case "--track-line-and-column": + options.trackLineAndColumn = true; + break; + case "-v": case "--version": printVersion(); @@ -129,7 +135,7 @@ switch (args.length) { readStream(inputStream, function(input) { try { - var parser = PEG.buildParser(input); + var parser = PEG.buildParser(input, options); } catch (e) { if (e.line !== undefined && e.column !== undefined) { abort(e.line + ":" + e.column + ": " + e.message);