jviereck / regjsparser

Parsing the JavaScript's RegExp in JavaScript.
http://www.julianviereck.de/regjsparser/
BSD 2-Clause "Simplified" License
79 stars 20 forks source link

Decimal escape in capture group is incorrectly parsed as a reference #114

Closed JLHwung closed 3 years ago

JLHwung commented 3 years ago

AST Explorer.

Currently,

/([\1])/

is parsed as

{
  "type": "group",
  "behavior": "normal",
  "body": [
    {
      "type": "characterClass",
      "body": [
        {
          "type": "reference",
          "matchIndex": 1,
          "range": [
            2,
            4
          ],
          "raw": "\\1"
        }
      ],
      "negative": false,
      "range": [
        1,
        5
      ],
      "raw": "[\\1]"
    }
  ],
  "range": [
    0,
    6
  ],
  "raw": "([\\1])"
}

where \1 should have been parsed as a value.