Fix code generated for classes starting with "\^"

Before this commit, incorrect regexps were produced for classes starting
with "\^". For example, this grammar:

  start = [\^a]

didn't match "a" because the generated regexp inside the parser was
/^[^a]/, not /^[\^a]/ as it should be.

This commit fixes the issue by escaping "^" in |quoteForRegexpClass|.

Fixes GH-125.
redux
David Majda 12 years ago
parent ff819cc579
commit 1988110a28

@ -183,6 +183,7 @@ var utils = {
.replace(/\\/g, '\\\\') // backslash
.replace(/\//g, '\\/') // closing slash
.replace(/\]/g, '\\]') // closing bracket
.replace(/^/g, '\\^') // caret
.replace(/-/g, '\\-') // dash
.replace(/\0/g, '\\0') // null
.replace(/\t/g, '\\t') // horizontal tab

Loading…
Cancel
Save