Commit graph

17 commits

Author SHA1 Message Date
David Majda dcf904c392 bin/pegjs: Default parser variable name is "module.exports"
The previous default name was "exports.parser". This meant that to use
the generated parser in Node.js, you had to use code like this:

  var parser = require("./my-cool-parser").parser;
  parser.parse(...);

Now you can shorten it a bit:

  var parser = require("./my-cool-parser");
  parser.parse(...);

The shorter version makes sense since no other objects except the parser
are exported from the module.
2011-02-13 12:43:12 +01:00
David Majda d5caaa7877 Nicer messages in command-line mode on read/write errors 2011-01-26 14:01:57 +01:00
David Majda 957b96c1b5 Add check for missing parameter of the -e/--export-var option. 2011-01-26 13:52:39 +01:00
David Majda d0c074e2f8 Small style fixes 2011-01-26 13:05:40 +01:00
David Majda 814ce7d9db Switch command-line mode backend from Rhino to Node 2011-01-24 10:57:00 +01:00
David Majda 4d68812b65 Fix usage description 2010-11-14 18:13:28 +01:00
David Majda 977d1d20c7 Fix wrong version reported by "bin/pegjs --version"
DRY: Now the version is stored only in the VERSION file.
2010-11-14 17:14:10 +01:00
David Majda a12a24fca1 Make parsers generated by /bin/pegjs CommonJS modules by default 2010-09-28 16:44:04 +02:00
David Majda e59f3ba338 Split the source code into several files, introduce build system
The source code is now in the src directory. The library needs to be
built using "rake", which creates the lib/peg.js file by combining the
source files.
2010-08-15 19:45:51 +02:00
David Majda 917cf1cf2a Start rule of the grammar is now implicitly its first rule
Before this change, the start rule was the one named "start" and there
was an option to override that. This is now impossible.

The goal of this change is to contain all information for the parser
generation in the grammar itself.

In the future, some override directive for the start rule (like Bison's
"%start") may be added to the grammar.
2010-06-08 11:03:28 +02:00
David Majda 81eced29b2 Whitespace fixes 2010-05-14 18:02:45 +02:00
David Majda 08635b658b Make bin/pegjs work when called via a symlink
Similar issue exists on Windows too (they have symlinks since Vista), but I
could not find how to dereference symlinks from batch files, so I did not fix
it. I guess this does not matter much given how little the symlinks are used in
the Windows world.

Closes #1.
2010-05-14 17:47:25 +02:00
David Majda e63f64a3d5 Make the generated parsers standalone (no runtime is required).
This and also speeds up the benchmark suite execution by 7.83 % on V8.

Detailed results (benchmark suite totals):

---------------------------------
 Test #     Before       After
---------------------------------
      1   26.17 kB/s   28.16 kB/s
      2   26.05 kB/s   28.16 kB/s
      3   25.99 kB/s   28.10 kB/s
      4   26.13 kB/s   28.11 kB/s
      5   26.14 kB/s   28.07 kB/s
---------------------------------
Average   26.10 kB/s   28.14 kB/s
---------------------------------

Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.7 Safari/533.2
2010-04-12 19:06:04 +02:00
David Majda d3104742d9 Fixed --start vs. --start-rule inconsistency between help and actual option processing code. 2010-03-13 15:23:59 +01:00
David Majda a43d1b33e3 Bootstrapped the grammar parser, yay! I should have done this long ago. 2010-03-13 15:18:57 +01:00
David Majda 0a5788b50e Fixed typo in help: "parserVar" -> "parser_var". 2010-03-13 09:50:56 +01:00
David Majda c3dd696a3e Initial commit. 2010-03-07 20:41:02 +01:00