Commit graph

8 commits

Author SHA1 Message Date
David Majda c1e1502d43 Utility functions cleanup: Cleanup lib/compiler/visitor.js 2014-05-08 20:28:32 +02:00
David Majda bfaad70899 Utility functions cleanup: Cleanup lib/compiler/asts.js 2014-05-08 20:28:32 +02:00
David Majda 5adad3ae12 Utility functions cleanup: Split lib/utils.js
Split lib/utils.js into multiple files. Some of the functions were
generic, these were moved into files in lib/utils. Other funtions were
specific for the compiler, these were moved to files in lib/compiler.

This commit only moves functions around -- there is no renaming and
cleanup performed. Both will come later.
2014-05-08 20:28:31 +02:00
David Majda ff8e877fce Change module exporting style
Modules now generally store the exported object in a named variable or
function first and only assign |module.exports| at the very end. This is
a difference when compared to style used until now, where most modules
started with a |module.exports| assignment.

I think the explicit name helps readability and understandability.
2014-05-04 14:11:44 +02:00
David Majda 549d052710 Make |GrammarError| require work also in the browser version
Fixes a bug from ac179cda7b (a fix for
GH-135).
2013-01-05 21:16:36 +01:00
Justin Blank ac179cda7b Fix ReferenceError in compiler passes.
Previously, the report-left-recursion and report-missing-rules passes
used PEG.GrammarError without requiring it, causing a ReferenceError.

Since requiring lib/peg.js would cause circular requirements, this
commit imports lib/grammar-error.js as GrammarError.

The bug was introduced in commit
4cda79951a.

Fixes GH-135.
2012-12-14 12:55:30 -05:00
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).
2012-12-02 17:05:13 +01:00
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.
2012-11-10 14:21:14 +01:00
Renamed from src/compiler/passes/report-missing-rules.js (Browse further)