90 Commits (21c6d9ccd387517ebc12e0cd8a52945a0e0e2800)

Author SHA1 Message Date
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 791c495aec Update embedded Codie to version 1.0.1 12 years ago
David Majda 47969a2f61 Replace |for| loop iterating over sequence elements with |each| 13 years ago
David Majda a19ea83ffa Replace |for| loop iterating over compiler passes with |each| 13 years ago
David Majda cd5490dee4 Make pass list customizable via |PEG.compiler.appliedPassNames| property 13 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 2a82d863e5 Regenerate src/parser.js (forgot to do it in previous commit) 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 c639c1fc83 PEG.js grammar: Replace two instances of |string / ""| by |string?| 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 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 da12c2f5d4 Compile Codie templates only once 13 years ago
David Majda a5af9611a2 Introduce |context.delta| function to make creating contexts more DRY 13 years ago
David Majda be3b87ec71 Refactor "grammar" emitter function a bit 13 years ago
David Majda 2b09a7116d Refactor "rule" emitter function a bit 13 years ago
David Majda 131b6dd01f Refactor "sequence" emitter function a bit 13 years ago
David Majda f29ff236b8 Refactor "simple_and" emitter function a bit 13 years ago
David Majda 506d8107a1 Refactor "simple_not" emitter function a bit 13 years ago
David Majda 13ae52b2bf Refactor "semantic_and" emitter function a bit 13 years ago
David Majda 9111020ca2 Refactor "semantic_not" emitter function a bit 13 years ago
David Majda cc3bd4f310 Refactor "zero_or_more" emitter function a bit 13 years ago
David Majda 85c1b010b6 Refactor "one_or_more" emitter function a bit 13 years ago
David Majda b5ca96dd48 Refactor "action" emitter function a bit 13 years ago
David Majda 50a0371e2d Refactor "rule_ref" emitter function a bit 13 years ago
David Majda eaba6b8a9d Refactor "literal" emitter function a bit 13 years ago
David Majda 2120c908c7 Refactor "class" emitter function a bit 13 years ago
David Majda 0748fee1d3 Use Codie for code templates
This will allow moving some code into the templates later.
13 years ago
David Majda 38c25efde0 Use single quotes for code in the emitter
Strings with code should use single quotes so that double quotes (which
I generally prefer) could be used in the code itself without escaping.
13 years ago
David Majda 45c99f8f6b Generate more efficient code for empty literals
Original patch by Wolfgang Kluge:

  797173f676
13 years ago
David Majda 4de3cc1716 Fix comment typos
Original patch by Wolfgang Kluge:

  07e0cfcc02
13 years ago
David Majda eceda8b5e8 Use correct disjunction operator in |computeErrorPosition|
Original patch by Wolfgang Kluge:

  6b793b33df
13 years ago
David Majda cc4910d9b9 src/compiler.js: Fix variable redefinition
Fixes the following JSHint error:

  ./src/compiler.js: line 23, col 16, 'i' is already defined.
13 years ago
David Majda bc4821581c src/emitter.js: Fix variable redefinitions
Fixes the following JSHint errors:

  ./src/emitter.js: line 95, col 21, 'name' is already defined.
  ./src/emitter.js: line 361, col 35, 'setReportFailuresCode' is already defined.
  ./src/emitter.js: line 362, col 39, 'restoreReportFailuresCode' is already defined.
  ./src/emitter.js: line 363, col 31, 'reportFailureCode' is already defined.
  ./src/emitter.js: line 393, col 38, 'setReportFailuresCode' used out of scope.Fixes the following JSHint errors:
  ./src/emitter.js: line 394, col 38, 'restoreReportFailuresCode' used out of scope.
  ./src/emitter.js: line 395, col 38, 'reportFailureCode' used out of scope.
  ./src/emitter.js: line 666, col 26, 'formalParams' is already defined.
  ./src/emitter.js: line 667, col 26, 'actualParams' is already defined.
  ./src/emitter.js: line 669, col 26, 'formalParams' is already defined.
  ./src/emitter.js: line 670, col 26, 'actualParams' is already defined.
  ./src/emitter.js: line 685, col 27, 'formalParams' used out of scope.
  ./src/emitter.js: line 686, col 27, 'actualParams' used out of scope.
  ./src/emitter.js: line 770, col 20, 'regexp' is already defined.
  ./src/emitter.js: line 784, col 22, 'regexp' used out of scope.
13 years ago
David Majda a52522c7c6 src/emitter.js: Remove unnecessary semicolon
Fixes the following JSHint error:

  ./src/emitter.js: line 77, col 4, Unnecessary semicolon.
13 years ago
David Majda d1b83e4ab3 src/emitter.js: Use strict comparison
Fixes the following JSHint error:

  ./src/emitter.js: line 44, col 48, Expected '!==' and instead saw '!='.
13 years ago
David Majda f893d47b98 src/utils.js: Make |quoteForRegexpClass| escape control characters
Fixes the following JSHint errors:

  ./src/parser.js: line 3614, col 16, Mixed spaces and tabs.
  ./src/parser.js: line 3614, col 20, Unsafe character.
13 years ago
David Majda ab49197ef1 src/utils.js: Make |quote| escape control characters
Also change |quote| in src/emitter.js so both are in sync.

Fixes the following JSHint errors:

  ./src/parser.js: line 3613, col 27, Mixed spaces and tabs.
  ./src/parser.js: line 3613, col 31, Unsafe character.
  ./src/parser.js: line 3613, col 38, Control character in string: [     .
  ./src/parser.js: line 3613, col 40, Control character in string: [
13 years ago
David Majda 67afc788ad src/parser.pegjs: Use radix in |parseInt| calls instead of "0x" prefix
Fixes the following JSHint errors:

  ./src/parser.js: line 2878, col 44, Missing radix parameter.
  ./src/parser.js: line 2949, col 44, Missing radix parameter.
13 years ago
David Majda 13c47d6c4f src/parser.pegjs: Replace "\0" with "\x00"
Fixes the following JSHint error:

  ./src/parser.js: line 2820, col 44, Bad escapement.
13 years ago
David Majda b80cd9cb02 src/parser.pegjs: Use strict comparison
Fixes the following JSHint errors:

  ./src/parser.js: line 460, col 50, Expected '!==' and instead saw '!='.
  ./src/parser.js: line 486, col 42, Expected '!==' and instead saw '!='.
13 years ago
David Majda cc416199be src/parser.pegjs: Add missing semicolons
Fixes the following JSHint errors:

  ./src/parser.js: line 193, col 18, Missing semicolon.
  ./src/parser.js: line 407, col 20, Missing semicolon.
  ./src/parser.js: line 2493, col 18, Missing semicolon.
  ./src/parser.js: line 2759, col 40, Missing semicolon.
13 years ago
David Majda 559db3a812 src/emitter.js: Sync |escape| in generated parsers with utils.js
Fixes the following JSHint errors:

  ./src/parser.js: line 102, col 26, 'escapeChar' is already defined.
  ./src/parser.js: line 103, col 22, 'length' is already defined.
  ./src/parser.js: line 106, col 23, 'escapeChar' used out of scope.
  ./src/parser.js: line 106, col 86, 'length' used out of scope.
13 years ago
David Majda e0ef7e1abb src/passes.js: Add missing semicolon
Fixes the following JSHint error:

  ./src/passes.js: line 98, col 8, Missing semicolon.
13 years ago