The following regexp /[a]\g/ is accepted by Ruby, yet RegexpParser raises an error:
> ruby -e "p(/[a]\g/ =~ 'ag')"
0
> ruby -r regexp_parser -e "Regexp::Parser.parse '/[a]\g/'"
Traceback (most recent call last):
6: from -e:1:in `<main>'
5: from /Users/mal/.rvm/gems/ruby-2.7.1/gems/regexp_parser-1.7.1/lib/regexp_parser/parser.rb:22:in `parse'
4: from /Users/mal/.rvm/gems/ruby-2.7.1/gems/regexp_parser-1.7.1/lib/regexp_parser/parser.rb:38:in `parse'
3: from /Users/mal/.rvm/gems/ruby-2.7.1/gems/regexp_parser-1.7.1/lib/regexp_parser/lexer.rb:15:in `lex'
2: from /Users/mal/.rvm/gems/ruby-2.7.1/gems/regexp_parser-1.7.1/lib/regexp_parser/lexer.rb:28:in `lex'
1: from /Users/mal/.rvm/gems/ruby-2.7.1/gems/regexp_parser-1.7.1/lib/regexp_parser/scanner.rb:71:in `scan'
/Users/mal/.rvm/gems/ruby-2.7.1/gems/regexp_parser-1.7.1/lib/regexp_parser/scanner.rb:2664:in `scan': Scan error at '\\g/' (Regexp::Scanner::ScannerError)
The same reasoning as #63 applies: while technically incorrect, this Regexp is actually accepted and might exist in the wild. Would it be possible to tweak the gem to parse it the same way Ruby does?
The following regexp
/[a]\g/
is accepted by Ruby, yet RegexpParser raises an error:The same reasoning as #63 applies: while technically incorrect, this Regexp is actually accepted and might exist in the wild. Would it be possible to tweak the gem to parse it the same way Ruby does?