edited by
497 views
1 votes
1 votes

edited by

2 Answers

0 votes
0 votes

There are three basic ways to build a shift-reduce parser. Full LR(1) (the `L' is the direction in which the input is scanned, the `R' is the way in which the parse is built, and the `1' is the number of tokens of lookahead) generates a parser with many states, and is therefore large and slow. SLR(1) (simple LR(1)) is a cut-down version of LR(1) which generates parsers with roughly one-tenth as many states, but lacks the power to parse many grammars (it finds conflicts in grammars which have none under LR(1)). ( n1 >= n2)

LALR(1) (look-ahead LR(1)), the method used by Happy and yacc, is tradeoff between the two. An LALR(1) parser has the same number of states as an SLR(1) parser, but it uses a more complex method to calculate the lookahead tokens that are valid at each point, and resolves many of the conflicts that SLR(1) finds.However, there may still be conflicts in an LALR(1) parser that wouldn't be there with full LR(1).

 

n1>=n3>=n2

http://www.cs.binghamton.edu/~zdu/parsdemo/srintro.html

https://www.haskell.org/happy/doc/html/sec-conflict-tips.html

 

 

 

 

Related questions

0 votes
0 votes
1 answer
1
0 votes
0 votes
1 answer
2
anonymous asked Jun 26, 2016
682 views
0 votes
0 votes
0 answers
3
Vishal Goyal asked Dec 6, 2016
293 views
0 votes
0 votes
1 answer
4