Skip to content

caret ^ not escaped in regexp, generates jshint error #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dkorz opened this issue Nov 19, 2012 · 1 comment
Closed

caret ^ not escaped in regexp, generates jshint error #125

dkorz opened this issue Nov 19, 2012 · 1 comment

Comments

@dkorz
Copy link

dkorz commented Nov 19, 2012

I have the following rule:

text_char 
    = [\-\^$+/():!&'~{}<>= ]

This generates:

  function parse_text_char() {
    var result0;

    if (/^[\-^$+\/():!&'~{}<>= ]/.test(input.charAt(pos))) {
      result0 = input.charAt(pos);
      pos++;
    } else {
      result0 = null;
      if (reportFailures === 0) {
        matchFailed("[\\-^$+\\/():!&'~{}<>= ]");
      }
    }
    return result0;
  }

jshint flags this as an error saying it's unescaped which breaks our build process. I think the code is working correctly but I've just started working with pegjs and haven't done much testing.

I think this can just be added to utils.quoteForRegexpClass(). It's interesting that jshint doesn't complain about the $. I can't find an option in jshint to turn this check off like I was able to with line breaks or I would have done that.

@dmajda dmajda closed this as completed in 1988110 Nov 21, 2012
@dmajda
Copy link
Contributor

dmajda commented Nov 21, 2012

@dkorz It turned out this was not just a JSHint issue but a real problem — see the example in 1988110 where I fixed the problem.

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants