12 Commits (9917f799911c99802259fac0172cfd9e955b3d1d)

Author SHA1 Message Date
David Majda 9917f79991 Add PEG.js version to "Generated by..." line in generated parsers 13 years ago
David Majda cc7ad9739f Add ability to start parsing from any grammar rule
Calling the parsing function could have been done without the ugly table
using |eval|, but this seemed to degrade performance significantly (by
about 3 %). This is probably because engines optimize badly in presence
of |eval|.

The method used in this patch does not change the benchmark suite
execution speed statistically significantly on V8.

Detailed results (benchmark suite totals):

---------------------------------
 Test #     Before       After
---------------------------------
      1   38.24 kB/s   38.28 kB/s
      2   38.35 kB/s   38.15 kB/s
      3   38.43 kB/s   38.40 kB/s
      4   38.53 kB/s   38.20 kB/s
      5   38.25 kB/s   38.39 kB/s
---------------------------------
Average   38.36 kB/s   38.39 kB/s
---------------------------------

Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.1
13 years ago
David Majda aa2327191f Escape 0xFF still with "\x", not "\u" 13 years ago
David Majda fc1f489165 Save one concatenation when creating cache keys in generated parsers
Results of benchmark with 100 runs on V8:

  Before:  38.06 kB/s
  After:   38.72 kB/s
  Speedup: 1.734 %

Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.10 (KHTML, like
Gecko) Chrome/8.0.552.237 Safari/534.10
13 years ago
David Majda aeb2cb4f1c Make sure quoting functions output only ASCII characters
This patch prevents portability problems. In particular, it fixes a
problem where "SyntaxError: Invalid range in character class." error
appeared when using command-line version on Widnows (see GH-13).
14 years ago
David Majda 2d38c5cab3 Handle non-unique expected values of match failuers differently
Before this commit, uniqueness was checked when addding the failure. Now
we make the entiries unique when generating the error report, saving a
little time when the parsing is successful. This does not increase the
benchmark numbers too much though.

Results of benchmark with 100 runs on V8:

  Before:  37.25 kB/s
  After:   37.41 kB/s
  Speedup: 0.241 %

Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like
Gecko) Chrome/6.0.472.63 Safari/534.3
14 years ago
David Majda b6288a8d9c Avoid quoting when reporting errors for literals
This is a small win performance-wise.

Results of benchmark with 100 runs on V8:

  Before:  31.65 kB/s
  After:   32.83 kB/s
  Speedup: 3.728 %

Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.4 (KHTML, like
Gecko) Chrome/5.0.375.127 Safari/533.4
14 years ago
David Majda c8836c0312 Remove two unused variables 14 years ago
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
14 years ago
David Majda 4d50a37b14 Extract |buildNodeVisitor| 14 years ago
David Majda 1279e87766 Simplify utility functions structure + do not export them as part of the PEG object 14 years ago
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.
14 years ago