Browse Source

Forward location to buildMessage (closes #608)

master
Futago-za Ryuu 1 year ago
parent
commit
1159660cf7
4 changed files with 7 additions and 6 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +2
    -2
      packages/pegjs/lib/compiler/passes/generate-js.js
  3. +3
    -3
      packages/pegjs/lib/parser.js
  4. +1
    -1
      packages/pegjs/typings/generated-parser.d.ts

+ 1
- 0
CHANGELOG.md View File

@@ -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



+ 2
- 2
packages/pegjs/lib/compiler/passes/generate-js.js View File

@@ -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",


+ 3
- 3
packages/pegjs/lib/parser.js View File

@@ -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


+ 1
- 1
packages/pegjs/typings/generated-parser.d.ts View File

@@ -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;

}



Loading…
Cancel
Save