Bottom up parser Flashcards
what is the difference between top down parser and bottom up parser ?
S –> Ab
top-down parser :
pop S into the stack then the right-hand side
left most derivation
bottom-up parser
pop the Ab then the left-hand side(S)
right-most derivation
bottom-up parser action :
reduce :
A -> Ba replacing the eight hand side by A
| a | | A |
| B | ==> | . |
|__ | |__|
shift :
reads the terminal from the input and put it on the stack
what are possible conflicts we can face
Reduce Reduce problem :
| A | and two rules B -> A / C -> Ab the parser gets
| b | stuck which rule he should reduce
|__ |
Shift reduce conflict: it gets stuck whether it keeps shifting or reducing
viable prefix
the prefix of a right sentential for that that occur during a successfull right-most derivation
how to extract viable prefix in a given automata
the prefix of a right sentential for that that occur during a successful run of the bottom parser, and can be extracted during the build of CFSM
LR 0 parser rules
at all the time we want a viable prefix on the stack
associate a config to each state of CFSM
at each step, we run CFGM on the stack content
Associate actions to each CFGM state A-> a. reduce otherwise, shift
what is the unrealistic things about LR 0 parser
the fact that we need to feed the content of stack CFSM, however, it can be treated through inserting the state number
what are the limitations of LR0?
it can lead to conflicts
SLR 1
it’s