This repository was archived by the owner on May 22, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Snyk has created this PR to upgrade pegjs from 0.6.2 to 0.10.0.
ℹ️ 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.
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:
🧐 View latest project report
🛠 Adjust upgrade PR settings
🔕 Ignore this dependency or unsubscribe from future upgrade PRs