Snyk has created this PR to upgrade pegjs from 0.6.2 to 0.10.0.
:information_source: Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
The recommended version is 4 versions ahead of your current version.
The recommended version was released 5 years ago, on 2016-08-19.
Parsers can be generated in multiple module formats. The available
formats are: CommonJS (the default), AMD, UMD, globals, and bare (not
available from the command-line).
The format can be specified using the format option of the peg.generate
function or the --format option on the command-line.
It is also possible to specify parser dependencies using the dependencies
option of the peg.generate function or the --dependency/-d option on
the command-line. This is mainly useful for the UMD format, where the
dependencies are translated into both AMD dependencies and CommonJS require calls.
Browser version of PEG.js is now in the UMD format. This means it will try
to detect AMD or Node.js/CommonJS module loader and define itself as a
module. If no loader is found, it will export itself using a global
variable.
API polishing. The peg.buildParser function was renamed to peg.generate. The global variable the browser version of PEG.js is
available in when no loader is detected was renamed from PEG to peg.
CLI improvements. There is new --output/-o command-line option which
allows to specify the output file. The old way of specifying the output file
using a second argument was removed. To make room for the new -o option
the old one (a shortcut for --optimize) was renamed to -O. All these
changes make PEG.js conform to traditional compiler command-line interface.
It is now also possible to use - as a file name on the command-line (with
the usual meaning of standard input/output).
Improved error messages. Both messages produced by PEG.js and generated
parsers were improved.
Duplicate rule definitions are reported as errors.
Duplicate labels are reported as errors.
Minor Changes
Exposed the AST node visitor builder as peg.compiler.visitor. This is
useful mainly for plugins which manipulate the AST.
Exposed the function which builds messages of exceptions produced by
generated parsers as SyntaxError.buildMessage. This is useful mainly for
customizing these error messages.
The error and expected functions now accept an optional location
parameter. This allows to customize the location in which the resulting
syntax error is reported.
Refactored expectations reported in the expected property of exceptions
produced by generated parsers. They are no longer de-duplicated and sorted,
their format changed to be more machine-readable, and they no longer contain
human-readable descriptions.
The found property of exceptions produced by the error function is now
set to null.
Removed access to the parser object in parser code via the parser
variable.
Made handling of optional parameters consistent with ES 2015. Specifically,
passing undefined as a parameter value is now equivalent to not passing
the parameter at all.
Renamed several compiler passes.
Generated parsers no longer consider \r, \u2028, and \u2029 as
newlines (only \n and \r\n).
Simplified the arithmetics example grammar.
Switched from first/rest to head/tail in PEG.js grammar and example
grammars.
Started using ESLint instead of JSHint and fixed various problems it found.
Tracing support. Parsers can be compiled with support for tracing their
progress, which can help debugging complex grammars. This feature is
experimental and is expected to evolve over time as experience is gained. More details
Infinite loop detection. Grammar constructs that could cause infinite
loops in generated parsers are detected during compilation and cause errors.
Improved location information API. The line, column, and offset
functions available in parser code were replaced by a single location
function which returns an object describing the current location. Similarly,
the line, column, and offset properties of exceptions were replaced by
a single location property. The location is no longer a single point but a
character range, which is meaningful mainly in actions where the range
covers action’s expression. More details
Improved error reporting. All exceptions thrown when generating a parser
have associated location information. And all exceptions thrown by generated
parser and PEG.js itself have a stack trace (the stack property) in
environments that support Error.captureStackTrace.
Strict mode code. All PEG.js and generated parser code is written using JavaScript strict mode.
Minor Changes
Labels behave like block-scoped variables. This means parser code can see
labels defined outside expressions containing code.
Empty sequences are no longer allowed.
Label names can’t be JavaScript reserved words.
Rule and label names can contain Unicode characters like in JavaScript.
Rules have to be separated either by ; or a newline (until now, any
whitespace was enough).
The PEG.js grammar and all the example grammars were completely rewritten.
This rewrite included a number of cleanups, formatting changes, naming
changes, and bug fixes.
The parser object can now be accessed as parser in parser code.
Location information computation is faster.
Added support for Node.js >= 0.10.x, io.js, and Edge. Removed support for
Node.js < 0.10.x.
Bug Fixes
Fixed left recursion detector which missed many cases.
Fixed escaping of U+0100—U+107F and U+1000—U+107F in generated code and
error messages.
Renamed parse and SyntaxError to peg$parse and peg$SyntaxError to
mark them as internal identifiers.
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]
Snyk has created this PR to upgrade pegjs from 0.6.2 to 0.10.0.
Release notes
Package name: pegjs
Major Changes
Parsers can be generated in multiple module formats. The available
formats are: CommonJS (the default), AMD, UMD, globals, and bare (not
available from the command-line).
The format can be specified using the
format
option of thepeg.generate
function or the
--format
option on the command-line.It is also possible to specify parser dependencies using the
dependencies
option of the
peg.generate
function or the--dependency
/-d
option onthe command-line. This is mainly useful for the UMD format, where the
dependencies are translated into both AMD dependencies and CommonJS
require
calls.Browser version of PEG.js is now in the UMD format. This means it will try
to detect AMD or Node.js/CommonJS module loader and define itself as a
module. If no loader is found, it will export itself using a global
variable.
API polishing. The
peg.buildParser
function was renamed topeg.generate
. The global variable the browser version of PEG.js isavailable in when no loader is detected was renamed from
PEG
topeg
.CLI improvements. There is new
--output
/-o
command-line option whichallows to specify the output file. The old way of specifying the output file
using a second argument was removed. To make room for the new
-o
optionthe old one (a shortcut for
--optimize
) was renamed to-O
. All thesechanges make PEG.js conform to traditional compiler command-line interface.
It is now also possible to use
-
as a file name on the command-line (withthe usual meaning of standard input/output).
Improved error messages. Both messages produced by PEG.js and generated
parsers were improved.
Duplicate rule definitions are reported as errors.
Duplicate labels are reported as errors.
Minor Changes
peg.compiler.visitor
. This isuseful mainly for plugins which manipulate the AST.
generated parsers as
SyntaxError.buildMessage
. This is useful mainly forcustomizing these error messages.
error
andexpected
functions now accept an optionallocation
parameter. This allows to customize the location in which the resulting
syntax error is reported.
expected
property of exceptionsproduced by generated parsers. They are no longer de-duplicated and sorted,
their format changed to be more machine-readable, and they no longer contain
human-readable descriptions.
found
property of exceptions produced by theerror
function is nowset to
null
.parser
variable.
passing
undefined
as a parameter value is now equivalent to not passingthe parameter at all.
\r
,\u2028
, and\u2029
asnewlines (only
\n
and\r\n
).first
/rest
tohead
/tail
in PEG.js grammar and examplegrammars.
guidelines.
Bug Fixes
bin/pegjs
so that invoking it with one non-option argument which isan extension-less file doesn’t cause that file to be overwritten.
(a:"a")
or(a:"a" b:"b" c:"c")
aren’t visible from the outside.(U+007F).
points above U+10FF in strings.
tools/impact
on OS X.Complete set of changes
Major Changes
progress, which can help debugging complex grammars. This feature is
experimental and is expected to evolve over time as experience is gained.
More details
loops in generated parsers are detected during compilation and cause errors.
line
,column
, andoffset
functions available in parser code were replaced by a single
location
function which returns an object describing the current location. Similarly,
the
line
,column
, andoffset
properties of exceptions were replaced bya single
location
property. The location is no longer a single point but acharacter range, which is meaningful mainly in actions where the range
covers action’s expression.
More details
have associated location information. And all exceptions thrown by generated
parser and PEG.js itself have a stack trace (the
stack
property) inenvironments that support
Error.captureStackTrace
.JavaScript strict mode.
Minor Changes
labels defined outside expressions containing code.
;
or a newline (until now, anywhitespace was enough).
This rewrite included a number of cleanups, formatting changes, naming
changes, and bug fixes.
parser
in parser code.Node.js < 0.10.x.
Bug Fixes
error messages.
parse
andSyntaxError
topeg$parse
andpeg$SyntaxError
tomark them as internal identifiers.
Complete set of changes
Big Changes
optimize
option of thePEG.buildParser
method or the--optimize
/-o
option on the command-line. All internal identifiers in generated code now also have apeg$
prefix to discourage their use and avoid conflicts. [#35, #92]null
inside actions to indicate match failure, newexpected
anderror
functions can be called to trigger an error. Also, expectation inside theSyntaxError
exceptions are now structured to allow easier machine processing. [#198]plugins
option of thePEG.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]offset
,line
andcolumn
functions, not variables. They are now available in all parsers and return lazily-computed position data. Removed now uselesstrackLineAndColumn
option of thePEG.buildParser
method and the--track-line-and-column
option on the command-line.text
function. When called inside an action, it returns the text matched by action's expression. [#131]$
operator. It extracts matched strings from expressions.?
operator now returnsnull
on unsuccessful match.undefined
.startRule
parameter of theparse
method in generated parsers with more genericoptions
parameter. The start rule can now be specified as thestartRule
option. Theoptions
parameter can be also used to pass custom options to the parser because it is visible as theoptions
variable inside parser code. [#37]allowedStartRules
option of thePEG.buildParser
method or the--allowed-start-rule
option on the command-line. This will make certain optimizations like rule inlining easier in the future.toSource
method of generated parsers and introduced a newoutput
option of thePEG.buildParser
method. It allows callers to specify whether they want to get back the parser object or its source code.versions easier. [#32]
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]name
property ofPEG.GrammarError
instances from “PEG.GrammarError” to just “GrammarError”. This better reflects the fact that PEG.js can get required with different variable name thanPEG
.PEG.GrammarError
correctly.SyntaxError
in generated parsers correctly.\^
. [#125]README.md
.CHANGELOG
to Markdown.README.md: Fix |PEG.buildParser| option name
Update version to 0.6.2
Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.
For more information:![](https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiJmNjc4ODFmYS1kMmJkLTQ1ZDEtYjY4Mi04MmVlNzFlMGIyNDkiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6ImY2Nzg4MWZhLWQyYmQtNDVkMS1iNjgyLTgyZWU3MWUwYjI0OSJ9fQ==)
🧐 View latest project report
🛠 Adjust upgrade PR settings
🔕 Ignore this dependency or unsubscribe from future upgrade PRs