S. no. | SLR Parsers | Canonical LR Parsers | LALR Parsers |
---|---|---|---|
1 | SLR parser are easiest to implement. | CLR parsers are difficult to implement. | LALR parsers are difficult to implement than SLR parser but less than CLR parsers. |
2. | SLR parsers make use of canonical collection of LR(0) items for constructing the parsing tables. | CLR parsers are uses LR(1) collection of items for constructing the parsing tables part. | LALR parsers LR(1) collection , items with items having same core merged into a single itemset. |
3 | SLR parsers don’t do any lookahead i.e., they lookahead zero | CLR parsers lookahead one symbol. | LALR parsers lookahead one symbol. |
4. | SLR parsers are cost effective to construct in terms of time and space. | CLR parsers are expensive to construct in terms – of time and space. | The cost of constructing LALR parsers is i intermediate between SLR and CLR parser. |
5. | SLR parsers have hundreds of states. | CLR parses have thousands of states. | LALR parsers have hundreds of state and is same as number states in SLR parsers. |
6. | SLR parsers uses FOLLOW information to guide reductions. | CLR parsers uses lookahead symbol to guide reductions. | LALR parsers uses lookahead symbol to guide reductions. |
7. | SLR parsers may fail to I produce a table for certain class of grammars on which ether succeed. | CLR parser works on very large class of grammar. | LALR parser works on very large class grammars. |
8. | Every SLR(1) grammar is LR(1) grammar and LALR(1). | Every LR(1) grammar may not be SLR( 1) grammar. | Every LALR(1) grammar may not be SLR(1) but every LALR(1) grammar is LR(1) grammar. |
9. | A shift-reduce or reduce-reduce conflict may arise in SLR parsing table. | A shift-reduce or reduce-reduce conflicted may arise but chances are less than that in SLR parsing tables. | A shift-reduce conflict can not arise but a reduce-reduce conflict may arise. |
10. | SLR parser is least powerful. | A CLR parsers is most powerful among the family canonical of bottom-up parsers. | A LALR parser is intermediate in power between SLR and LR parser. |
activation record in compiler design