Forward location to buildMessage (closes #608)

master
Futago-za Ryuu 5 роки тому
джерело d615cd7975
коміт 1159660cf7

@ -66,6 +66,7 @@
* On the CLI added the use of `input` and `output` from the _config file_ instead of passing them as arguments
* Updated examples
* Upgraded support for Unicode (from _v8_ to _v11_)
* Forward location to `SyntaxError.buildMessage` ([#608](https://github.com/pegjs/pegjs/pull/608))
### Bugfixes

@ -1047,7 +1047,7 @@ function generateJS( ast, session, options ) {
"",
"peg$subclass(peg$SyntaxError, Error);",
"",
"peg$SyntaxError.buildMessage = function(expected, found) {",
"peg$SyntaxError.buildMessage = function(expected, found, location) {",
" var DESCRIBE_EXPECTATION_FNS = {",
" literal: function(expectation) {",
" return \"\\\"\" + literalEscape(expectation.text) + \"\\\"\";",
@ -1547,7 +1547,7 @@ function generateJS( ast, session, options ) {
"",
" function peg$buildStructuredError(expected, found, location) {",
" return new peg$SyntaxError(",
" peg$SyntaxError.buildMessage(expected, found),",
" peg$SyntaxError.buildMessage(expected, found, location),",
" expected,",
" found,",
" location",

@ -1,4 +1,4 @@
// Generated by PEG.js v0.11.0-dev, https://pegjs.org/
// Generated by PEG.js v0.11.0, https://pegjs.org/
/* eslint-disable */
@ -28,7 +28,7 @@ function peg$SyntaxError(message, expected, found, location) {
peg$subclass(peg$SyntaxError, Error);
peg$SyntaxError.buildMessage = function(expected, found) {
peg$SyntaxError.buildMessage = function(expected, found, location) {
var DESCRIBE_EXPECTATION_FNS = {
literal: function(expectation) {
return "\"" + literalEscape(expectation.text) + "\"";
@ -557,7 +557,7 @@ function peg$parse(input, options) {
function peg$buildStructuredError(expected, found, location) {
return new peg$SyntaxError(
peg$SyntaxError.buildMessage(expected, found),
peg$SyntaxError.buildMessage(expected, found, location),
expected,
found,
location

@ -56,7 +56,7 @@ declare namespace generatedparser {
new( message: string, expected: T, found: string | null, location: SourceLocation ): ISyntaxError<T>;
readonly prototype: ISyntaxError<T>;
buildMessage( expected: T, found?: string ): string;
buildMessage( expected: T, found?: string, location?: SourceLocation ): string;
}

Завантаження…
Відмінити
Зберегти