1140 lines
34 KiB
Plaintext
1140 lines
34 KiB
Plaintext
Created by PLY version 3.11 (http://www.dabeaz.com/ply)
|
|
|
|
Grammar
|
|
|
|
Rule 0 S' -> E
|
|
Rule 1 E -> LET D IN E
|
|
Rule 2 E -> ID
|
|
Rule 3 E -> ID LPAREN A RPAREN
|
|
Rule 4 E -> E AOP E
|
|
Rule 5 E -> LPAREN E RPAREN
|
|
Rule 6 E -> CONST
|
|
Rule 7 E -> ID ASSIGN E
|
|
Rule 8 E -> E SEMICOLON E
|
|
Rule 9 E -> IF B THEN E ELSE E
|
|
Rule 10 E -> WHILE B DO LBRACE E RBRACE
|
|
Rule 11 A -> E
|
|
Rule 12 A -> A COMMA E
|
|
Rule 13 D -> ID LPAREN V RPAREN LBRACE E RBRACE
|
|
Rule 14 D -> D D
|
|
Rule 15 V -> ID
|
|
Rule 16 V -> V COMMA ID
|
|
Rule 17 B -> E EQOP E
|
|
Rule 18 B -> E COMP E
|
|
Rule 19 B -> B EQOP B
|
|
Rule 20 B -> B LOP B
|
|
Rule 21 B -> TRUE
|
|
Rule 22 B -> FALSE
|
|
Rule 23 B -> LPAREN B RPAREN
|
|
|
|
Terminals, with rules where they appear
|
|
|
|
AOP : 4
|
|
ASSIGN : 7
|
|
COMMA : 12 16
|
|
COMP : 18
|
|
CONST : 6
|
|
DO : 10
|
|
ELSE : 9
|
|
EQOP : 17 19
|
|
FALSE : 22
|
|
ID : 2 3 7 13 15 16
|
|
IF : 9
|
|
IN : 1
|
|
LBRACE : 10 13
|
|
LET : 1
|
|
LOP : 20
|
|
LPAREN : 3 5 13 23
|
|
RBRACE : 10 13
|
|
RPAREN : 3 5 13 23
|
|
SEMICOLON : 8
|
|
THEN : 9
|
|
TRUE : 21
|
|
WHILE : 10
|
|
error :
|
|
|
|
Nonterminals, with rules where they appear
|
|
|
|
A : 3 12
|
|
B : 9 10 19 19 20 20 23
|
|
D : 1 14 14
|
|
E : 1 4 4 5 7 8 8 9 9 10 11 12 13 17 17 18 18 0
|
|
V : 13 16
|
|
|
|
Parsing method: LALR
|
|
|
|
state 0
|
|
|
|
(0) S' -> . E
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
LPAREN shift and go to state 4
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
E shift and go to state 1
|
|
|
|
state 1
|
|
|
|
(0) S' -> E .
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
AOP shift and go to state 8
|
|
SEMICOLON shift and go to state 9
|
|
|
|
|
|
state 2
|
|
|
|
(1) E -> LET . D IN E
|
|
(13) D -> . ID LPAREN V RPAREN LBRACE E RBRACE
|
|
(14) D -> . D D
|
|
|
|
ID shift and go to state 11
|
|
|
|
D shift and go to state 10
|
|
|
|
state 3
|
|
|
|
(2) E -> ID .
|
|
(3) E -> ID . LPAREN A RPAREN
|
|
(7) E -> ID . ASSIGN E
|
|
|
|
AOP reduce using rule 2 (E -> ID .)
|
|
SEMICOLON reduce using rule 2 (E -> ID .)
|
|
$end reduce using rule 2 (E -> ID .)
|
|
RPAREN reduce using rule 2 (E -> ID .)
|
|
EQOP reduce using rule 2 (E -> ID .)
|
|
COMP reduce using rule 2 (E -> ID .)
|
|
COMMA reduce using rule 2 (E -> ID .)
|
|
ELSE reduce using rule 2 (E -> ID .)
|
|
THEN reduce using rule 2 (E -> ID .)
|
|
LOP reduce using rule 2 (E -> ID .)
|
|
DO reduce using rule 2 (E -> ID .)
|
|
RBRACE reduce using rule 2 (E -> ID .)
|
|
LPAREN shift and go to state 12
|
|
ASSIGN shift and go to state 13
|
|
|
|
|
|
state 4
|
|
|
|
(5) E -> LPAREN . E RPAREN
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
LPAREN shift and go to state 4
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
E shift and go to state 14
|
|
|
|
state 5
|
|
|
|
(6) E -> CONST .
|
|
|
|
AOP reduce using rule 6 (E -> CONST .)
|
|
SEMICOLON reduce using rule 6 (E -> CONST .)
|
|
$end reduce using rule 6 (E -> CONST .)
|
|
RPAREN reduce using rule 6 (E -> CONST .)
|
|
EQOP reduce using rule 6 (E -> CONST .)
|
|
COMP reduce using rule 6 (E -> CONST .)
|
|
COMMA reduce using rule 6 (E -> CONST .)
|
|
ELSE reduce using rule 6 (E -> CONST .)
|
|
THEN reduce using rule 6 (E -> CONST .)
|
|
LOP reduce using rule 6 (E -> CONST .)
|
|
DO reduce using rule 6 (E -> CONST .)
|
|
RBRACE reduce using rule 6 (E -> CONST .)
|
|
|
|
|
|
state 6
|
|
|
|
(9) E -> IF . B THEN E ELSE E
|
|
(17) B -> . E EQOP E
|
|
(18) B -> . E COMP E
|
|
(19) B -> . B EQOP B
|
|
(20) B -> . B LOP B
|
|
(21) B -> . TRUE
|
|
(22) B -> . FALSE
|
|
(23) B -> . LPAREN B RPAREN
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
TRUE shift and go to state 17
|
|
FALSE shift and go to state 18
|
|
LPAREN shift and go to state 19
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
B shift and go to state 15
|
|
E shift and go to state 16
|
|
|
|
state 7
|
|
|
|
(10) E -> WHILE . B DO LBRACE E RBRACE
|
|
(17) B -> . E EQOP E
|
|
(18) B -> . E COMP E
|
|
(19) B -> . B EQOP B
|
|
(20) B -> . B LOP B
|
|
(21) B -> . TRUE
|
|
(22) B -> . FALSE
|
|
(23) B -> . LPAREN B RPAREN
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
TRUE shift and go to state 17
|
|
FALSE shift and go to state 18
|
|
LPAREN shift and go to state 19
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
B shift and go to state 20
|
|
E shift and go to state 16
|
|
|
|
state 8
|
|
|
|
(4) E -> E AOP . E
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
LPAREN shift and go to state 4
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
E shift and go to state 21
|
|
|
|
state 9
|
|
|
|
(8) E -> E SEMICOLON . E
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
LPAREN shift and go to state 4
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
E shift and go to state 22
|
|
|
|
state 10
|
|
|
|
(1) E -> LET D . IN E
|
|
(14) D -> D . D
|
|
(13) D -> . ID LPAREN V RPAREN LBRACE E RBRACE
|
|
(14) D -> . D D
|
|
|
|
IN shift and go to state 24
|
|
ID shift and go to state 11
|
|
|
|
D shift and go to state 23
|
|
|
|
state 11
|
|
|
|
(13) D -> ID . LPAREN V RPAREN LBRACE E RBRACE
|
|
|
|
LPAREN shift and go to state 25
|
|
|
|
|
|
state 12
|
|
|
|
(3) E -> ID LPAREN . A RPAREN
|
|
(11) A -> . E
|
|
(12) A -> . A COMMA E
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
LPAREN shift and go to state 4
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
A shift and go to state 26
|
|
E shift and go to state 27
|
|
|
|
state 13
|
|
|
|
(7) E -> ID ASSIGN . E
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
LPAREN shift and go to state 4
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
E shift and go to state 28
|
|
|
|
state 14
|
|
|
|
(5) E -> LPAREN E . RPAREN
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
RPAREN shift and go to state 29
|
|
AOP shift and go to state 8
|
|
SEMICOLON shift and go to state 9
|
|
|
|
|
|
state 15
|
|
|
|
(9) E -> IF B . THEN E ELSE E
|
|
(19) B -> B . EQOP B
|
|
(20) B -> B . LOP B
|
|
|
|
THEN shift and go to state 30
|
|
EQOP shift and go to state 31
|
|
LOP shift and go to state 32
|
|
|
|
|
|
state 16
|
|
|
|
(17) B -> E . EQOP E
|
|
(18) B -> E . COMP E
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
EQOP shift and go to state 33
|
|
COMP shift and go to state 34
|
|
AOP shift and go to state 8
|
|
SEMICOLON shift and go to state 9
|
|
|
|
|
|
state 17
|
|
|
|
(21) B -> TRUE .
|
|
|
|
THEN reduce using rule 21 (B -> TRUE .)
|
|
EQOP reduce using rule 21 (B -> TRUE .)
|
|
LOP reduce using rule 21 (B -> TRUE .)
|
|
DO reduce using rule 21 (B -> TRUE .)
|
|
RPAREN reduce using rule 21 (B -> TRUE .)
|
|
|
|
|
|
state 18
|
|
|
|
(22) B -> FALSE .
|
|
|
|
THEN reduce using rule 22 (B -> FALSE .)
|
|
EQOP reduce using rule 22 (B -> FALSE .)
|
|
LOP reduce using rule 22 (B -> FALSE .)
|
|
DO reduce using rule 22 (B -> FALSE .)
|
|
RPAREN reduce using rule 22 (B -> FALSE .)
|
|
|
|
|
|
state 19
|
|
|
|
(23) B -> LPAREN . B RPAREN
|
|
(5) E -> LPAREN . E RPAREN
|
|
(17) B -> . E EQOP E
|
|
(18) B -> . E COMP E
|
|
(19) B -> . B EQOP B
|
|
(20) B -> . B LOP B
|
|
(21) B -> . TRUE
|
|
(22) B -> . FALSE
|
|
(23) B -> . LPAREN B RPAREN
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
TRUE shift and go to state 17
|
|
FALSE shift and go to state 18
|
|
LPAREN shift and go to state 19
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
B shift and go to state 35
|
|
E shift and go to state 36
|
|
|
|
state 20
|
|
|
|
(10) E -> WHILE B . DO LBRACE E RBRACE
|
|
(19) B -> B . EQOP B
|
|
(20) B -> B . LOP B
|
|
|
|
DO shift and go to state 37
|
|
EQOP shift and go to state 31
|
|
LOP shift and go to state 32
|
|
|
|
|
|
state 21
|
|
|
|
(4) E -> E AOP E .
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
AOP reduce using rule 4 (E -> E AOP E .)
|
|
SEMICOLON reduce using rule 4 (E -> E AOP E .)
|
|
$end reduce using rule 4 (E -> E AOP E .)
|
|
RPAREN reduce using rule 4 (E -> E AOP E .)
|
|
EQOP reduce using rule 4 (E -> E AOP E .)
|
|
COMP reduce using rule 4 (E -> E AOP E .)
|
|
COMMA reduce using rule 4 (E -> E AOP E .)
|
|
ELSE reduce using rule 4 (E -> E AOP E .)
|
|
THEN reduce using rule 4 (E -> E AOP E .)
|
|
LOP reduce using rule 4 (E -> E AOP E .)
|
|
DO reduce using rule 4 (E -> E AOP E .)
|
|
RBRACE reduce using rule 4 (E -> E AOP E .)
|
|
|
|
! AOP [ shift and go to state 8 ]
|
|
! SEMICOLON [ shift and go to state 9 ]
|
|
|
|
|
|
state 22
|
|
|
|
(8) E -> E SEMICOLON E .
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
! shift/reduce conflict for AOP resolved as shift
|
|
! shift/reduce conflict for SEMICOLON resolved as shift
|
|
$end reduce using rule 8 (E -> E SEMICOLON E .)
|
|
RPAREN reduce using rule 8 (E -> E SEMICOLON E .)
|
|
EQOP reduce using rule 8 (E -> E SEMICOLON E .)
|
|
COMP reduce using rule 8 (E -> E SEMICOLON E .)
|
|
COMMA reduce using rule 8 (E -> E SEMICOLON E .)
|
|
ELSE reduce using rule 8 (E -> E SEMICOLON E .)
|
|
THEN reduce using rule 8 (E -> E SEMICOLON E .)
|
|
LOP reduce using rule 8 (E -> E SEMICOLON E .)
|
|
DO reduce using rule 8 (E -> E SEMICOLON E .)
|
|
RBRACE reduce using rule 8 (E -> E SEMICOLON E .)
|
|
AOP shift and go to state 8
|
|
SEMICOLON shift and go to state 9
|
|
|
|
! AOP [ reduce using rule 8 (E -> E SEMICOLON E .) ]
|
|
! SEMICOLON [ reduce using rule 8 (E -> E SEMICOLON E .) ]
|
|
|
|
|
|
state 23
|
|
|
|
(14) D -> D D .
|
|
(14) D -> D . D
|
|
(13) D -> . ID LPAREN V RPAREN LBRACE E RBRACE
|
|
(14) D -> . D D
|
|
|
|
! shift/reduce conflict for ID resolved as shift
|
|
IN reduce using rule 14 (D -> D D .)
|
|
ID shift and go to state 11
|
|
|
|
! ID [ reduce using rule 14 (D -> D D .) ]
|
|
|
|
D shift and go to state 23
|
|
|
|
state 24
|
|
|
|
(1) E -> LET D IN . E
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
LPAREN shift and go to state 4
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
E shift and go to state 38
|
|
|
|
state 25
|
|
|
|
(13) D -> ID LPAREN . V RPAREN LBRACE E RBRACE
|
|
(15) V -> . ID
|
|
(16) V -> . V COMMA ID
|
|
|
|
ID shift and go to state 39
|
|
|
|
V shift and go to state 40
|
|
|
|
state 26
|
|
|
|
(3) E -> ID LPAREN A . RPAREN
|
|
(12) A -> A . COMMA E
|
|
|
|
RPAREN shift and go to state 41
|
|
COMMA shift and go to state 42
|
|
|
|
|
|
state 27
|
|
|
|
(11) A -> E .
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
RPAREN reduce using rule 11 (A -> E .)
|
|
COMMA reduce using rule 11 (A -> E .)
|
|
AOP shift and go to state 8
|
|
SEMICOLON shift and go to state 9
|
|
|
|
|
|
state 28
|
|
|
|
(7) E -> ID ASSIGN E .
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
! shift/reduce conflict for AOP resolved as shift
|
|
! shift/reduce conflict for SEMICOLON resolved as shift
|
|
$end reduce using rule 7 (E -> ID ASSIGN E .)
|
|
RPAREN reduce using rule 7 (E -> ID ASSIGN E .)
|
|
EQOP reduce using rule 7 (E -> ID ASSIGN E .)
|
|
COMP reduce using rule 7 (E -> ID ASSIGN E .)
|
|
COMMA reduce using rule 7 (E -> ID ASSIGN E .)
|
|
ELSE reduce using rule 7 (E -> ID ASSIGN E .)
|
|
THEN reduce using rule 7 (E -> ID ASSIGN E .)
|
|
LOP reduce using rule 7 (E -> ID ASSIGN E .)
|
|
DO reduce using rule 7 (E -> ID ASSIGN E .)
|
|
RBRACE reduce using rule 7 (E -> ID ASSIGN E .)
|
|
AOP shift and go to state 8
|
|
SEMICOLON shift and go to state 9
|
|
|
|
! AOP [ reduce using rule 7 (E -> ID ASSIGN E .) ]
|
|
! SEMICOLON [ reduce using rule 7 (E -> ID ASSIGN E .) ]
|
|
|
|
|
|
state 29
|
|
|
|
(5) E -> LPAREN E RPAREN .
|
|
|
|
AOP reduce using rule 5 (E -> LPAREN E RPAREN .)
|
|
SEMICOLON reduce using rule 5 (E -> LPAREN E RPAREN .)
|
|
$end reduce using rule 5 (E -> LPAREN E RPAREN .)
|
|
RPAREN reduce using rule 5 (E -> LPAREN E RPAREN .)
|
|
EQOP reduce using rule 5 (E -> LPAREN E RPAREN .)
|
|
COMP reduce using rule 5 (E -> LPAREN E RPAREN .)
|
|
COMMA reduce using rule 5 (E -> LPAREN E RPAREN .)
|
|
ELSE reduce using rule 5 (E -> LPAREN E RPAREN .)
|
|
THEN reduce using rule 5 (E -> LPAREN E RPAREN .)
|
|
LOP reduce using rule 5 (E -> LPAREN E RPAREN .)
|
|
DO reduce using rule 5 (E -> LPAREN E RPAREN .)
|
|
RBRACE reduce using rule 5 (E -> LPAREN E RPAREN .)
|
|
|
|
|
|
state 30
|
|
|
|
(9) E -> IF B THEN . E ELSE E
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
LPAREN shift and go to state 4
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
E shift and go to state 43
|
|
|
|
state 31
|
|
|
|
(19) B -> B EQOP . B
|
|
(17) B -> . E EQOP E
|
|
(18) B -> . E COMP E
|
|
(19) B -> . B EQOP B
|
|
(20) B -> . B LOP B
|
|
(21) B -> . TRUE
|
|
(22) B -> . FALSE
|
|
(23) B -> . LPAREN B RPAREN
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
TRUE shift and go to state 17
|
|
FALSE shift and go to state 18
|
|
LPAREN shift and go to state 19
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
B shift and go to state 44
|
|
E shift and go to state 16
|
|
|
|
state 32
|
|
|
|
(20) B -> B LOP . B
|
|
(17) B -> . E EQOP E
|
|
(18) B -> . E COMP E
|
|
(19) B -> . B EQOP B
|
|
(20) B -> . B LOP B
|
|
(21) B -> . TRUE
|
|
(22) B -> . FALSE
|
|
(23) B -> . LPAREN B RPAREN
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
TRUE shift and go to state 17
|
|
FALSE shift and go to state 18
|
|
LPAREN shift and go to state 19
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
B shift and go to state 45
|
|
E shift and go to state 16
|
|
|
|
state 33
|
|
|
|
(17) B -> E EQOP . E
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
LPAREN shift and go to state 4
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
E shift and go to state 46
|
|
|
|
state 34
|
|
|
|
(18) B -> E COMP . E
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
LPAREN shift and go to state 4
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
E shift and go to state 47
|
|
|
|
state 35
|
|
|
|
(23) B -> LPAREN B . RPAREN
|
|
(19) B -> B . EQOP B
|
|
(20) B -> B . LOP B
|
|
|
|
RPAREN shift and go to state 48
|
|
EQOP shift and go to state 31
|
|
LOP shift and go to state 32
|
|
|
|
|
|
state 36
|
|
|
|
(5) E -> LPAREN E . RPAREN
|
|
(17) B -> E . EQOP E
|
|
(18) B -> E . COMP E
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
RPAREN shift and go to state 29
|
|
EQOP shift and go to state 33
|
|
COMP shift and go to state 34
|
|
AOP shift and go to state 8
|
|
SEMICOLON shift and go to state 9
|
|
|
|
|
|
state 37
|
|
|
|
(10) E -> WHILE B DO . LBRACE E RBRACE
|
|
|
|
LBRACE shift and go to state 49
|
|
|
|
|
|
state 38
|
|
|
|
(1) E -> LET D IN E .
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
! shift/reduce conflict for AOP resolved as shift
|
|
! shift/reduce conflict for SEMICOLON resolved as shift
|
|
$end reduce using rule 1 (E -> LET D IN E .)
|
|
RPAREN reduce using rule 1 (E -> LET D IN E .)
|
|
EQOP reduce using rule 1 (E -> LET D IN E .)
|
|
COMP reduce using rule 1 (E -> LET D IN E .)
|
|
COMMA reduce using rule 1 (E -> LET D IN E .)
|
|
ELSE reduce using rule 1 (E -> LET D IN E .)
|
|
THEN reduce using rule 1 (E -> LET D IN E .)
|
|
LOP reduce using rule 1 (E -> LET D IN E .)
|
|
DO reduce using rule 1 (E -> LET D IN E .)
|
|
RBRACE reduce using rule 1 (E -> LET D IN E .)
|
|
AOP shift and go to state 8
|
|
SEMICOLON shift and go to state 9
|
|
|
|
! AOP [ reduce using rule 1 (E -> LET D IN E .) ]
|
|
! SEMICOLON [ reduce using rule 1 (E -> LET D IN E .) ]
|
|
|
|
|
|
state 39
|
|
|
|
(15) V -> ID .
|
|
|
|
RPAREN reduce using rule 15 (V -> ID .)
|
|
COMMA reduce using rule 15 (V -> ID .)
|
|
|
|
|
|
state 40
|
|
|
|
(13) D -> ID LPAREN V . RPAREN LBRACE E RBRACE
|
|
(16) V -> V . COMMA ID
|
|
|
|
RPAREN shift and go to state 50
|
|
COMMA shift and go to state 51
|
|
|
|
|
|
state 41
|
|
|
|
(3) E -> ID LPAREN A RPAREN .
|
|
|
|
AOP reduce using rule 3 (E -> ID LPAREN A RPAREN .)
|
|
SEMICOLON reduce using rule 3 (E -> ID LPAREN A RPAREN .)
|
|
$end reduce using rule 3 (E -> ID LPAREN A RPAREN .)
|
|
RPAREN reduce using rule 3 (E -> ID LPAREN A RPAREN .)
|
|
EQOP reduce using rule 3 (E -> ID LPAREN A RPAREN .)
|
|
COMP reduce using rule 3 (E -> ID LPAREN A RPAREN .)
|
|
COMMA reduce using rule 3 (E -> ID LPAREN A RPAREN .)
|
|
ELSE reduce using rule 3 (E -> ID LPAREN A RPAREN .)
|
|
THEN reduce using rule 3 (E -> ID LPAREN A RPAREN .)
|
|
LOP reduce using rule 3 (E -> ID LPAREN A RPAREN .)
|
|
DO reduce using rule 3 (E -> ID LPAREN A RPAREN .)
|
|
RBRACE reduce using rule 3 (E -> ID LPAREN A RPAREN .)
|
|
|
|
|
|
state 42
|
|
|
|
(12) A -> A COMMA . E
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
LPAREN shift and go to state 4
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
E shift and go to state 52
|
|
|
|
state 43
|
|
|
|
(9) E -> IF B THEN E . ELSE E
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
ELSE shift and go to state 53
|
|
AOP shift and go to state 8
|
|
SEMICOLON shift and go to state 9
|
|
|
|
|
|
state 44
|
|
|
|
(19) B -> B EQOP B .
|
|
(19) B -> B . EQOP B
|
|
(20) B -> B . LOP B
|
|
|
|
THEN reduce using rule 19 (B -> B EQOP B .)
|
|
EQOP reduce using rule 19 (B -> B EQOP B .)
|
|
LOP reduce using rule 19 (B -> B EQOP B .)
|
|
DO reduce using rule 19 (B -> B EQOP B .)
|
|
RPAREN reduce using rule 19 (B -> B EQOP B .)
|
|
|
|
! EQOP [ shift and go to state 31 ]
|
|
! LOP [ shift and go to state 32 ]
|
|
|
|
|
|
state 45
|
|
|
|
(20) B -> B LOP B .
|
|
(19) B -> B . EQOP B
|
|
(20) B -> B . LOP B
|
|
|
|
! shift/reduce conflict for EQOP resolved as shift
|
|
! shift/reduce conflict for LOP resolved as shift
|
|
THEN reduce using rule 20 (B -> B LOP B .)
|
|
DO reduce using rule 20 (B -> B LOP B .)
|
|
RPAREN reduce using rule 20 (B -> B LOP B .)
|
|
EQOP shift and go to state 31
|
|
LOP shift and go to state 32
|
|
|
|
! EQOP [ reduce using rule 20 (B -> B LOP B .) ]
|
|
! LOP [ reduce using rule 20 (B -> B LOP B .) ]
|
|
|
|
|
|
state 46
|
|
|
|
(17) B -> E EQOP E .
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
THEN reduce using rule 17 (B -> E EQOP E .)
|
|
EQOP reduce using rule 17 (B -> E EQOP E .)
|
|
LOP reduce using rule 17 (B -> E EQOP E .)
|
|
DO reduce using rule 17 (B -> E EQOP E .)
|
|
RPAREN reduce using rule 17 (B -> E EQOP E .)
|
|
AOP shift and go to state 8
|
|
SEMICOLON shift and go to state 9
|
|
|
|
|
|
state 47
|
|
|
|
(18) B -> E COMP E .
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
THEN reduce using rule 18 (B -> E COMP E .)
|
|
EQOP reduce using rule 18 (B -> E COMP E .)
|
|
LOP reduce using rule 18 (B -> E COMP E .)
|
|
DO reduce using rule 18 (B -> E COMP E .)
|
|
RPAREN reduce using rule 18 (B -> E COMP E .)
|
|
AOP shift and go to state 8
|
|
SEMICOLON shift and go to state 9
|
|
|
|
|
|
state 48
|
|
|
|
(23) B -> LPAREN B RPAREN .
|
|
|
|
THEN reduce using rule 23 (B -> LPAREN B RPAREN .)
|
|
EQOP reduce using rule 23 (B -> LPAREN B RPAREN .)
|
|
LOP reduce using rule 23 (B -> LPAREN B RPAREN .)
|
|
DO reduce using rule 23 (B -> LPAREN B RPAREN .)
|
|
RPAREN reduce using rule 23 (B -> LPAREN B RPAREN .)
|
|
|
|
|
|
state 49
|
|
|
|
(10) E -> WHILE B DO LBRACE . E RBRACE
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
LPAREN shift and go to state 4
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
E shift and go to state 54
|
|
|
|
state 50
|
|
|
|
(13) D -> ID LPAREN V RPAREN . LBRACE E RBRACE
|
|
|
|
LBRACE shift and go to state 55
|
|
|
|
|
|
state 51
|
|
|
|
(16) V -> V COMMA . ID
|
|
|
|
ID shift and go to state 56
|
|
|
|
|
|
state 52
|
|
|
|
(12) A -> A COMMA E .
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
RPAREN reduce using rule 12 (A -> A COMMA E .)
|
|
COMMA reduce using rule 12 (A -> A COMMA E .)
|
|
AOP shift and go to state 8
|
|
SEMICOLON shift and go to state 9
|
|
|
|
|
|
state 53
|
|
|
|
(9) E -> IF B THEN E ELSE . E
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
LPAREN shift and go to state 4
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
E shift and go to state 57
|
|
|
|
state 54
|
|
|
|
(10) E -> WHILE B DO LBRACE E . RBRACE
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
RBRACE shift and go to state 58
|
|
AOP shift and go to state 8
|
|
SEMICOLON shift and go to state 9
|
|
|
|
|
|
state 55
|
|
|
|
(13) D -> ID LPAREN V RPAREN LBRACE . E RBRACE
|
|
(1) E -> . LET D IN E
|
|
(2) E -> . ID
|
|
(3) E -> . ID LPAREN A RPAREN
|
|
(4) E -> . E AOP E
|
|
(5) E -> . LPAREN E RPAREN
|
|
(6) E -> . CONST
|
|
(7) E -> . ID ASSIGN E
|
|
(8) E -> . E SEMICOLON E
|
|
(9) E -> . IF B THEN E ELSE E
|
|
(10) E -> . WHILE B DO LBRACE E RBRACE
|
|
|
|
LET shift and go to state 2
|
|
ID shift and go to state 3
|
|
LPAREN shift and go to state 4
|
|
CONST shift and go to state 5
|
|
IF shift and go to state 6
|
|
WHILE shift and go to state 7
|
|
|
|
E shift and go to state 59
|
|
|
|
state 56
|
|
|
|
(16) V -> V COMMA ID .
|
|
|
|
RPAREN reduce using rule 16 (V -> V COMMA ID .)
|
|
COMMA reduce using rule 16 (V -> V COMMA ID .)
|
|
|
|
|
|
state 57
|
|
|
|
(9) E -> IF B THEN E ELSE E .
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
! shift/reduce conflict for AOP resolved as shift
|
|
! shift/reduce conflict for SEMICOLON resolved as shift
|
|
$end reduce using rule 9 (E -> IF B THEN E ELSE E .)
|
|
RPAREN reduce using rule 9 (E -> IF B THEN E ELSE E .)
|
|
EQOP reduce using rule 9 (E -> IF B THEN E ELSE E .)
|
|
COMP reduce using rule 9 (E -> IF B THEN E ELSE E .)
|
|
COMMA reduce using rule 9 (E -> IF B THEN E ELSE E .)
|
|
ELSE reduce using rule 9 (E -> IF B THEN E ELSE E .)
|
|
THEN reduce using rule 9 (E -> IF B THEN E ELSE E .)
|
|
LOP reduce using rule 9 (E -> IF B THEN E ELSE E .)
|
|
DO reduce using rule 9 (E -> IF B THEN E ELSE E .)
|
|
RBRACE reduce using rule 9 (E -> IF B THEN E ELSE E .)
|
|
AOP shift and go to state 8
|
|
SEMICOLON shift and go to state 9
|
|
|
|
! AOP [ reduce using rule 9 (E -> IF B THEN E ELSE E .) ]
|
|
! SEMICOLON [ reduce using rule 9 (E -> IF B THEN E ELSE E .) ]
|
|
|
|
|
|
state 58
|
|
|
|
(10) E -> WHILE B DO LBRACE E RBRACE .
|
|
|
|
AOP reduce using rule 10 (E -> WHILE B DO LBRACE E RBRACE .)
|
|
SEMICOLON reduce using rule 10 (E -> WHILE B DO LBRACE E RBRACE .)
|
|
$end reduce using rule 10 (E -> WHILE B DO LBRACE E RBRACE .)
|
|
RPAREN reduce using rule 10 (E -> WHILE B DO LBRACE E RBRACE .)
|
|
EQOP reduce using rule 10 (E -> WHILE B DO LBRACE E RBRACE .)
|
|
COMP reduce using rule 10 (E -> WHILE B DO LBRACE E RBRACE .)
|
|
COMMA reduce using rule 10 (E -> WHILE B DO LBRACE E RBRACE .)
|
|
ELSE reduce using rule 10 (E -> WHILE B DO LBRACE E RBRACE .)
|
|
THEN reduce using rule 10 (E -> WHILE B DO LBRACE E RBRACE .)
|
|
LOP reduce using rule 10 (E -> WHILE B DO LBRACE E RBRACE .)
|
|
DO reduce using rule 10 (E -> WHILE B DO LBRACE E RBRACE .)
|
|
RBRACE reduce using rule 10 (E -> WHILE B DO LBRACE E RBRACE .)
|
|
|
|
|
|
state 59
|
|
|
|
(13) D -> ID LPAREN V RPAREN LBRACE E . RBRACE
|
|
(4) E -> E . AOP E
|
|
(8) E -> E . SEMICOLON E
|
|
|
|
RBRACE shift and go to state 60
|
|
AOP shift and go to state 8
|
|
SEMICOLON shift and go to state 9
|
|
|
|
|
|
state 60
|
|
|
|
(13) D -> ID LPAREN V RPAREN LBRACE E RBRACE .
|
|
|
|
IN reduce using rule 13 (D -> ID LPAREN V RPAREN LBRACE E RBRACE .)
|
|
ID reduce using rule 13 (D -> ID LPAREN V RPAREN LBRACE E RBRACE .)
|
|
|
|
WARNING:
|
|
WARNING: Conflicts:
|
|
WARNING:
|
|
WARNING: shift/reduce conflict for AOP in state 22 resolved as shift
|
|
WARNING: shift/reduce conflict for SEMICOLON in state 22 resolved as shift
|
|
WARNING: shift/reduce conflict for ID in state 23 resolved as shift
|
|
WARNING: shift/reduce conflict for AOP in state 28 resolved as shift
|
|
WARNING: shift/reduce conflict for SEMICOLON in state 28 resolved as shift
|
|
WARNING: shift/reduce conflict for AOP in state 38 resolved as shift
|
|
WARNING: shift/reduce conflict for SEMICOLON in state 38 resolved as shift
|
|
WARNING: shift/reduce conflict for EQOP in state 45 resolved as shift
|
|
WARNING: shift/reduce conflict for LOP in state 45 resolved as shift
|
|
WARNING: shift/reduce conflict for AOP in state 57 resolved as shift
|
|
WARNING: shift/reduce conflict for SEMICOLON in state 57 resolved as shift
|