This file documents all notable changes to Peggy.
Released: TBD
- #274 Use commander's new
.conflicts()
to check for mutually-exclusive CLI options, from @hildjj - #274
"*"
is now a validallowedStartRule
, which means all rules are allowed, from @hildjj - #229 new CLI option
-S <rule>
or--start-rule <rule>
to specify the start rule when testing, from @hildjj - #236 Website: show line numbers in parser input textarea, from @Mingun
- #280 new output type
source-with-inline-map
, which generates source text with an inline map, from @hildjj - #285 Require that a non-empty string be given as a grammarSource if you are generating a source map, from @hildjj
- #206: New output type
ast
and an--ast
flag for the CLI to get an internal grammar AST for investigation (can be useful for plugin writers), from @Mingun - #294 Website: show errors in the editors, from @Mingun
- #299 Add example grammar for a SemVer.org semantic version string, from @dselman
- #308 Add support for reading test data from stdin using
-T -
, from @hildjj.
- #283 Fix incorrect type information for DiagnosticCallback, from @hildjj
- #287 Allow large outputs to be received without blocking on the CLI tests, from @hildjj
Released: 2022-01-01
- None
- #261: Remove documentation from
README.md, instead linking to the HTML documentation. HTML documentation on
https://peggyjs.org is now served from the
docs
branch, so that it won't update as we change themain
branch.main
must be merged ontodocs
as a part of the release process going forward. - #266: Expose the private
field
problems
in theSession
class, from @hildjj.
- #263: Broken link to unpkg. This bug was a symptom of a relatively bad issue in the 2.0.0 release, where the web version of peggy was put in the wrong place, and therefore not tested in the release process. From @hildjj.
Released: 2022-05-28
- #163: Add support for generating source maps, from @Mingun
- #160: Introduce an API for reporting errors, warnings and information messages from passes. New API allows reporting several diagnostics at once with intermediate results checking after each compilation stage, from @Mingun
- #218: Add a
sourceMappingURL
to the generated code, from @hildjj - #248: Remove support for Node.js version 10. When updating dependencies, too many of the tools we use no longer work on the Node 10, which went out of security maintenance more than a year ago. Added support for Node.js version 18, from @hildjj
- #251: Make
commander
andsource-map-generator
full dependencies. These are not needed for the pre-packaged web build, but will be used by Node or people that are doing their own packaging for the web, from @hildjj
- #167: New CLI, from @hildjj
- Backward compatible with the previous
- New -t/--test and -T/--testfile flags to directly test the generated grammar
- #169: Expose string escape
functions,
stringEscape()
andregexpClassEscape()
, from @hildjj - #175: Check allowedStartRules for validity, from @hildjj
- #185: Updated eslint rules, from @hildjj
- #196: Add example grammars for XML and source-mapping, from @hildjj
- #204: Increase coverage for the tests, from @Mingun
- #210: Refactor CLI testing, from @hildjj
- #164: Fix some errors in the typescript definitions, from @Mingun
- #170: Add missing argument in function call, from @darlanalves
- #182: Fix typo in documentation, from @zargold
- #197: Fix a regression of redundant commas in the character classes in the error messages, introduced in fad4ab74d1de67ef1902cd22d479c81ccab73224, from @Mingun
- #198: Make all build scripts run on Windows, from @hildjj
- #199: Test web version locally, using puppeteer, from @hildjj
- #211:Command-line -t requires from wrong directory, from @hildjj
- #212: Parse errors with zero length give badly-formatted errors, from @hildjj
- #214: Failing tests don't format errors
- #216: Fix typescript definition of SyntaxError, from @cmfcmf
- #220: Fix rollup warnings, from @hildjj
- #285: Work around source-map bug by throwing an exception if no grammarSource is given when generating source maps, from @hildjj.
Released: 2021-06-02
-
Infrastructural rebake @StoneCypher
- Builds with
typescript
, removesbabel
- Bundles with
rollup
, removesbrowserify
- Tests with
jest
, removesmocha
- Minifies with
terser
, removesuglify
- Adds
rimraf
for portable pre-build cleanup - Extends CI testing to
windows
,macintosh
- Increases node testing range to include
node 16
- Builds with
-
Option to select optimization mode removed as it had no significant effect on the majority of generated parsers and as such represented only academic interest. You should use minifiers to get smaller parsers. Option
optimize
is deleted from thegenerate()
options, flag--optimize
is deleted from the CLI (you still can supply it, but the CLI will issue a warning that the option is removed). @Mingun -
location()
s now will have additionalsource
property which value is taken from theoptions.grammarSource
property. That property can contain arbitrary data, for example, path to the currently parsed file. @Mingun -
Made usage of
GrammarError
andpeg$SyntaxError
more consistent. Use theformat
method to get pretty string outputs. Updated thepeggy
binary to make pretty errors. Slight breaking change: the format of a few error messages have changed; use thetoString()
method onGrammarError
to get something close to the old text. @hildjj -
The code generator was slightly reworked to simplify reusing the bytecode generator (
generate.generateBytecode
pass). Propertyconsts
on thegrammar
AST node, has been creating by the pass in the past, was decoupled into 4 other properties with the structured information:literals
classes
expectations
functions
-
Added missing type definitions to the
peg.d.ts
file. Added definitions for thecompiler
andvisitor
modules, AST, andplugins
option in thegenerate()
function. @MingunNow bytecode generation pass is independent from the JavaScript backend. @Mingun
-
Some opcodes from
compiler/opcode.js
were deprecated. Although you shouldn't use them directly because they are not considered as a public API, some plugins use them. For that reason backward compatibility is preserved:- Opcode
MATCH_REGEXP
is deprecated and replaced byMATCH_CHAR_CLASS
with the same value. - Added new opcode
PUSH_EMPTY_STRING
that puts a new empty string on the stack. - Opcode
PUSH
is deprecated because it was used only for pushing empty string constants and they now pushed withPUSH_EMPTY_STRING
.
Instead of relying on the library opcodes it is better to have a copy of them, especially if your plugin replaces both the
generateBytecode
and thegenerateJs
passes. @Mingun - Opcode
-
Default visitor functions, returned by the
visitor.build()
, that just forward call tonode.expression
, now return the result of underlyingvisit
call. @MingunAffected functions:
rule
named
action
labeled
text
simple_and
simple_not
optional
zero_or_more
one_or_more
group
-
Parsers now can use two new functions to get location information:
offset()
andrange()
. Use them if you don't need the whole location information, because it is expensive to compute. These two new functions are always very efficient (back-ported pegjs/pegjs#528). @felix9 and @Mingun -
Add a new option
config.reservedWords: string[]
, avalible for plugins in theiruse()
method. Using this option, a plugin can change the list of words that cannot be used.By default this new option contains an array with reserved JavaScript words @Mingun
-
Several optimizations in the generator. Generated parsers should now be faster and smaller @Mingun
- #112:
"group"
node in the AST now havelocation
information (back-ported) - #143:
peg.d.ts
had some errors in the type descriptions, which were fixed
Released: 2021-04-22
- Added global initializer blocks, which contain code that is only run once
when the grammar is loaded, rather than once every time the parser runs.
Global initializers are surrounded by
{{
and}}
, and must come before the per-parser initializer, which is surrounded by{
and}
. @jaubourg - Back-ported value plucking with
@
from pegjs head. If your rule has a simple action that returns one or more of the values matched by the rule, you can instead mark those expressions with@
and not need an action. This works inside of parens as well. @hildjj
- #10: Better docs for parser options
- #40: Turn on eslint prefer-const
- #58: Release script didn't push tag correctly
- #61: Replace download link with new one in doc (partial fix)
- #71: Readme doesn't include "es" format
- #72: Generated code has wrong version number
Released: 2021-04-16
First release
See previous project for PEG.js changes