Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimise LR(1) table #2

Open
tjvr opened this issue Mar 22, 2017 · 1 comment
Open

Minimise LR(1) table #2

tjvr opened this issue Mar 22, 2017 · 1 comment

Comments

@tjvr
Copy link
Collaborator

tjvr commented Mar 22, 2017

There appear to be techniques to reduce the number of states in the automaton.

@tjvr
Copy link
Collaborator Author

tjvr commented Jan 26, 2019

Consider the following two item sets:

i6. goto('+') from i2
  1 [Expr  -> Factor '+' . num,  $end]*
  2 [Expr  -> Factor '+' . num,  '+' ]*
  3 [Parms -> .,                 ',' ] 

i11. goto('+') from i4
  1 [Expr  -> Factor '+' . num,  '+']*
  2 [Expr  -> Factor '+' . num,  ')']*
  3 [Parms -> .,                 ','] 

If we ignore lookahead items, they have the same item cores:

i6. cores:
  [Expr  -> Factor '+' . num]*
  [Parms -> .               ]

i11. cores:
  [Expr  -> Factor '+' . num]*
  [Parms -> .               ]

(We only need to compare the cores of the kernel items, since the closure items are determined by the kernel items, and so should be the same.)

Also, the reduction item sets are identical, so merging them would not produce a reduce/reduce conflict. ("This occurs in grammars that are LR(k) but which are not simpler, i.e., grammars that are not SLR(0), LALR(k), or LR(0).") That is to say, if the reduction is different depending on the lookahead symbol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant