502 Commits (c54483bb17e5e14a689f25d4bc08a6bab7c3aea8)
 

Author SHA1 Message Date
David Majda c54483bb17 Text nodes: Use text nodes in examples/javascript.pegjs 12 years ago
David Majda faaf9b6be1 Text nodes: Use text nodes in examples/css.pegjs 12 years ago
David Majda d0dfe46550 Text nodes: Use text nodes in examples/json.pegjs 12 years ago
David Majda 9ec6b6aa57 Text nodes: Use text nodes in examples/arithmetics.pegjs 12 years ago
David Majda f0a6bc92cc Text nodes: Use text nodes in PEG.js grammar 12 years ago
David Majda 5e146fce38 Text nodes: Implement text nodes
Implement a new syntax to extract matched strings from expressions. For
example, instead of:

  identifier = first:[a-zA-Z_] rest:[a-zA-Z0-9_]* { return first + rest.join(""); }

you can now just write:

  identifier = $([a-zA-Z_] [a-zA-Z0-9_]*)

This is useful mostly for "lexical" rules at the bottom of many
grammars.

Note that structured match results are still built for the expressions
prefixed by "$", they are just ignored. I plan to optimize this later
(sometime after the code generator rewrite).
12 years ago
David Majda af20f024c7 Text nodes: Disallow the "$" character in identifiers
The "$" character will mark text nodes in the future.
12 years ago
David Majda 4e46a6e46e Rebuild src/parser.js (forgotten in the previous commit) 12 years ago
David Majda 28860e88df Position tracking: Cache position info computed by |line| and |column|
Cache the last reported position info. If the position advances, the
code uses the cache and only computes the differnece. If the position
goes back, the cache is simply dropped.
12 years ago
David Majda 3333cdd18d Position tracking: Kill the |trackLineAndColumn| option
Getting rid of the |trackLineAndColumn| simplifies the code generator
(by unifying two paths in the code).

The |line| and |column| functions currently always compute all the
position info from scratch, which is horribly ineffective. This will be
improved in later commit(s).
12 years ago
David Majda da8c455640 Position tracking: Make |offset|, |line| and |column| functions
This will allow to compute position data lazily and get rid of the
|trackLineAndColumn| option without affecting performance of generated
parsers that don't use position data.
12 years ago
David Majda da9ab1bf17 Remove "make build" from tools/impact
There is no "build" target anymore.

This was forgotten in 0519d7e3ce.
12 years ago
David Majda 203243b884 README.md: Add link to the Trello board 12 years ago
David Majda bc9a2528ef Add backslash forgotten in the previous commit 12 years ago
David Majda 1988110a28 Fix code generated for classes starting with "\^"
Before this commit, incorrect regexps were produced for classes starting
with "\^". For example, this grammar:

  start = [\^a]

didn't match "a" because the generated regexp inside the parser was
/^[^a]/, not /^[\^a]/ as it should be.

This commit fixes the issue by escaping "^" in |quoteForRegexpClass|.

Fixes GH-125.
12 years ago
David Majda ff819cc579 Fix whitespace 12 years ago
David Majda 05a6bad989 Kill the |toSource| method, introduce the |output| option
Before this commit, |PEG.buildParser| always returned a parser object.
The only way to get its source code was to call the |toSource| method on
it. While this method worked for parsers produced by |PEG.buildParser|
directly, it didn't work for parsers instantiated by executing their
source code. In other words, it was unreliable.

This commit remvoes the |toSource| method on generated parsers and
introduces a new |output| option to |PEG.buildParser|. It allows callers
to specify whether they want to get back the parser object
(|options.output === "parser"|) or its source code (|options.output ===
"source"|). This is much better and more reliable API.
12 years ago
David Majda 3629d880d3 Make sure the |options| param passed to passes is always an object
Pass code can be simpler as a result.
12 years ago
David Majda ee1a0b5810 Add compiled examples to .gitignore
Based on patch by Pavel Lang (GH-96).
12 years ago
David Majda dd2216da7e Fix versions of development dependencies
This ensures stable environment for development, CI, browser builds,
etc.
12 years ago
David Majda 51e126882b Assume development dependencies are installed locally
This is compatible with what "npm install" does and allows for isolated
development environment.
12 years ago
David Majda 32e372be92 package.json: Formatting 12 years ago
David Majda 0519d7e3ce Git repo npmization: Make the repo a npm package
Includes:

  * Moving the source code from /src to /lib.
  * Adding an explicit file list to package.json
  * Updating the Makefile.
  * Updating the spec and benchmark suites and their READMEs.

Part of a fix for GH-32.
12 years ago
David Majda 4cda79951a Git repo npmization: Compose PEG.js from Node.js modules
PEG.js source code becomes a set of Node.js modules that include each
other as needed. The distribution version is built by bundling these
modules together, wrapping them inside a bit of boilerplate code that
makes |module.exports| and |require| work.

Part of a fix for GH-32.
12 years ago
David Majda c6cf129635 Git repo npmization: Do not use @VERSION
When the Git repository will be a npm package, there will be no
preprocessing step and thus no @VERSION substitution. Let's get rid of
it.

