summaryrefslogtreecommitdiff
path: root/src/paca.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/paca.mjs')
-rw-r--r--src/paca.mjs20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/paca.mjs b/src/paca.mjs
index 993d26c..380200a 100644
--- a/src/paca.mjs
+++ b/src/paca.mjs
@@ -36,12 +36,6 @@ const tokenizeRegexStep = chars => ({ out, state }, char, index) => {
}
if (char === "\\") {
- if (next === undefined) {
- throw new SyntaxError(
- `bad trailing escape character: ${chars}`,
- );
- }
-
return {
out,
state: ConcatStep.ESCAPING,
@@ -61,8 +55,18 @@ const tokenizeRegexFn = chars =>
state: ConcatStep.ACCEPTING,
});
-const tokenizeRegex = chars =>
- tokenizeRegexFn(chars).out;
+const tokenizeRegex = chars => {
+ const tokens = tokenizeRegexFn(chars);
+ if (!!tokens.error) {
+ throw tokens.error;
+ }
+
+ if (tokens.state !== ConcatStep.ACCEPTING) {
+ throw new SyntaxError("bad ending state: " + tokens.state);
+ }
+
+ return tokens.out;
+};
const PRECEDENCE = {
"(": 4,