233 Commits (8bd4d390a9f43b730cd4403b4c767847e1e8cd4e)

Author SHA1 Message Date
David Majda 1471df9a69 Jasmine: Convert |reportLeftRecursion| compiler pass tests 12 years ago
David Majda 2889ca72fc Jasmine: Convert |reportMissingRules| compiler pass tests 12 years ago
David Majda e030834a0e Delete test/compiler-test.js 12 years ago
David Majda 112e4122d0 Jasmine: Convert remaining error reporting tests 12 years ago
David Majda 94aaf4ec75 Jasmine: Convert error position reporting tests 12 years ago
David Majda 1825dd4a42 Jasmine: Convert start rule tests 12 years ago
David Majda 68bfeac134 Jasmine: Drop the idempotence test
The code this test covered is long gone.
12 years ago
David Majda f61813238d Jasmine: Convert complex example tests 12 years ago
David Majda 022a51f94e Jasmine: Convert cache tests 12 years ago
David Majda e9f7255d47 Jasmine: Convert initializer tests 12 years ago
David Majda f5f40f68d2 Jasmine: Convert choice matching tests 12 years ago
David Majda 1b0789fbae Jasmine: Convert sequence matching tests 12 years ago
David Majda ae8a89c9e4 Jasmine: Convert labeled matching tests 12 years ago
David Majda b013ba8cc9 Jasmine: Convert simple and matching tests 12 years ago
David Majda 343e9db525 Jasmine: Convert simple not matching tests 12 years ago
David Majda 2bb25efa44 Jasmine: Convert semantic and code tests 12 years ago
David Majda f04096189f Jasmine: Convert semantic not code tests 12 years ago
David Majda ccf31f8822 Jasmine: Convert optional matching tests 12 years ago
David Majda 669668fc1b Jasmine: Convert zero or more matching tests 12 years ago
David Majda 1ab06ff906 Jasmine: Convert one or more matching tests 12 years ago
David Majda 03716a562d Jasmine: Convert action code tests 12 years ago
David Majda b06bd774f5 Jasmine: Convert rule reference matching tests 12 years ago
David Majda 14c11b4dfc Jasmine: Convert class matching tests 12 years ago
David Majda 75ab03dc85 Jasmine: Convert any matching tests 12 years ago
David Majda ec48742032 Jasmine: Convert literal matching tests 12 years ago
David Majda feddd10190 Jasmine: Delete test/parser-test.js 12 years ago
David Majda 94205ab639 Jasmine: Convert tests of parser's "grammar" rule 12 years ago
David Majda f746189f2b Jasmine: Convert tests of parser's "initializer" rule 12 years ago
David Majda 171d62fce4 Jasmine: Convert tests of parser's "rule" rule 12 years ago
David Majda e17d4de7ae Jasmine: Convert tests of parser's "expression" rule 12 years ago
David Majda cc22086a09 Jasmine: Convert tests of parser's "choice" rule 12 years ago
David Majda 434abdb272 Jasmine: Convert tests of parser's "sequence" rule 12 years ago
David Majda ec8889f85d Jasmine: Convert tests of parser's "labeled" rule 12 years ago
David Majda bf6d412a4f Jasmine: Convert tests of parser's "prefixed" rule 12 years ago
David Majda 3e083cc51b Jasmine: Convert tests of parser's "suffixed" rule 12 years ago
David Majda 45f825c24f Jasmine: Convert tests of parser's "primary" rule 12 years ago
David Majda 57bbcd71e5 Jasmine: Convert tests of parser's "action" rule 12 years ago
David Majda 35771e15bc Jasmine: Convert tests of parser's "braced" rule 12 years ago
David Majda b1cb214e8b Jasmine: Convert non-tests of parser's character class rules 12 years ago
David Majda 4f5b78b372 Jasmine: Convert tests of parser's "identifier" rule 12 years ago
David Majda a3d93f000f Jasmine: Convert tests of parser's "literal" rule 12 years ago
David Majda 573db92583 Jasmine: Convert tests of parser's "string" rule 12 years ago
David Majda fa65018b15 Jasmine: Convert tests of parser's "doubleQuotedString" rule 12 years ago
David Majda 0e384b31f4 Jasmine: Convert tests of parser's "doubleQuotedCharacter" rule 12 years ago
David Majda 2f5f8d5932 Jasmine: Convert tests of parser's "simpleDoubleQuotedCharacter" rule 12 years ago
David Majda fb01f48c97 Jasmine: Convert tests of parser's "singleQuotedString" rule 12 years ago
David Majda d3b3fe9b78 Jasmine: Convert tests of parser's "singleQuotedCharacter" rule 12 years ago
David Majda 124e45606c Jasmine: Convert tests of parser's "simpleSingleQuotedCharacter" rule 12 years ago
David Majda ba68919b0a Jasmine: Convert tests of parser's "class" rule 12 years ago
David Majda 5fb59b05f2 Jasmine: Convert tests of parser's "classCharacterRange" rule 12 years ago
David Majda d29a753b8d Jasmine: Convert tests of parser's "classCharacter" rule 12 years ago
David Majda b9ae8f9561 Jasmine: Convert tests of parser's "bracketDelimitedCharacter" rule 12 years ago
David Majda da4ac8bb92 Jasmine: Convert tests of parser's "simpleBracketDelimitedCharacter" rule 12 years ago
David Majda 2bb266bbaf Jasmine: Convert tests of parser's "simpleEscapeSequence" rule 12 years ago
David Majda 2619becb9d Jasmine: Convert tests of parser's "zeroEscapeSequence" rule 12 years ago
David Majda 2b43f8ebb8 Jasmine: Convert tests of parser's "hexEscapeSequence" rule 12 years ago
David Majda 0bbca136a2 Jasmine: Convert tests of parser's "unicodeEscapeSequence" rule 12 years ago
David Majda a27dc5ae4a Jasmine: Convert tests of parser's "eolEscapeSequence" rule 12 years ago
David Majda 4f91286013 Jasmine: Convert non-tests of parser's character class rules 12 years ago
David Majda 3bc61c4c50 Jasmine: Convert tests of parser's "__" rule 12 years ago
David Majda fadaef84dd Jasmine: Convert tests of parser's "comment" rule 12 years ago
David Majda b5ccaed491 Jasmine: Convert tests of parser's "singleLineComment" rule 12 years ago
David Majda dac3b0d8d9 Jasmine: Convert tests of parser's "multiLineComment" rule 12 years ago
David Majda 328edf667c Jasmine: Convert tests of parser's "eol" rule 12 years ago
David Majda b4cffee9d4 Jasmine: Convert tests of parser's "eolChar" rule 12 years ago
David Majda a46b9c197b Jasmine: Convert tests of parser's "whitespace" rule 12 years ago
David Majda 53f70b9eb9 Move compiler passes and their tests into a subdirectory 12 years ago
David Majda f046e0a838 Move compiler-related source files and tests into a subdirectory 12 years ago
David Majda ef06621a2b Remove extra comma in compiler tests 12 years ago
David Majda 5b3321d302 Implement |cache| option for |PEG.buildParser|
This option enables/disables the results cache in generated parsers.
Until now, it was always enabled, but after this commit it needs to be
enabled explicitly (i.e. the |cache| option default value is |false|).
The reason is that parsing without it is *much* faster according to the
benchmark.

