Hacker News new | past | comments | ask | show | jobs | submit login

Another place where lexing and parsing interact is JavaScript. Consider the lexer encountering the text "/x;".

If it occurs in code like:

   let a = /x;
then it needs to continue lexing a regular expression.

If it occurs in code like:

   let a = b /x;
then it needs to lex it as division sign, identifier x, semicolon.



At least it's not bad as Perl, where the same code can be parsed as division or a regex depending on the 'type signature' of a function it names:

https://www.perlmonks.org/?node_id=663393




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: