Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
evmar
on March 17, 2018
|
parent
|
context
|
favorite
| on:
What can we learn from how compilers are designed?
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.
comex
on March 17, 2018
[–]
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:
If it occurs in code like:
then it needs to continue lexing a regular expression.If it occurs in code like:
then it needs to lex it as division sign, identifier x, semicolon.