Part of a fix for GH-32.
12 years ago
David Majda d742ca5dc6 Makefile: Small reordering
Define |PEGJS_VERSION| before it is used. While defining it after its
first use was OK technically, it made the code a tiny bit harder to
read.
12 years ago
David Majda a7584fa878 Rebuild src/parser.js (forgotten in the previous commit) 12 years ago
David Majda 277fb23411 Setup prototype chain for |SyntaxError| in generated parsers correctly 12 years ago
David Majda 143924357b Setup prototype chain for |PEG.GrammarError| correctly 12 years ago
David Majda 428fe294cf Change |PEG.GrammarError| name
Change the value of the |name| property of |PEG.GrammarError| instances
from "PEG.GrammarError" to just "GrammarError". This better reflects the
fact that PEG.js can get required under different name than "PEG".
12 years ago
David Majda 12398ada9a Implement Travis CI integration 12 years ago
David Majda a2672e0b48 Make "npm test" work
This is will be useful for Travis CI integration
12 years ago
David Majda adfeb87c82 Do not preprecess package.json
Before this commit, package.json in the project root directory was
preprocessed in order to insert correct version into it. This made it
invalid JSON and thus unusable for npm purposes.

This commit makes package.json a valid JSON by hardcoding the version
into it. I think that introducing this small duplicity is outweighted by
being able to use npm in project root directory. For example, it is now
possible to make the "npm test" command work and introduce Travis CI
integration.
12 years ago
David Majda b1db42e1b4 Merge pull request #115 from fpirsch/patch-1
Changed "arguments" to "args" in a few places.
12 years ago
David Majda df1ecb1313 Fix typo found by Almad also in the generator 12 years ago
David Majda 710bee256a Merge pull request #113 from Almad/master
Grammar typo
12 years ago
David Majda e5e9ce2778 README.md: Wrap lines at column 80 12 years ago
David Majda 406ac0a288 Fix banner typo 12 years ago
fpirsch fa05142292 Update examples/javascript.pegjs
Changed "arguments" to "args" in several places to avoid shadowing "arguments", which is not allowed by Google Clusure Compiler.
12 years ago
Almad 030ac3d6f9 Grammar typo 12 years ago
David Majda 208cc33930 Allowed start rules must be specified explicitly
Before this commit, generated parser were able to start parsing from any
rule. This was nice, but it made rule code inlining impossible.

Since this commit, the list of allowed start rules has to be specified
explicitly using the |allowedStartRules| option of the |PEG.buildParser|
method (or the --allowed-start-rule option on the command-line). These
rules will be excluded from inlining when it's implemented.
12 years ago
David Majda 6a1ec7631f Do not modify |options| passed to |PEG.buildParser|
Modifying |options| can lead to subtle bugs.
12 years ago
David Majda 75a78c083c Fix typo in testcase description 12 years ago
David Majda e97c501072 README.md: Add wiki link 12 years ago
David Majda edb547958e README.md: Fix project website link 12 years ago
David Majda a4df483159 s/Modelled/Modeled/
"modelled" is a British variant, "modeled" an US one. PEG.js officially
uses American English.

Based on pull request by John Gietzen:

  https://github.com/dmajda/pegjs/pull/102
12 years ago
David Majda 98ff2eb83f Allow passing options to the parser
This commit replaces the |startRule| parameter of the |parse| method in
generated parsers with more generic |options| -- an options object. This
options object can be used to pass custom options to the parser because
it is visible as the |options| variable inside parser code.

The start rule can now be specified as the |startRule| option. This
means you have to replace all calls like:

  parser.parse("input", "myStartRule");

with

  parser.parse("input", { startRule: "myStartRule" });

Closes GH-37.
12 years ago
David Majda e90aacd934 Specs: Whitespace fix + add semicolon in tested parser code 12 years ago
David Majda a3fe36a466 Add missing semicolon 12 years ago
David Majda 7134b09e50 Merge |allocateRegisters| and |computeParams| passes
The purpose of this change is to avoid the need to index register
variables storing match results of sequences whose elements are labeled.
The indexing happened when match results of labeled elements were passed
to action/predicate functions.

In order to avoid indexing, the register allocator needs to ensure that
registers storing match results of any labeled sequence elements are
still "alive" after finishing parsing of the sequence. They should not
be used to store anything else at least until code of all actions and
predicates that can see the labels is executed. This requires that the
|allocateRegisters| pass has the knowledge of scoping. Because that
knowledge was already implicitly embedded in the |coputeParams| pass,
the logical step to prevent duplication was to merge it with the
|allocateRegisters| pass. This is what this commit does.

As a part of the merge the tests of both passes were largely refactored.
This is both to accomodate the merge and to make the tests in sync with
the code again (the tests became a bit out-of-sync during the last few
commits -- they tested more than was needed).

The speed/size impact is slightly positive:

Speed impact
------------
Before:     849.86 kB/s
After:      858.16 kB/s
Difference: 0.97%

Size impact
-----------
Before:     876618 b
After:      875602 b
Difference: -0.12%

(Measured by /tools/impact with Node.js v0.6.18 on x86_64 GNU/Linux.)
12 years ago