PEG.js v0.8.0 Release Notes

Release Date: 2013-12-24 // over 8 years ago
  • Big Changes

    • ⚑️ Completely rewrote the code generator. Among other things, it allows optimizing generated parsers for parsing speed or code size using the optimize option of the PEG.buildParser method or the --optimize/-o option on the command-line. All internal identifiers in generated code now also have a peg$ prefix to discourage their use and avoid conflicts. [#35, #92]
    • Completely redesigned error handling. Instead of returning null inside actions to indicate match failure, new expected and error functions can be called to trigger an error. Also, expectation inside the SyntaxError exceptions are now structured to allow easier machine processing. [#198]
    • πŸ— Implemented a plugin API. The list of plugins to use can be specified using the plugins option of the PEG.buildParser method or the --plugin option on the command-line. Also implemented the --extra-options and --extra-options-file command-line options, which are mainly useful to pass additional options to plugins. [#106]
    • πŸ— Made offset, line and column functions, not variables. They are now available in all parsers and return lazily-computed position data. Removed now useless trackLineAndColumn option of the PEG.buildParser method and the --track-line-and-column option on the command-line.
    • βž• Added a new text function. When called inside an action, it returns the text matched by action's expression. [#131]
    • βž• Added a new $ operator. It extracts matched strings from expressions.
    • The ? operator now returns null on unsuccessful match.
    • Predicates now always return undefined.
    • πŸ“œ Replaced the startRule parameter of the parse method in generated parsers with more generic options parameter. The start rule can now be specified as the startRule option. The options parameter can be also used to pass custom options to the parser because it is visible as the options variable inside parser code. [#37]
    • πŸ— The list of allowed start rules of a generated parser now has to be specified explicitly using the allowedStartRules option of the PEG.buildParser method or the --allowed-start-rule option on the command-line. This will make certain optimizations like rule inlining easier in the future.
    • βœ‚ Removed the toSource method of generated parsers and introduced a new output option of the PEG.buildParser method. It allows callers to specify whether they want to get back the parser object or its source code.
    • πŸ“¦ The source code is now a valid npm package. This makes using development
      πŸ”– versions easier. [#32]
    • ⚑️ Generated parsers are now ~25% faster and ~62%/~3% smaller (when optimized for size/speed) than those generated by 0.7.0.
    • Requires Node.js 0.8.0+.

    Small Changes

    • πŸ“œ bin/pegjs now outputs just the parser source if the value of the --export-var option is empty. This makes embedding generated parsers into other files easier. [#143]
    • πŸ”„ Changed the value of the name property of PEG.GrammarError instances from β€œPEG.GrammarError” to just β€œGrammarError”. This better reflects the fact that PEG.js can get required with different variable name than PEG.
    • Setup prototype chain for PEG.GrammarError correctly.
    • πŸ“œ Setup prototype chain for SyntaxError in generated parsers correctly.
    • πŸ›  Fixed error messages in certain cases with trailing input [#119]
    • πŸ›  Fixed code generated for classes starting with \^. [#125]
    • πŸ›  Fixed too eager proxy rules removal. [#137]
    • βž• Added a license to all vendored libraries. [#207]
    • βœ… Converted the test suite from QUnit to Jasmine, cleaning it up on the way.
    • πŸ‘· Travis CI integration.
    • πŸ›  Various internal code improvements and fixes.
    • πŸ›  Various generated code improvements and fixes.
    • πŸ›  Various example grammar improvements and fixes.
    • πŸ‘Œ Improved
    • Converted CHANGELOG to Markdown.