Commit graph

11 commits

Author SHA1 Message Date
Arlo Breault 12c169e7b5 Convert PEG.js code to strict mode
* Issues #323
2015-06-12 17:34:59 -07:00
David Majda 898a7b5a2d Simplify visitors by providing default visit functions
The |visitor.build| function now supplies default visit functions for
visitors it builds. These functions don't do anything beside traversing
the tree and passing arguments around to child visit functions.

Having the default visit functions allowed to simplify several visitors.
2014-06-04 07:41:00 +02:00
David Majda 85c8f386c1 Formatting 2014-05-09 13:40:50 +02:00
David Majda c1e1502d43 Utility functions cleanup: Cleanup lib/compiler/visitor.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 d3d4ace153 Move options handling from passes to |PEG.compiler.compile|
This eliminates some duplicate code.
2013-01-06 10:32:52 +01:00
David Majda 5942988f66 Remove the |startRule| property from the AST
It's redundant.
2013-01-06 10:21:48 +01:00
David Majda 3981433984 Fix too eager proxy rules removal
Fixes GH-137.
2013-01-06 10:17:10 +01: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/remove-proxy-rules.js (Browse further)