DEV Community

Discussion on: Arrow functions break JavaScript parsers

evanplaice profile image
Evan Plaice

JS is parsed with a TDOP (Top Down Order Precedence) parser.

This may explain why it's hard to cover all edge cases using an alternative (ex EBNF).

TDOP is very flexible and very fast. But, to handle an existing grammar you have to know the order.

samthor profile image
Sam Thorogood Author • Edited

I took a look at Crockford's post on this. It seems like he thinks TDOP is a good fit for "Simplified JavaScript", which wouldn't have these ambiguities in the language.

My post is more about simple L-to-R parsers, and maybe a better title would be on "breaking tokenizers". Unfortunately tokenizers technically can't be as simple as we expect because of the ambiguities I outline. This is why breaking most syntax highlighters is trivial ;)