Describe the term LALR Parser

Describe the term LALR Parser with example.

E

Expert

Verified

The abbreviation of LALR is Look-ahead LR parser. This differs from the LR in the fact that it will look ahead one symbol in the input string before going for a reduce action. Look-ahead aids in knowing if the complete rule has been matched or not.

Example: Consider a grammar G with production

P->AB|ABC

If the Parser shifts the Symbol B it can decrease to P. However if the next Symbol was C then it has not matched the complete rule. The LALR parser will shift one extra token and then take a decision to reduce or shift.

   Related Questions in Computer Engineering

©TutorsGlobe All rights reserved 2022-2023.