Commit graph

397 commits

Author SHA1 Message Date
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
David Majda 131b6dd01f Refactor "sequence" emitter function a bit 2011-09-24 17:09:53 +02:00
David Majda f29ff236b8 Refactor "simple_and" emitter function a bit 2011-09-24 17:09:52 +02:00
David Majda 506d8107a1 Refactor "simple_not" emitter function a bit 2011-09-24 17:09:52 +02:00
David Majda 13ae52b2bf Refactor "semantic_and" emitter function a bit 2011-09-24 17:09:52 +02:00
David Majda 9111020ca2 Refactor "semantic_not" emitter function a bit 2011-09-24 17:09:52 +02:00
David Majda cc3bd4f310 Refactor "zero_or_more" emitter function a bit 2011-09-24 17:09:52 +02:00
David Majda 85c1b010b6 Refactor "one_or_more" emitter function a bit 2011-09-24 17:09:52 +02:00
David Majda b5ca96dd48 Refactor "action" emitter function a bit 2011-09-24 17:09:52 +02:00
David Majda 50a0371e2d Refactor "rule_ref" emitter function a bit 2011-09-24 17:09:52 +02:00
David Majda eaba6b8a9d Refactor "literal" emitter function a bit 2011-09-24 17:09:52 +02:00
David Majda 2120c908c7 Refactor "class" emitter function a bit 2011-09-24 17:09:52 +02:00
David Majda 0748fee1d3 Use Codie for code templates
This will allow moving some code into the templates later.
2011-09-24 17:09:45 +02:00
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.
2011-09-23 14:08:08 +02:00
David Majda 45c99f8f6b Generate more efficient code for empty literals
Original patch by Wolfgang Kluge:

  797173f676
2011-09-18 20:12:26 +02:00
David Majda 4de3cc1716 Fix comment typos
Original patch by Wolfgang Kluge:

  07e0cfcc02
2011-09-18 20:06:52 +02:00
David Majda eceda8b5e8 Use correct disjunction operator in |computeErrorPosition|
Original patch by Wolfgang Kluge:

  6b793b33df
2011-09-18 18:08:58 +02:00
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
2011-09-18 18:05:10 +02:00
David Majda 50be1081e0 Sort JSHint options alphabetically 2011-09-18 16:55:27 +02:00
David Majda ce40a8e815 benchmark/index.js: Use radix in |parseInt| call
Fixes the following JSHint error:

  ./benchmark/index.js: line 59, col 18, Missing radix parameter.
2011-09-18 16:25:47 +02:00
David Majda c8c5187768 Make "jake hint" check benchmark/index.js 2011-09-18 16:25:47 +02:00
David Majda 11a44948ab Extract JavaScript and CSS from benchmark/index.html into separate files
JavaScript is extracted to make it JSHintable, CSS is just for symmetry.
2011-09-18 16:25:47 +02:00
David Majda 8841c31d1b benchamrk/runner.js: Add "()" to constructor invocations
Fixes the following JSHint errors:

  ./benchmark/runner.js: line 73, col 28, Missing '()' invoking a constructor.
  ./benchmark/runner.js: line 75, col 33, Missing '()' invoking a constructor.
2011-09-18 16:25:47 +02:00
David Majda cad3013966 benchmark/runner.js: Add missing semicolon
Fixes the following JSHint error:

  ./benchmark/runner.js: line 21, col 42, Missing semicolon.
2011-09-18 16:25:47 +02:00
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.
2011-09-18 16:25:47 +02:00
David Majda 934bfa5eef test/parser-test.js: Fix missing/unnecessary semicolons
Fixes the following JSHint errors:

  ./test/parser-test.js: line 49, col 4, Missing semicolon.
  ./test/parser-test.js: line 58, col 4, Missing semicolon.
  ./test/parser-test.js: line 77, col 2, Unnecessary semicolon.
  ./test/parser-test.js: line 137, col 23, Missing semicolon.
2011-09-18 16:25:47 +02:00
David Majda d84f38c64b test/parser-test.js: Fix comments that look like nested to JSHint
Fixes the following JSHint errors:

  ./test/parser-test.js: line 521, col 29, Nested comment.
  ./test/parser-test.js: line 521, col 29, Stopping, unable to continue. (87% scanned).
2011-09-18 16:25:47 +02:00
David Majda 34d19a7dc6 test/passes-test.js: Add missing semicolons
Fixes the following JSHint errors:

  ./test/passes-test.js: line 12, col 6, Missing semicolon.
  ./test/passes-test.js: line 25, col 4, Missing semicolon.
  ./test/passes-test.js: line 229, col 41, Missing semicolon.
2011-09-18 16:25:47 +02:00
David Majda 0fe5769024 test/checks-test.js: Avoid function definitions in loops
Fixes the following JSHint errors:

  ./test/checks-test.js: line 26, col 8, Don't make functions within a loop.
  ./test/checks-test.js: line 31, col 5, Don't make functions within a loop.
  ./test/checks-test.js: line 59, col 8, Don't make functions within a loop.
  ./test/checks-test.js: line 64, col 5, Don't make functions within a loop.
2011-09-18 16:25:47 +02:00
David Majda 96192417d8 test/compiler-test.js: Remove extra comma
Fixes the following JSHint error:

  ./test/compiler-test.js: line 498, col 49, Extra comma.
2011-09-18 16:25:47 +02:00
David Majda e93eaa0e0e test/compiler-test.js: Add missing semicolon
Fixes the following JSHint error:

  ./test/compiler-test.js: line 420, col 47, Missing semicolon.
2011-09-18 16:25:47 +02:00
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.
2011-09-18 16:25:46 +02:00
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.
2011-09-18 16:25:46 +02:00
David Majda a52522c7c6 src/emitter.js: Remove unnecessary semicolon
Fixes the following JSHint error:

  ./src/emitter.js: line 77, col 4, Unnecessary semicolon.
2011-09-18 16:25:46 +02:00
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 '!='.
2011-09-18 16:25:46 +02:00
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.
2011-09-18 16:25:46 +02:00
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: [
2011-09-18 16:25:46 +02:00
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.
2011-09-18 16:25:46 +02:00
David Majda 13c47d6c4f src/parser.pegjs: Replace "\0" with "\x00"
Fixes the following JSHint error:

  ./src/parser.js: line 2820, col 44, Bad escapement.
2011-09-18 16:25:46 +02:00
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 '!='.
2011-09-18 16:25:46 +02:00