Note that disabling the cache breaks the linear parsing time guarantee,
meaning that with some grammars you can get exponential parsing time
with respect to the input length. This, together with the possibility of
improving the cache performance in the future, is the reason to keep it
as an option.

Speed impact
------------
Before:     214.08 kB/s
After:      827.52 kB/s
Difference: 286.54%

Size impact
-----------
Before:     1045396 b
After:      949783 b
Difference: -9.15%

(Measured by /tools/impact with Node.js v0.6.6 on x86_64 GNU/Linux.)
12 years ago
David Majda f3970bfa5c Extend QUnit a bit more cleanly 12 years ago
David Majda d35b21e9b2 Simplify the |indent| function in /test/run 12 years ago
David Majda 9d5990f80a Update code formatting in /test/run to match conventions I use elsewhere 12 years ago
David Majda 6d624a89bd Update bundled QUnit to version 1.5.0 12 years ago
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.
12 years ago
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.)
12 years ago
David Majda f47da5c682 Fix a bug in param name fixup code for sequences 12 years ago
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.
12 years ago
David Majda a2af1fe612 Semantic predicates now have access to preceding labels
Part of a fix for GH-69.
12 years ago
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.
12 years ago
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.
12 years ago
David Majda 46b2eaf3e3 Add |expected| and |found| properties to exceptions thrown by parsers
Based on a patch by Marcin Stefaniuk (marcin@stefaniuk.info).
12 years ago
David Majda 21c6d9ccd3 Add |offset| property to exceptions thrown by parsers
Based on a patch by Marcin Stefaniuk (marcin@stefaniuk.info).
12 years ago
David Majda fb5028eb90 Use |util| module instead of |sys|
|sys| emits a warning in Node.js 0.6.x.
12 years ago
David Majda 8a0276ffb7 Unify checks and passes
There is no real reason to have them separated.
13 years ago
David Majda 6cd5bdc5e6 Passes now do not return anything (they always modify the AST in-place) 13 years ago
David Majda 3983f46d5d Rename |reportMissingReferencedRules| check to |reportMissingRules|
The new name is shorter, there is no real loss of meaning.
13 years ago
David Majda 64d26e5db2 Make names of compiler checks and passes verbs 13 years ago
David Majda 8acea01525 Fix reported error position when part of the input is not consumed
Closes GH-48.
13 years ago
David Majda 211a1116e4 Fix stack depth computations for empty sequences
Part of a fix for GH-53.
13 years ago
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.
13 years ago
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.
13 years ago
David Majda 9c3da347cc Fix string parsing tests
The tests were wrong because the |string| rule is not used to parse
literals but rule names.
13 years ago
David Majda 3421bdb813 Test trailing characters for strings and literals at correct places 13 years ago
David Majda c04af99df8 Implament case-insensitive class matching 13 years ago
David Majda b540b2d460 Implement case-insensitive literal matching 13 years ago
David Majda 88c50a3e33 Add tests for zero- and one-char literals
We optimize these cases in the emitter so we should better test them.
13 years ago
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.
13 years ago
David Majda cb2415a4fd Fix output printed during test failures
Expected value was being printed instead of the actual one.

Original patch by Wolfgang Kluge:

  1e875d4479
13 years ago
David Majda 17f62ae9e3 test/parser-test.js: Replace "\0" with "\x00"
Fixes the following JSHint errors:

  ./test/parser-test.js: line 353, col 54, Bad escapement.
  ./test/parser-test.js: line 384, col 54, Bad escapement.
  ./test/parser-test.js: line 436, col 60, Bad escapement.
  ./test/parser-test.js: line 437, col 60, Bad escapement.
  ./test/parser-test.js: line 472, col 50, Bad escapement.
13 years ago