1192 Commits (b3329e626ef8205e0eda452479e0bcf6e55ccc9e)
 

Author SHA1 Message Date
David Majda e5a5572a87 Factored the code emitter out of the compiler 14 years ago
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.
14 years ago
David Majda d7d1a0b28c Remove unused |PEG.ArrayUtils.range| utility function 14 years ago
David Majda 98da358ef4 Found a neater trick how to defend against |undefined| redefinition 14 years ago
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
14 years ago
David Majda 647e7be1fd Benchmark: Users can specify the number of runs 14 years ago
David Majda 4cae3f9b48 Benchmark: Make results table fixed-width, center everything 14 years ago
David Majda 1cdce63878 Updated version to 0.5 14 years ago
David Majda 374cf3644b CHANGELOG: Fix 0.5 release date 14 years ago
David Majda b30f4a9c34 README.md tweaks 14 years ago
David Majda 61fff6c70f Updated CHANGELOG 14 years ago
David Majda 08ea5e49d6 README.md: Fix example code 14 years ago
David Majda a616b00c83 Improve README.md 14 years ago
David Majda 5f810f803b Make example grammars compatible with Rhino 14 years ago
David Majda a93ad0a5b8 README.md: Make the "Compatibility" section a bulleted list 14 years ago
David Majda af1968054b Implement semantic predicates 14 years ago
David Majda 4895f4f8e4 Treat the whole grammar as an AST node 14 years ago
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.
14 years ago
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).
14 years ago
David Majda 66de889f4b Implement initializers 14 years ago
David Majda 718bcf5f87 Rename the |action| property of action AST nodes to |code| 14 years ago
David Majda c0f0d56975 Fix incorrect comment 14 years ago
David Majda 8a2e21fa3f Inlined the |initialContext| variable 14 years ago
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.
14 years ago
David Majda 1daf1448e5 Get rid of the |_startRule| property in generated parsers. 14 years ago
David Majda 95735f2c97 Allow trailing semicolon (";") for rules 14 years ago
David Majda 7d4911ec53 Emit little bit less whitespace in actions 14 years ago
David Majda ee8c121676 Use labeled expressions and variables instead of $1, $2, etc.
Labeled expressions lead to more maintainable code and also will allow
certain optimizations (we can ignore results of expressions not passed
to the actions).

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

Detailed results (benchmark suite totals):

---------------------------------
 Test #     Before       After
---------------------------------
      1   28.43 kB/s   28.46 kB/s
      2   28.38 kB/s   28.56 kB/s
      3   28.22 kB/s   28.58 kB/s
      4   28.76 kB/s   28.55 kB/s
      5   28.57 kB/s   28.48 kB/s
---------------------------------
Average   28.47 kB/s   28.53 kB/s
---------------------------------

Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.55 Safari/533.4
14 years ago
David Majda 52704593cd Allow labeled expressions in the metagrammar (without any meaning yet) 14 years ago
David Majda 409ddf2ae8 Formatted all grammars more consistently and transparently
This is purely cosmetical change, no functionality was affected
(hopefully).
14 years ago
David Majda 698564a3c2 Replace ":" after a rule name with "="
I'll introduce labelled expressions shortly and I want to use ":" as a
label-expression separator. This change avoids conflict between the two
meanings of ":". (What would e.g. "foo: 'bar'" mean?  Rule "foo"
matching string "bar", or string "bar" labelled "foo"?)
14 years ago
David Majda 7fdf0492c7 Fixed error message for invalid character range + added test 14 years ago
David Majda f9ea46ef15 Fix string literal parsing in the JavaScript grammar 14 years ago
David Majda 570658756a Remove useless action from the metagrammar 14 years ago
David Majda 9bf86b89a6 Fix stupid mistakes in metagrammar-test.js
The mistakes weren't caught because the first one introduces a syntax
error, causing the whole test suite not to load. Unfortunately, QUnit
didn't complain so I missed this.

The real commit these changes belong to is
33a1a7c1e9.
14 years ago
David Majda d1fc16c373 Fix bug causing incorrect error messages
The bug could cause the list of expected strings in an error message to
contain strings that shouldn't be there.

Closes #2.
14 years ago
David Majda 11c67b0507 Remove trailing whitespace 14 years ago
David Majda 90ed4712e9 Add compiler optimization: Remove proxy rules
This shouldn't have measurable effect on the benchmarks as there are no
proxy rules in the grammars the benchamrk uses. However the effect on
generated parsers' speed should be positive generally.
14 years ago
David Majda 33a1a7c1e9 Clean up class handling in the metagrammar and compiler
The class AST node now contains structured data and a raw text which is
used for error messages.
14 years ago
David Majda 137a4b4f53 Renamed |characters| -> |chars| (shorter, no loss of expressivity) 14 years ago
David Majda 4e968892be Guard against redefinition of |undefined|
In most cases, code pattern

  x === undefined

was transformed to

  typeof(x) === "undefined"

and similarly with |!==|.

In the generated code, the condition was simply made less strict to
avoid performance penalty of string comparison (I don't think JavaScript
VMs optimize this specific pattern to avoid it).
14 years ago
David Majda d85bfcb2e9 Fix comment typo 14 years ago
David Majda 76ed63c86e AST refactoring 6/6: Get rid of the |Grammar| namespace 14 years ago
David Majda b4bf49443a AST refactoring 5/6: Make AST classless 14 years ago
David Majda 41abb7ad92 AST refactoring 4/6: Rewrite compilation to not extend the AST nodes 14 years ago
David Majda 5885a34dde AST refactoring 3/6: Rewrite checks to not extend the AST nodes 14 years ago
David Majda c59516541f AST refactoring 2/6: Add |type| property to AST nodes 14 years ago
David Majda 4e99a2bda7 AST refactoring 1/6: Make properties of AST nodes public
Removed undescore prefix of the properties and deleted getters.
14 years ago
David Majda 1c7c5bb5da Correct variable name: "choice" -> "optional". 14 years ago
David Majda 81eced29b2 Whitespace fixes 14 years ago