David Majda
52d7ec2224
Implement |trackLineAndColumn| option for |PEG.buildParser|
...
This option makes the generated parser track line and column during
parsing. Tracked line and column are made available inside actions and
predicates as |line| and |column| variables.
Note that in actions these variables denote start position of the
action's expression while in predicates they denote the current
position. The slightly different behavior is motivated by expected
usage.
2012-03-26 20:15:29 +02:00
David Majda
9615eb4bb6
Allow passing options to |PEG.buildParser|
...
These get passed down to the emitter templates.
2012-03-26 20:15:23 +02:00
David Majda
f2f88b87ea
Make current parse position visible in actions and predicates
...
The speed/size impact is insignificant.
Speed impact
------------
Before: 214.11 kB/s
After: 214.87 kB/s
Difference: 0.35%
Size impact
-----------
Before: 1042691 b
After: 1046731 b
Difference: 0.38%
(Measured by /tools/impact with Node.js v0.6.6 on x86_64 GNU/Linux.)
2012-03-06 19:55:55 +01:00
David Majda
f47da5c682
Fix a bug in param name fixup code for sequences
2012-03-06 08:46:28 +01:00
David Majda
4d5b1d58aa
AST: Store rules in an array instead of an object
...
This simplifies the code a bit and makes the AST more regular (each node
type has a fixed set of properties). The latter may get useful later
when generalizing visitors.
2012-03-04 17:29:32 +01:00
David Majda
bc5abfef5c
Replace Jakefile with Makefile
...
Doing scripting tasks in JavaScript is painful.
2012-03-04 11:46:28 +01:00
David Majda
ed45a1808e
Fix |quote| visibility in generated parsers
...
|quote| is used outside of the |parse| function so it must be defined in
more outer scope.
Fixes a problem (introduced in e9d8dc8eba
)
where construction of some error messages could throw an error.
2012-03-04 11:32:18 +01:00
David Majda
a2af1fe612
Semantic predicates now have access to preceding labels
...
Part of a fix for GH-69.
2012-02-27 20:18:21 +01:00
David Majda
4cf50bcf9f
Move param computations from the emitter into a separate pass
...
This has two main benefits:
1. The knowledge about scoping params in at one designated place,
making all future adjustments in this area easier.
2. Action-related code does not handle sequences specially anymore.
Such knowledge/behavior doesn't belong there.
2012-02-27 20:18:03 +01:00
David Majda
efc38eef9b
Consolidate all variable name computations into one compiler pass
...
Before this change, knowledge about variable names was spread between
the |computeStackDepths| pass and the code emitter code. For example,
the fact that the |&...| expression needs one variable to store a
position was represented in both places.
This changes consolidates that knowledge and introduces a new
|computeVarNames| pass. This pass replaces old |computeStackDepths|
pass, does all computations realted to variable names and stores the
results in the AST. Note that some knowledge about variables
(inevitably) remained in emitter code templates.
Beside DRYing things up, this change simplifies the emitter
significantly. By storing variable names in the AST it also allows
introduction of a pass that will identify parameters passed to actions
using proper symbol tables. Right now, this is done in a hackish way
directly in the emitter, which won't work well with changes planned in
GH-69.
2012-02-27 20:10:25 +01:00
David Majda
9d96e1e303
README.md: Update compatibility information
2012-02-13 08:40:12 +01:00
David Majda
d002cd6ff6
Remove comment about IE in |quoteForRegexpClass|
...
We escape null for general compatibility (see comment at the top of the
function), not only because of IE.
2012-02-13 08:13:01 +01:00
David Majda
a0898388fb
/bin/pegjs: Avoid calling |process.openStdin|
...
While |process.openStdin| is not officially deprecated, it's no longer
documented and just using |process.stdin| and resuming it seems to be
the official way.
2012-02-12 19:16:42 +01:00
David Majda
de256105eb
/bin/pegjs: Don't close standard output
...
Avoids "Error: process.stdout cannot be closed" error when invoked
without file arguments.
2012-02-12 19:11:56 +01:00
David Majda
70e4166bb2
Fix typo in a comment in JavaScript example grammar
2012-02-12 15:35:26 +01:00
David Majda
46b2eaf3e3
Add |expected| and |found| properties to exceptions thrown by parsers
...
Based on a patch by Marcin Stefaniuk (marcin@stefaniuk.info ).
2012-02-12 12:28:59 +01:00
David Majda
e9d8dc8eba
More responsibility for building an error message into |SyntaxError|
2012-02-12 12:28:59 +01:00
David Majda
21c6d9ccd3
Add |offset| property to exceptions thrown by parsers
...
Based on a patch by Marcin Stefaniuk (marcin@stefaniuk.info ).
2012-02-12 12:28:53 +01:00
David Majda
8ae3eea7c4
Fix typo in JavaScript example grammar
...
Fixes GH-62.
2012-02-04 22:25:06 +01:00
David Majda
433c278e5d
Merge pull request #59 from jasondavies/typo
...
Fix typo in comment.
2012-01-11 11:26:47 -08:00
David Majda
791c495aec
Update embedded Codie to version 1.0.1
2012-01-09 20:10:05 +01:00
David Majda
fb5028eb90
Use |util| module instead of |sys|
...
|sys| emits a warning in Node.js 0.6.x.
2012-01-07 12:01:11 +01:00
David Majda
fa1523b651
Update version of Node.js and development dependencies in package.json
...
The new versions are the ones I test with.
2012-01-07 11:55:26 +01:00
Jason Davies
d386d3a351
Fix typo in comment.
2011-10-09 16:38:26 +01:00
David Majda
47969a2f61
Replace |for| loop iterating over sequence elements with |each|
2011-10-03 15:12:50 +02:00
David Majda
a19ea83ffa
Replace |for| loop iterating over compiler passes with |each|
2011-10-03 14:57:09 +02:00
David Majda
cd5490dee4
Make pass list customizable via |PEG.compiler.appliedPassNames| property
2011-10-03 14:57:09 +02:00
David Majda
8a0276ffb7
Unify checks and passes
...
There is no real reason to have them separated.
2011-10-03 14:57:09 +02:00
David Majda
6cd5bdc5e6
Passes now do not return anything (they always modify the AST in-place)
2011-10-03 14:57:09 +02:00
David Majda
3983f46d5d
Rename |reportMissingReferencedRules| check to |reportMissingRules|
...
The new name is shorter, there is no real loss of meaning.
2011-10-03 14:56:54 +02:00
David Majda
64d26e5db2
Make names of compiler checks and passes verbs
2011-10-03 13:34:25 +02:00
David Majda
2a82d863e5
Regenerate src/parser.js (forgot to do it in previous commit)
2011-10-01 19:50:52 +02:00
David Majda
8acea01525
Fix reported error position when part of the input is not consumed
...
Closes GH-48.
2011-10-01 18:46:57 +02:00
David Majda
c90e7f369b
Fix regexp for detecting command-line options in /bin/pegjs
...
Closes GH-51.
2011-10-01 16:59:05 +02:00
David Majda
5013f79e8d
Make "jake clean" and "jake distclean" check deleted directory existence
...
Closes GH-52.
2011-10-01 16:50:31 +02:00
David Majda
211a1116e4
Fix stack depth computations for empty sequences
...
Part of a fix for GH-53.
2011-09-30 19:47:05 +02:00
David Majda
afdcb6fc4f
Fix |posStackDepth| computation for rules
...
Rules by themselves do not need any variable for storing position.
Part of a fix for GH-53.
2011-09-30 17:57:48 +02:00
David Majda
756b6fc473
Fix |resultStackDepth| computation for sequences
...
The |1 + ...| was wrong -- sequence does not need its own variable since
it reuses the one used by the first item.
Part of a fix for GH-53.
2011-09-30 17:23:57 +02:00
David Majda
9c3da347cc
Fix string parsing tests
...
The tests were wrong because the |string| rule is not used to parse
literals but rule names.
2011-09-30 16:49:50 +02:00
David Majda
3421bdb813
Test trailing characters for strings and literals at correct places
2011-09-30 16:44:44 +02:00
David Majda
c639c1fc83
PEG.js grammar: Replace two instances of |string / ""| by |string?|
2011-09-30 16:37:47 +02:00
David Majda
c04af99df8
Implament case-insensitive class matching
2011-09-30 11:45:36 +02:00
David Majda
b540b2d460
Implement case-insensitive literal matching
2011-09-30 11:20:37 +02:00
David Majda
88c50a3e33
Add tests for zero- and one-char literals
...
We optimize these cases in the emitter so we should better test them.
2011-09-30 10:53:12 +02:00
David Majda
1c11e4aaa3
Split |literal| rule in the PEG.js grammar to |literal| and |string|
...
This is just a formality now but it will make sense later when literals
(but not strings) will allow "i" flag for case-insensitive matching.
2011-09-30 10:21:29 +02:00
David Majda
950cc80738
Few small README.md fixes
2011-09-29 17:02:02 +02:00
David Majda
da12c2f5d4
Compile Codie templates only once
2011-09-29 13:47:50 +02:00
David Majda
a5af9611a2
Introduce |context.delta| function to make creating contexts more DRY
2011-09-27 16:36:58 +02:00
David Majda
be3b87ec71
Refactor "grammar" emitter function a bit
2011-09-24 17:09:58 +02:00
David Majda
2b09a7116d
Refactor "rule" emitter function a bit
2011-09-24 17:09:53 +02:00