shapesecurity / shift-parser-js

ECMAScript parser that produces a Shift format AST
http://shift-ast.org/parser.html
Apache License 2.0
248 stars 28 forks source link

Preserve backslash in regexp #375

Closed mhaagens closed 6 years ago

mhaagens commented 6 years ago

Any way I can preserve the backslash in the regexp of "test", as seen here? It just returns test: /.js$/ when I run it through parseModule.

screen shot 2017-10-21 at 22 48 38
bakkot commented 6 years ago

That's a normal JavaScript string escaping thing, nothing to do with Shift. By the time Shift sees it, there's no backslash there:

`\.` === '.' // true

Just put another backslash in front of it, or tag your template with String.raw.

mhaagens commented 6 years ago

Thank you so much for helping me out, and sorry for opening an unrelated issue!