Unexpected token ILLEGAL on /^
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.1k
- Forks
- 773
- PR merge metrics
- No merged PRs in 30d
Description
Unexpected token ILLEGAL on /^
I try parse following js
isImage=function(e){return/^image\//.test(e.type)
and get ParserExeption
Line 1: Unexpected token ILLEGAL
This code works in chrome without any errors.
Code to parse
var s = new Scanner(@"isImage=function(e){return/^image\//.test(e.type)}");
var tokens = new List();
Token token;
do
{
s.ScanComments();
token = s.Lex();
tokens.Add(token);
} while (token.Type != TokenType.EOF);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with the JavaScript string passed to Scanner and inspect the Scanner/Lex flow that produces the Unexpected token ILLEGAL error. The issue is resolved when the regular-expression literal /^image// is tokenized without an error, matching Chrome's behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100