243 Commits (10cca7b69ddd8bc268681a2506c5c01b26b08311)
 

Author SHA1 Message Date
David Majda 10cca7b69d src/utils.js: Fix unescaped "]" inside a regexp
Fixes the following JSHint error:

  ./src/utils.js: line 124, col 15, Unescaped ']'.
13 years ago
David Majda 6e934fccca src/utils.js: Fix missing/unnecessary semicolons
Fixes the following JSHint errors:

  ./src/utils.js: line 108, col 2, Unnecessary semicolon.
  ./src/utils.js: line 128, col 39, Missing semicolon.
  ./src/utils.js: line 140, col 4, Missing semicolon.
13 years ago
David Majda 938f655ccf src/utils.js: Fix variable redefinition in |escape|
Fixes the following JSHint errors:

  ./src/utils.js: line 76, col 20, 'escapeChar' is already defined.
  ./src/utils.js: line 77, col 16, 'length' is already defined.
  ./src/utils.js: line 80, col 17, 'escapeChar' used out of scope.
  ./src/utils.js: line 80, col 80, 'length' used out of scope.
13 years ago
David Majda c7f99019c2 Add "jake hint" task that checks all javaScript files using JSHint
This currently outputs many issues. These will be fixed in subsequent
commits.
13 years ago
David Majda a92676edce Upgrade QUnit to the current master
Exact commit ID: 96e42601cadcba989f80bd4c294b7e0ee4ff1d29
13 years ago
David Majda 468597be27 Use |charCodeAt| instead of |charCode| when matching one-character literals
The speedup is marginal (if any) but let's have this anyway.

Speed impact
------------
Before:     212.49 kB/s
After:      213.01 kB/s
Difference: 0.24%

Size impact
-----------
Before:     1056976 b
After:      1058314 b
Difference: 0.12%

(Measured by /tools/impact with Node.js v0.4.8 on x86_64 GNU/Linux.)

Closes GH-50.
13 years ago
David Majda d3aff0c66a Use |charAt| instead of |substr| when matching classes
Speed impact
------------
Before:     131.36 kB/s
After:      213.59 kB/s
Difference: 62.59%

Size impact
-----------
Before:     1056976 b
After:      1056976 b
Difference: 0.00%

(Measured by /tools/impact with Node.js v0.4.8 on x86_64 GNU/Linux.)

Closes GH-49.
13 years ago
David Majda 0a1cea5f12 Use |charAt| instead of |substr| when matching one-character literals
Speed impact
------------
Before:     130.62 kB/s
After:      133.76 kB/s
Difference: 2.40%

Size impact
-----------
Before:     1058371 b
After:      1056976 b
Difference: -0.14%

(Measured by /tools/impact with Node.js v0.4.8 on x86_64 GNU/Linux.)
13 years ago
David Majda 2fc877e875 Match literals using |RegExp.prototype.test|
This is little faster than |String.prototype.match| in successful cases
since return value of |test| is just a boolean, not a special array as
with |match|.

Speed impact
------------
Before:     130.75 kB/s
After:      131.81 kB/s
Difference: 0.81%

Size impact
-----------
Before:     1059811 b
After:      1058371 b
Difference: -0.14%

(Measured by /tools/impact with Node.js v0.4.8 on x86_64 GNU/Linux.)
13 years ago
David Majda 2d4ee4fb23 Make /tools/improve script measure speed 5 times and compute an average
I measured speed 5 times manually too before introducing the script. It
gives more stable results.
13 years ago
David Majda d0c96481bf Add /tools/impact script to measure speed and size impact of commits 13 years ago
David Majda d123cf0eda Rewrite variable handling in generated parsers
Before this commit, variables for saving match results and parse
positions in generated parsers were not used efficiently. Each rule
basically used its own variable(s) for storing the data, with names
generated sequentially during code emitting. There was no reuse of
variables and a lot of unnecessary assignments between them.

It is easy to see that both match results and parse positions can
actually be stored on a stack that grows as the parser walks deeper in
the grammar tree and shrinks as it returns. Moreover, if one creates a
new stack for each rule the parser enters, its maximum depth can be
computed statically from the grammar. This allows us to implement the
stack not as an array, but as a set of numbered variables in each
function that handles parsing of a grammar rule, avoiding potentially
slow array accesses.

This commit implements the idea from the previous paragraph, using
separate stack for match results and for parse positions. As a result,
defined variables are reused and unnecessary copying avoided.

Speed implications
------------------

This change speeds up the benchmark suite execution by 2.14%.

Detailed results (benchmark suite totals as reported by "jake benchmark"
on Node.js 0.4.8):

-----------------------------------
 Test #      Before        After
-----------------------------------
      1   129.01 kB/s   131.98 kB/s
      2   129.39 kB/s   130.13 kB/s
      3   128.63 kB/s   132.57 kB/s
      4   127.53 kB/s   129.82 kB/s
      5   127.98 kB/s   131.80 kB/s
-----------------------------------
Average   128.51 kB/s   131.26 kB/s
-----------------------------------

Size implications
-----------------

This change makes a sample of generated parsers 8.60% smaller:

