From f8b5e04bba314275d0821bc5b33fcc6420a4dbb2 Mon Sep 17 00:00:00 2001 From: David Majda Date: Sun, 1 Dec 2013 14:10:24 +0100 Subject: [PATCH] Error handling: Use the new |error| function in PEG.js's grammar itself Implements part of #198. --- src/parser.pegjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/parser.pegjs b/src/parser.pegjs index e5d20e1..a864e03 100644 --- a/src/parser.pegjs +++ b/src/parser.pegjs @@ -267,9 +267,10 @@ class "character class" classCharacterRange = begin:classCharacter "-" end:classCharacter { if (begin.data.charCodeAt(0) > end.data.charCodeAt(0)) { - throw new this.SyntaxError( + error( "Invalid character range: " + begin.rawText + "-" + end.rawText + "." ); + return; } return {