167 Commits (2d38c5cab3e4b63654b9947422ef67728a011850)
 

Author SHA1 Message Date
David Majda 95735f2c97 Allow trailing semicolon (";") for rules 15 years ago
David Majda 7d4911ec53 Emit little bit less whitespace in actions 15 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
15 years ago
David Majda 52704593cd Allow labeled expressions in the metagrammar (without any meaning yet) 15 years ago
David Majda 409ddf2ae8 Formatted all grammars more consistently and transparently
This is purely cosmetical change, no functionality was affected
(hopefully).
15 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"?)
15 years ago
David Majda 7fdf0492c7 Fixed error message for invalid character range + added test 15 years ago
David Majda f9ea46ef15 Fix string literal parsing in the JavaScript grammar 15 years ago
David Majda 570658756a Remove useless action from the metagrammar 15 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.
15 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.
15 years ago
David Majda 11c67b0507 Remove trailing whitespace 15 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.
15 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.
15 years ago
David Majda 137a4b4f53 Renamed |characters| -> |chars| (shorter, no loss of expressivity) 15 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).
15 years ago
David Majda d85bfcb2e9 Fix comment typo 15 years ago
David Majda 76ed63c86e AST refactoring 6/6: Get rid of the |Grammar| namespace 15 years ago
David Majda b4bf49443a AST refactoring 5/6: Make AST classless 15 years ago
David Majda 41abb7ad92 AST refactoring 4/6: Rewrite compilation to not extend the AST nodes 15 years ago
David Majda 5885a34dde AST refactoring 3/6: Rewrite checks to not extend the AST nodes 15 years ago
David Majda c59516541f AST refactoring 2/6: Add |type| property to AST nodes 15 years ago
David Majda 4e99a2bda7 AST refactoring 1/6: Make properties of AST nodes public
Removed undescore prefix of the properties and deleted getters.
15 years ago
David Majda 1c7c5bb5da Correct variable name: "choice" -> "optional". 15 years ago
David Majda 81eced29b2 Whitespace fixes 15 years ago
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.
15 years ago
David Majda 6f2a188efc Checks refactoring
Changed two things:

  1. Checks are run in |PEG.Compiler.compileParser|, not in
     |PEG.buildParser|.

  2. Checks are extracted into separate functions.
15 years ago
David Majda 85930cbcfe Reorder AST stuff more consistently and sensibly
There is no functional change in this commit.
15 years ago
David Majda f28c52fde2 Rename |_element| to |_expression| in AST
All nodes which have one subexpression store it in the |_expression| property
now.
15 years ago
David Majda 7d1261c0fc Regenerate lib/metagrammar.js (forgot to do it in previous commit) 15 years ago
David Majda cc7f1d96eb Avoid |call| when calling actions with one parameter.
This speeds up the benchmark suite execution by 0.18%, which may just be a
measurement error. (Standrad statistic tests would tell more, but I don't want
to mess with them now.) The code is little bit nicer this way though.

Going further and avoiding |apply| seems to slow thigs down a bit, possibly
because multiple array accesses. I may try improved version without array
accesses (where Action passes the Sequence variable names to save the results
into) sometime later.

Detailed results (benchmark suite totals):

---------------------------------
 Test #     Before       After
---------------------------------
      1   29.08 kB/s   28.91 kB/s
      2   28.72 kB/s   28.75 kB/s
      3   28.78 kB/s   28.88 kB/s
      4   28.57 kB/s   28.90 kB/s
      5   28.84 kB/s   28.81 kB/s
---------------------------------
Average   28.80 kB/s   28.85 kB/s
---------------------------------

Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.9 Safari/533.2
15 years ago
David Majda e3aa4df090 Changed action parameter processing to avoid the arguments object.
The action now computes the number of passed parameters during the code
generation and the parameters are declared directly as $1, $2, etc. in the
generated function.

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

Detailed results (benchmark suite totals):

---------------------------------
 Test #     Before       After
---------------------------------
      1   28.68 kB/s   29.08 kB/s
      2   28.77 kB/s   28.72 kB/s
      3   28.89 kB/s   28.78 kB/s
      4   28.84 kB/s   28.57 kB/s
      5   28.86 kB/s   28.84 kB/s
---------------------------------
Average   28.81 kB/s   28.80 kB/s
---------------------------------

Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.9 Safari/533.2
15 years ago
David Majda a1dcd245bb Action AST node no longer accepts functions as actions (only strings). 15 years ago
David Majda b2f230fad2 Added Optional AST node.
This does not speed up the benchmark suite execution statistically significantly
on V8.

Detailed results (benchmark suite totals):

---------------------------------
 Test #     Before       After
---------------------------------
      1   28.84 kB/s   28.75 kB/s
      2   28.76 kB/s   28.69 kB/s
      3   28.72 kB/s   28.69 kB/s
      4   28.84 kB/s   28.93 kB/s
      5   28.82 kB/s   28.70 kB/s
---------------------------------
Average   28.80 kB/s   28.75 kB/s
---------------------------------

Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.2 (KHTML, like Gecko)
Chrome/5.0.342.9 Safari/533.2
15 years ago
David Majda e5df8284b5 Added AndPredicate AST node.
This does not speed up the benchmark suite execution statistically significantly
on V8.

Detailed results (benchmark suite totals):

---------------------------------
 Test #     Before       After
---------------------------------
      1   28.72 kB/s   28.84 kB/s
      2   28.84 kB/s   28.76 kB/s
      3   28.83 kB/s   28.72 kB/s
      4   28.81 kB/s   28.84 kB/s
      5   28.76 kB/s   28.82 kB/s
---------------------------------
Average   28.79 kB/s   28.80 kB/s
---------------------------------

Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.9 Safari/533.2
15 years ago
David Majda c3c1c79665 Added OneOrMore AST node.
This speeds up the benchmark suite execution by 1.08% on V8.

Detailed results (benchmark suite totals):

---------------------------------
 Test #     Before       After
---------------------------------
      1   28.38 kB/s   28.72 kB/s
      2   28.52 kB/s   28.84 kB/s
      3   28.41 kB/s   28.83 kB/s
      4   28.47 kB/s   28.81 kB/s
      5   28.64 kB/s   28.76 kB/s
---------------------------------
Average   28.48 kB/s   28.79 kB/s
---------------------------------

Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.9 Safari/533.2
15 years ago
David Majda 8f59e21c8d Renamed an iterator variable: "key" -> "rule". 15 years ago
David Majda 3f5cb8850c Fixed PEG.buildParser's documentation and added a test. 15 years ago
David Majda 48da65d08e PEG.buildParser now accepts grammars only in string format. 15 years ago
David Majda 927f2d65c9 Exception tests also test exception messages. 15 years ago
David Majda b5ac4f0c4a Refactored helpers for testing of thrown exceptions. 15 years ago
David Majda de7536fd94 Added notes about ECMA-262, 5th ed. compatibility to the JSON example grammar. 15 years ago
David Majda a86e06a216 Add "Generated by ..." message to the generated parsers. 15 years ago
David Majda f37ca3fcdb Updated version to 0.4 15 years ago
David Majda 870144b439 Added CHANGELOG. 15 years ago
David Majda 7214de6dc8 README.md: Removed unnecessary "id" attribute from the example. 15 years ago
David Majda db4cc71f2c README.md: Fixed formatting. 15 years ago
David Majda 7822379c70 Rewrote the "Usage" section. 15 years ago
David Majda c9a5e283e7 README.md: Renamed the "Requirements" section to "Compatibility" and moved it at the end. 15 years ago
David Majda 3752fe211a README.md: Added the "Features" section. 15 years ago