LR Parser Flashcards

1
Q

LR Parser

A

input is scanned left-to-right and a rightmost derivation is constructed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

SLR

A

simple LR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

LALR

A

look ahead LR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the most general grammar?

A

LR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the most specific grammar?

A

SLR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

LR parsers to time and space __________ in the size of input

A

linear

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which is more powerful, LR or LL?

A

LR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which is more natural, LR or LL?

A

LR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Disadvantages of LR grammar?

A

harder to write parser, larger table size, more difficult error repair

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the stack represent in a bottom up parser?

A

summary of input already seen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

shift operation

A

shif the next input token from the input to the top of the stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

reduce operation

A

pop N symbols on stack that match a RHS of production and push non-term

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What type of derivation is constructed for LR?

A

reverse rightmost derivation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

reduction

A

each step of building the parse tree (add a new nonterm as parent of subtree)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What actions can an LR parser perform?

A

shift, reduce, accept, reject

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are symbols pushed onto LR parser’s stack?

A

states

17
Q

2 tables of LR parsers:

A

action table

goto table

18
Q

action table

A

indexed by the top-of-stack symbol and current token, tells which action to perform

19
Q

What is different for different LR parsers?

A

definition of an item
number of states in underlying state machine
amount of information in a state

20
Q

item

A

production with a dot somewhere on the rhs

21
Q

for an item to the right of a dot

A

look for productions with a LHS of that symbol, then add to the closure

22
Q

Closure(I) tells you what?

Goto(I,X) tells you what?

A

where we might be in the parse

where we might be after parsing X

23
Q

When is a grammar not in SLR(1)

A

When there is a conflict in the SLR Action Table

24
Q

2 types of conflicts for

A

shift/reduce

reduce/reduce

25
Q

shift/reduce

A

it is not possible to determine based on the top-of-stack state symbol and current token to shift or reduce

26
Q

reduce/reduce

A

not possible to determine which grammar rule to reduce by