Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LALR(2) dangling else

Is LALR(2) able to handle the dangling else case naturally (without any special rules, as with LALR(1))?

Thanks

like image 707
Flavius Avatar asked Dec 01 '09 21:12

Flavius


People also ask

How do I fix dangling else problems?

The problem can also be solved by making explicit the link between an else and its if, within the syntax. This usually helps avoid human errors. Possible solutions are: Having an "end if" symbol delimiting the end of the if construct.

Is Lalr and CLR same?

LALR Parser is Look Ahead LR Parser. It is intermediate in power between SLR and CLR parser. It is the compaction of CLR Parser, and hence tables obtained in this will be smaller than CLR Parsing Table. For constructing the LALR (1) parsing table, the canonical collection of LR (1) items is used.

What is dangling if in C?

Sometimes the programmer fails to initialize the pointer with a valid address, then this type of initialized pointer is known as a dangling pointer in C. Dangling pointer occurs at the time of the object destruction when the object is deleted or de-allocated from memory without modifying the value of the pointer.

Is LALR and LR 1 Same?

An LALR(1) parser is an "upgraded" version of an LR(0) parser that keeps track of more precise information to disambiguate the grammar. An LR(1) parser is a significantly more powerful parser that keeps track of even more precise information than an LALR(1) parser.


1 Answers

No, the dangling else problem is an ambiguity, so no amount of lookahead helps.

like image 93
Chris Dodd Avatar answered Sep 21 '22 21:09

Chris Dodd