LR1 File Format (.lr1) CS 444

A .lr1 file has two components:

Context-free Grammar

Same as the CFG File Format. The grammar must be augmented; that is, the start symbol must occur as the LHS of exactly one rule that begins and ends with a terminal.

LR(1) Machine

The parser representation has three components:

Example .lr1 File (see bubble diagram)

6
BOF
EOF
id
-
(
)
3
S
expr
term
S
5
S BOF expr EOF
expr term
expr expr - term
term id
term ( expr )
11
28
8 EOF reduce 2
9 - reduce 4
7 - shift 1
1 id shift 2
6 ( shift 3
6 term shift 4
10 EOF shift 5
2 - reduce 3
4 ) reduce 1
3 id shift 2
4 EOF reduce 1
2 ) reduce 3
0 BOF shift 6
8 - reduce 2
2 EOF reduce 3
3 expr shift 7
9 ) reduce 4
9 EOF reduce 4
4 - reduce 1
1 term shift 8
3 term shift 4
3 ( shift 3
10 - shift 1
6 id shift 2
8 ) reduce 2
1 ( shift 3
7 ) shift 9
6 expr shift 10