Before:

  $ wc -c src/parser.js examples/*.js
   110867 src/parser.js
    13886 examples/arithmetics.js
   450125 examples/css.js
   632390 examples/javascript.js
    61365 examples/json.js
  1268633 total

After:

  $ wc -c src/parser.js examples/*.js
    99597 src/parser.js
    13077 examples/arithmetics.js
   399893 examples/css.js
   592044 examples/javascript.js
    54797 examples/json.js
  1159408 total
13 years ago
David Majda bb83b2189a Change how disabling failure reporting works in generated parsers
Disabling failure reporting is driven by the |reportFailures| variable.
So far it was a boolean and its value was saved before changing and
restored afterwards (requiring additional variable in few places). This
patch changes it to an integer where value 0 means "report errors" and
anything > 0 means "do not report errors".  Instead of saving/restoring
we can now simple increment/decrement (avoiding the additional
variable and simplifying the code).

This change speeds up the benchmark suite execution by 0.66%.

Detailed results (benchmark suite totals as reported by "jake benchmark"
on Node.js 0.4.8):

-----------------------------------
 Test #      Before        After
-----------------------------------
      1   129.26 kB/s   128.28 kB/s
      2   127.34 kB/s   127.53 kB/s
      3   126.72 kB/s   129.01 kB/s
      4   126.89 kB/s   128.05 kB/s
      5   126.46 kB/s   127.98 kB/s
-----------------------------------
Average   127.33 kB/s   128.17 kB/s
-----------------------------------
13 years ago
David Majda c6243fd872 Replace "MatchFailure" by "Failure" in many identifiers
Shorter identifier without much loss of meaning.
13 years ago
David Majda 8b2edd3c41 Remove trailing comma in parser tests (IE compatibility) 13 years ago
David Majda 8f3e2d9344 Update version to 0.6.2 13 years ago
David Majda 99f80e2541 Update CHANGELOG 13 years ago
David Majda 747cb8afaa Reset parser position when action returns |null|
The change does not change the benchmark suite execution speed
statistically significantly.

Detailed results (benchmark suite totals as reported by "jake benchmark"
on Node.js 0.4.8):

-----------------------------------
 Test #      Before        After
-----------------------------------
      1   128.20 kB/s   128.03 kB/s
      2   130.36 kB/s   128.73 kB/s
      3   126.53 kB/s   129.72 kB/s
      4   127.46 kB/s   127.48 kB/s
      5   127.63 kB/s   128.53 kB/s
-----------------------------------
Average   128.04 kB/s   125.50 kB/s
-----------------------------------

Closes GH-25.
13 years ago
David Majda 5cf66d824c Fix typo in JavaScript example grammar 13 years ago
David Majda c91dc7e54b Update version to 0.6.1 13 years ago
David Majda 96364ca623 Update CHANGELOG 13 years ago
David Majda cca707950d CHANGELOG: Fix version ("0.6" -> "0.6.0") 13 years ago
David Majda 9e9062d827 Use --ascii option when generating a minified version
This makes the minified version actually work and not cause syntax
errors when loaded into a browser (this happened with Chrome and Firefox
at least).
13 years ago
David Majda b399004a90 Update version to 0.6.0 + update release date in CHANGELOG 13 years ago
David Majda ffbe60094a Rewrite README.md 13 years ago
David Majda 1f89c7746f Quote keys in |parseFunctions| table in generated parsers
IE and Nitro choked when rule names that are JavaScript reserved words
(e.g. "class") were used.
13 years ago
David Majda 596bf6eba9 Update CHANGELOG 13 years ago
David Majda bafb8655f7 Clean up package.json
The engine's and dependencies' versions are the ones I've tested with.
Lower version will probably work too, but I don't want to spend more
time testing now so I'll play it safe.
13 years ago
David Majda 8d8a5e322f Fix @VERSION substitution in build-time preprocessing
The code didn't work properly when multiple @VERSION strings were
present in a preprocessed file.
13 years ago
David Majda 66e5418052 Build also minified version for the web in "jake dist" 13 years ago
David Majda 81fbbd7897 Make "test" and "benchmark" Jakefile tasks depend on "build"
This ensures the version tested/benchmarked is always up-to-date.
13 years ago
David Majda d00ba29ead Add "clean" and "distclean" Jakefile tasks 13 years ago
David Majda 69044e9d0b Add "dist" Jakefile task that prepares the distribution files 13 years ago
David Majda 827a5ac312 Add PEG.js version information and homepage header to peg.js 13 years ago
David Majda 9917f79991 Add PEG.js version to "Generated by..." line in generated parsers 13 years ago
David Majda aca15d6f36 Change Node.js pacakge name to from "peg" to "pegjs"
The only place where we use the name without "js" is the library
filename (peg.js) and consequently the module name (PEG).
13 years ago
David Majda db32ff2d0d Change version to 0.6.0pre 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 1e57bf778d Require Node.js 0.4 or higher
This is not strictly necessary now, but I won't test PEG.js with lower
versions, so I can't guarantee correct functionality.
13 years ago
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.
13 years ago
David Majda 13a3621e79 Export the PEG library in simpler and more robust way 13 years ago
David Majda 3e7d31559d Do not pass |global| into wrapping functions in tests, it's useless 13 years ago
David Majda cfc6041041 Remove function wrapping and all |global| refrences from helpers.js
Originally I wanted to be very explicit with accesses to global object,
but since all this file is about extending it, the |global.| qualifier
seems more like noise.
13 years ago
David Majda f0eab4728a Use Unicode box-drawing characters for command-line benchmark table
Hopefully this works reasonably in all environments where Node.js runs.
13 years ago
David Majda 17c1531068 Make "Avg. time" column in the commmand-line benchmark table wider 13 years ago
David Majda c3822835c9 Update copyright year in LICENSE 13 years ago
David Majda a042f78558 Fix unit in command-line benchmark runner 13 years ago
David Majda 4e81eb48af Add "jake test" and "jake benchmark" 13 years ago
David Majda 918dcf6ed2 Test and benchmark command-line runners can be run from any directory 13 years ago
David Majda aa2327191f Escape 0xFF still with "\x", not "\u" 13 years ago