Minor features and optimizations
Minor Changes
-
Infrastructural rebake @StoneCypher
- Builds with
typescript, removesbabel - Bundles with
rollup, removesbrowserify - Tests with
jest, removesmocha - Minifies with
terser, removesuglify - Adds
rimraffor 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. Optionoptimizeis deleted from thegenerate()
options, flag--optimizeis 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 additionalsourceproperty which value is taken
from theoptions.grammarSourceproperty. That property can contain arbitrary
data, for example, path to the currently parsed file.
@Mingun -
Made usage of
GrammarErrorandpeg$SyntaxErrormore consistent. Use the
formatmethod to get pretty string outputs. Updated thepeggybinary to
make pretty errors. Slight breaking change: the format of a few error
messages have changed; use thetoString()method onGrammarErrorto get
something close to the old text.
@hildjj -
The code generator was slightly reworked to simplify reusing the bytecode generator
(generate.generateBytecodepass). Propertyconstson thegrammarAST node,
has been creating by the pass in the past, was decoupled into 4 other properties
with the structured information:literalsclassesexpectationsfunctions
-
Added missing type definitions to the
peg.d.tsfile. Added definitions for the
compilerandvisitormodules, AST, andpluginsoption in thegenerate()function.
@MingunNow bytecode generation pass is independent from the JavaScript backend.
@Mingun -
Some opcodes from
compiler/opcode.jswere 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_REGEXPis deprecated and replaced byMATCH_CHAR_CLASSwith the same value. - Added new opcode
PUSH_EMPTY_STRINGthat puts a new empty string on the stack. - Opcode
PUSHis 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 thegenerateBytecodeand
thegenerateJspasses. @Mingun - Opcode
-
Default visitor functions, returned by the
visitor.build(), that just forward
call tonode.expression, now return the result of underlyingvisitcall.
@MingunAffected functions:
rulenamedactionlabeledtextsimple_andsimple_notoptionalzero_or_moreone_or_moregroup
-
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 their
use()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