Commit graph

165 commits

Author SHA1 Message Date
David Majda c8836c0312 Remove two unused variables 2010-08-22 18:15:53 +02:00
David Majda 7b03f164b8 Avoid passing |context| in the generated parser
Passing the context is not necessary, global variable is good enough
(passing the context would make more sense if each AST node was
translated into a function call, but this isn't the case).

The performance gain is very small, on the border of statstical error.

Results of benchmark with 100 runs on V8:

  Before:  31.49 kB/s
  After:   31.57 kB/s
  Speedup: 0.254 %

Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.4 (KHTML, like
Gecko) Chrome/5.0.375.127 Safari/533.4
2010-08-22 17:56:08 +02:00
David Majda a42b957573 Remove now mostly useless comment headers from the code 2010-08-21 15:38:17 +02:00
David Majda d493a4d143 Move test helper into its own file + reorder test file includes 2010-08-21 15:34:56 +02:00
David Majda fea6d85194 Little compiler tests clean-up 2010-08-21 15:30:23 +02:00
David Majda 8918d77da1 Add compiler passes tests (currently testing the one pass that exists) 2010-08-21 14:36:44 +02:00
David Majda 95f70c9562 Test the checks directly, do not go through |PEG.buildParser| 2010-08-21 11:59:42 +02:00
David Majda f82a4ebf28 Compiler checks and passes are named for easier reference from tests 2010-08-21 11:55:46 +02:00
David Majda 906488027b Fix stupid mistakes in the |buildNodeVisitor| function 2010-08-21 11:54:35 +02:00
David Majda 1b75a7b9b3 Split-off |PEG.compiler.checks| tests 2010-08-18 21:15:48 +02:00
David Majda b15eb0bb5f Change term "grammar parser" to "parser" in tests 2010-08-18 21:07:04 +02:00
David Majda b105c43756 Define |global| object in different way in tests 2010-08-18 20:59:03 +02:00
David Majda f787793848 Rename |node| -> |subnode| to avoid aliasing 2010-08-17 20:53:13 +02:00
David Majda 088c78e88c Fix incorrect variable name on two places 2010-08-17 20:44:24 +02:00
David Majda 4d50a37b14 Extract |buildNodeVisitor| 2010-08-17 20:34:14 +02:00
David Majda 1279e87766 Simplify utility functions structure + do not export them as part of the PEG object 2010-08-16 21:20:37 +02:00
David Majda 5ab36f8018 Split the vendor directory
There are now three vendor directories. The goal is to have test- and
benchmark-specific stuff is its own directories and not in the main one.

  vendor
  test/vendor
  benchmark/vendor
2010-08-15 19:50:59 +02:00
David Majda 44f541330e Rakefile: Make everything dependencies-based again 2010-08-15 19:45:51 +02:00
David Majda 9e2fc76fc5 Rakefile: Rename "metaparser" task to "parser"
This is more consistent with nomenclature in the code and with the file
names.
2010-08-15 19:45:51 +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 95a78892de Rename |PEG.compiler.compileParser| to |PEG.compiler.compile|
It's shorter and more consistent with |PEG.parser.parse|.
2010-08-14 17:49:14 +02:00
David Majda 5e64d09a15 Renamed some properties of the |PEG| object
1. |PEG.Compiler| -> |PEG.compiler|
2. |PEG.grammarParser| -> |PEG.parser|

This brings us closer to the desired structure of the PEG object, which
is:

  +-PEG
    |- parser
    +- compiler
       |- checks
       |- passes
       +- emitter

These are the only things (together with the |PEG.buildParser| function
and exceptions) that I want to be publicly accessible -- as extension
points and also for easy testing of PEG.js's components.
2010-08-14 17:49:03 +02:00
David Majda 1682a25b0d Move emitter utility functions out of |PEG.Compiler| 2010-08-14 17:48:55 +02:00
David Majda e5a5572a87 Factored the code emitter out of the compiler 2010-08-14 17:48:47 +02:00
David Majda 2622f432bd Move compiler checks and passes out of |PEG.Compiler| definition
This allows splitting them into separate files in the future. It also
decreases indentation level in the code.
2010-08-14 17:48:39 +02:00
David Majda d7d1a0b28c Remove unused |PEG.ArrayUtils.range| utility function 2010-08-14 17:48:26 +02:00
David Majda 98da358ef4 Found a neater trick how to defend against |undefined| redefinition 2010-08-14 17:48:17 +02:00
David Majda c3b5c2131a Benchmark: Factor benchmark into several functions run using |setTimeout|
We do this for two reasons:

  1. To avoid bowser mechanism for interrupting long-running scripts to
     kick-in (or at least to not kick-in that often).

  2. To ensure progressive rendering of results in the browser (some
     browsers do not render at all when running JavaScript code).

This does not change the benchmark suite execution speed statistically
significantly on V8.

Detailed results (benchmark suite totals):

---------------------------------
 Test #     Before       After
---------------------------------
      1   31.04 kB/s   31.18 kB/s
      2   31.26 kB/s   30.89 kB/s
      3   31.15 kB/s   31.19 kB/s
      4   30.52 kB/s   31.21 kB/s
      5   31.00 kB/s   30.73 kB/s
---------------------------------
Average   30.99 kB/s   31.04 kB/s
---------------------------------

Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.99 Safari/533.4
2010-07-24 14:48:12 +02:00
David Majda 647e7be1fd Benchmark: Users can specify the number of runs 2010-07-21 22:38:44 +02:00
David Majda 4cae3f9b48 Benchmark: Make results table fixed-width, center everything 2010-07-21 21:53:09 +02:00
David Majda 1cdce63878 Updated version to 0.5 2010-06-10 09:54:23 +02:00
David Majda 374cf3644b CHANGELOG: Fix 0.5 release date 2010-06-10 09:53:14 +02:00
David Majda b30f4a9c34 README.md tweaks 2010-06-10 09:43:08 +02:00
David Majda 61fff6c70f Updated CHANGELOG 2010-06-09 10:28:36 +02:00
David Majda 08ea5e49d6 README.md: Fix example code 2010-06-09 09:44:33 +02:00
David Majda a616b00c83 Improve README.md 2010-06-09 09:40:22 +02:00
David Majda 5f810f803b Make example grammars compatible with Rhino 2010-06-08 17:01:54 +02:00
David Majda a93ad0a5b8 README.md: Make the "Compatibility" section a bulleted list 2010-06-08 15:06:21 +02:00
David Majda af1968054b Implement semantic predicates 2010-06-08 14:49:13 +02:00
David Majda 4895f4f8e4 Treat the whole grammar as an AST node 2010-06-08 12:46:16 +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 70cf4cd94d Reset generated variable names for each rule parsing function
Little change in the source grammar now does not change variables in all
the generated code. This is helpful especially when one has the
generated grammar stored in a VCS (this is true e.g. for our
metagrammar).
2010-06-08 09:35:58 +02:00
David Majda 66de889f4b Implement initializers 2010-06-08 09:15:09 +02:00
David Majda 718bcf5f87 Rename the |action| property of action AST nodes to |code| 2010-06-07 16:47:17 +02:00
David Majda c0f0d56975 Fix incorrect comment 2010-06-07 16:06:50 +02:00
David Majda 8a2e21fa3f Inlined the |initialContext| variable 2010-06-07 16:04:21 +02:00
David Majda 439c815e48 Move lot of stuff in generated parsers into the |parse| method
We want to have the rule parsing functions inside the |parse| method
because we want them to share a common environment. In the future,
initializers will be executed in this enviromnent and thus functions and
variables defined by them will be accessible to the rule parsing
functions.

Moving various private properties from the parser object into the
|parse| method was not strictly necessary, but it was a natural step
after moving the functions.
2010-06-07 15:22:29 +02:00
David Majda 1daf1448e5 Get rid of the |_startRule| property in generated parsers. 2010-06-07 11:43:02 +02:00
David Majda 95735f2c97 Allow trailing semicolon (";") for rules 2010-06-07 10:59:14 +02:00
David Majda 7d4911ec53 Emit little bit less whitespace in actions 2010-06-07 10:45:26 +02:00