1
$\begingroup$

I keep hearing about lookahead parsers, LL parsers, LR, LALR, etc... but no clear explanation behind the etymology of this word.

What does "lookahead" refer to? How does this relate to LL, LR, LALR? Basic examples would be great, as I'm not well versed in this subject.

$\endgroup$
3
$\begingroup$

"A good driver drives in three cars. His own car, the car behind him, and the car in front of him". (Bertold Brecht).

"Lookahead" is what you do when you drive a car. You look ahead and make decisions not just based on things around you, but also based on things ahead of you.

A parser with a lookahead of 1 makes decisions based on the current symbol and the symbol ahead of it. That often keeps it from making the wrong parsing decisions.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Based on your car analogy, a good parser should have not only lookahead, but lookbehind as well? $\endgroup$ – kate Sep 30 at 2:25
  • 2
    $\begingroup$ @kate Unlike driving, everything behind you is static so that just becomes "memory". $\endgroup$ – Especially Lime Sep 30 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.