325 lines
8.8 KiB
Plaintext
325 lines
8.8 KiB
Plaintext
Created by PLY version 3.11 (http://www.dabeaz.com/ply)
|
|
|
|
Unused terminals:
|
|
|
|
ASSIGN
|
|
And
|
|
COMMA
|
|
DIVIDEASSIGN
|
|
DO
|
|
ELSE
|
|
FOR
|
|
GETKEY
|
|
GOTO
|
|
ID
|
|
IF
|
|
IFEND
|
|
ISEQUAL
|
|
LBL
|
|
LCURBRA
|
|
LIST
|
|
LOCATE
|
|
LPWHILE
|
|
LSQRBRA
|
|
MAT
|
|
MINUSASSIGN
|
|
MODULO
|
|
MODULOASSIGN
|
|
NEWLINE
|
|
NEXT
|
|
NOT
|
|
OR
|
|
PLUSASSIGN
|
|
RCURBRA
|
|
RSQRBRA
|
|
STEP
|
|
STR
|
|
STRING
|
|
THEN
|
|
TIMESASSIGN
|
|
TO
|
|
WHILE
|
|
WHILEEND
|
|
|
|
Grammar
|
|
|
|
Rule 0 S' -> expression
|
|
Rule 1 expression -> expression PLUS term
|
|
Rule 2 expression -> expression MINUS term
|
|
Rule 3 expression -> term
|
|
Rule 4 term -> term TIMES factor
|
|
Rule 5 term -> term DIVIDE factor
|
|
Rule 6 term -> factor
|
|
Rule 7 factor -> NUMBER
|
|
Rule 8 factor -> LPAREN expression RPAREN
|
|
|
|
Terminals, with rules where they appear
|
|
|
|
ASSIGN :
|
|
And :
|
|
COMMA :
|
|
DIVIDE : 5
|
|
DIVIDEASSIGN :
|
|
DO :
|
|
ELSE :
|
|
FOR :
|
|
GETKEY :
|
|
GOTO :
|
|
ID :
|
|
IF :
|
|
IFEND :
|
|
ISEQUAL :
|
|
LBL :
|
|
LCURBRA :
|
|
LIST :
|
|
LOCATE :
|
|
LPAREN : 8
|
|
LPWHILE :
|
|
LSQRBRA :
|
|
MAT :
|
|
MINUS : 2
|
|
MINUSASSIGN :
|
|
MODULO :
|
|
MODULOASSIGN :
|
|
NEWLINE :
|
|
NEXT :
|
|
NOT :
|
|
NUMBER : 7
|
|
OR :
|
|
PLUS : 1
|
|
PLUSASSIGN :
|
|
RCURBRA :
|
|
RPAREN : 8
|
|
RSQRBRA :
|
|
STEP :
|
|
STR :
|
|
STRING :
|
|
THEN :
|
|
TIMES : 4
|
|
TIMESASSIGN :
|
|
TO :
|
|
WHILE :
|
|
WHILEEND :
|
|
error :
|
|
|
|
Nonterminals, with rules where they appear
|
|
|
|
expression : 1 2 8 0
|
|
factor : 4 5 6
|
|
term : 1 2 3 4 5
|
|
|
|
Parsing method: LALR
|
|
|
|
state 0
|
|
|
|
(0) S' -> . expression
|
|
(1) expression -> . expression PLUS term
|
|
(2) expression -> . expression MINUS term
|
|
(3) expression -> . term
|
|
(4) term -> . term TIMES factor
|
|
(5) term -> . term DIVIDE factor
|
|
(6) term -> . factor
|
|
(7) factor -> . NUMBER
|
|
(8) factor -> . LPAREN expression RPAREN
|
|
|
|
NUMBER shift and go to state 4
|
|
LPAREN shift and go to state 5
|
|
|
|
expression shift and go to state 1
|
|
term shift and go to state 2
|
|
factor shift and go to state 3
|
|
|
|
state 1
|
|
|
|
(0) S' -> expression .
|
|
(1) expression -> expression . PLUS term
|
|
(2) expression -> expression . MINUS term
|
|
|
|
PLUS shift and go to state 6
|
|
MINUS shift and go to state 7
|
|
|
|
|
|
state 2
|
|
|
|
(3) expression -> term .
|
|
(4) term -> term . TIMES factor
|
|
(5) term -> term . DIVIDE factor
|
|
|
|
PLUS reduce using rule 3 (expression -> term .)
|
|
MINUS reduce using rule 3 (expression -> term .)
|
|
$end reduce using rule 3 (expression -> term .)
|
|
RPAREN reduce using rule 3 (expression -> term .)
|
|
TIMES shift and go to state 8
|
|
DIVIDE shift and go to state 9
|
|
|
|
|
|
state 3
|
|
|
|
(6) term -> factor .
|
|
|
|
TIMES reduce using rule 6 (term -> factor .)
|
|
DIVIDE reduce using rule 6 (term -> factor .)
|
|
PLUS reduce using rule 6 (term -> factor .)
|
|
MINUS reduce using rule 6 (term -> factor .)
|
|
$end reduce using rule 6 (term -> factor .)
|
|
RPAREN reduce using rule 6 (term -> factor .)
|
|
|
|
|
|
state 4
|
|
|
|
(7) factor -> NUMBER .
|
|
|
|
TIMES reduce using rule 7 (factor -> NUMBER .)
|
|
DIVIDE reduce using rule 7 (factor -> NUMBER .)
|
|
PLUS reduce using rule 7 (factor -> NUMBER .)
|
|
MINUS reduce using rule 7 (factor -> NUMBER .)
|
|
$end reduce using rule 7 (factor -> NUMBER .)
|
|
RPAREN reduce using rule 7 (factor -> NUMBER .)
|
|
|
|
|
|
state 5
|
|
|
|
(8) factor -> LPAREN . expression RPAREN
|
|
(1) expression -> . expression PLUS term
|
|
(2) expression -> . expression MINUS term
|
|
(3) expression -> . term
|
|
(4) term -> . term TIMES factor
|
|
(5) term -> . term DIVIDE factor
|
|
(6) term -> . factor
|
|
(7) factor -> . NUMBER
|
|
(8) factor -> . LPAREN expression RPAREN
|
|
|
|
NUMBER shift and go to state 4
|
|
LPAREN shift and go to state 5
|
|
|
|
expression shift and go to state 10
|
|
term shift and go to state 2
|
|
factor shift and go to state 3
|
|
|
|
state 6
|
|
|
|
(1) expression -> expression PLUS . term
|
|
(4) term -> . term TIMES factor
|
|
(5) term -> . term DIVIDE factor
|
|
(6) term -> . factor
|
|
(7) factor -> . NUMBER
|
|
(8) factor -> . LPAREN expression RPAREN
|
|
|
|
NUMBER shift and go to state 4
|
|
LPAREN shift and go to state 5
|
|
|
|
term shift and go to state 11
|
|
factor shift and go to state 3
|
|
|
|
state 7
|
|
|
|
(2) expression -> expression MINUS . term
|
|
(4) term -> . term TIMES factor
|
|
(5) term -> . term DIVIDE factor
|
|
(6) term -> . factor
|
|
(7) factor -> . NUMBER
|
|
(8) factor -> . LPAREN expression RPAREN
|
|
|
|
NUMBER shift and go to state 4
|
|
LPAREN shift and go to state 5
|
|
|
|
term shift and go to state 12
|
|
factor shift and go to state 3
|
|
|
|
state 8
|
|
|
|
(4) term -> term TIMES . factor
|
|
(7) factor -> . NUMBER
|
|
(8) factor -> . LPAREN expression RPAREN
|
|
|
|
NUMBER shift and go to state 4
|
|
LPAREN shift and go to state 5
|
|
|
|
factor shift and go to state 13
|
|
|
|
state 9
|
|
|
|
(5) term -> term DIVIDE . factor
|
|
(7) factor -> . NUMBER
|
|
(8) factor -> . LPAREN expression RPAREN
|
|
|
|
NUMBER shift and go to state 4
|
|
LPAREN shift and go to state 5
|
|
|
|
factor shift and go to state 14
|
|
|
|
state 10
|
|
|
|
(8) factor -> LPAREN expression . RPAREN
|
|
(1) expression -> expression . PLUS term
|
|
(2) expression -> expression . MINUS term
|
|
|
|
RPAREN shift and go to state 15
|
|
PLUS shift and go to state 6
|
|
MINUS shift and go to state 7
|
|
|
|
|
|
state 11
|
|
|
|
(1) expression -> expression PLUS term .
|
|
(4) term -> term . TIMES factor
|
|
(5) term -> term . DIVIDE factor
|
|
|
|
PLUS reduce using rule 1 (expression -> expression PLUS term .)
|
|
MINUS reduce using rule 1 (expression -> expression PLUS term .)
|
|
$end reduce using rule 1 (expression -> expression PLUS term .)
|
|
RPAREN reduce using rule 1 (expression -> expression PLUS term .)
|
|
TIMES shift and go to state 8
|
|
DIVIDE shift and go to state 9
|
|
|
|
|
|
state 12
|
|
|
|
(2) expression -> expression MINUS term .
|
|
(4) term -> term . TIMES factor
|
|
(5) term -> term . DIVIDE factor
|
|
|
|
PLUS reduce using rule 2 (expression -> expression MINUS term .)
|
|
MINUS reduce using rule 2 (expression -> expression MINUS term .)
|
|
$end reduce using rule 2 (expression -> expression MINUS term .)
|
|
RPAREN reduce using rule 2 (expression -> expression MINUS term .)
|
|
TIMES shift and go to state 8
|
|
DIVIDE shift and go to state 9
|
|
|
|
|
|
state 13
|
|
|
|
(4) term -> term TIMES factor .
|
|
|
|
TIMES reduce using rule 4 (term -> term TIMES factor .)
|
|
DIVIDE reduce using rule 4 (term -> term TIMES factor .)
|
|
PLUS reduce using rule 4 (term -> term TIMES factor .)
|
|
MINUS reduce using rule 4 (term -> term TIMES factor .)
|
|
$end reduce using rule 4 (term -> term TIMES factor .)
|
|
RPAREN reduce using rule 4 (term -> term TIMES factor .)
|
|
|
|
|
|
state 14
|
|
|
|
(5) term -> term DIVIDE factor .
|
|
|
|
TIMES reduce using rule 5 (term -> term DIVIDE factor .)
|
|
DIVIDE reduce using rule 5 (term -> term DIVIDE factor .)
|
|
PLUS reduce using rule 5 (term -> term DIVIDE factor .)
|
|
MINUS reduce using rule 5 (term -> term DIVIDE factor .)
|
|
$end reduce using rule 5 (term -> term DIVIDE factor .)
|
|
RPAREN reduce using rule 5 (term -> term DIVIDE factor .)
|
|
|
|
|
|
state 15
|
|
|
|
(8) factor -> LPAREN expression RPAREN .
|
|
|
|
TIMES reduce using rule 8 (factor -> LPAREN expression RPAREN .)
|
|
DIVIDE reduce using rule 8 (factor -> LPAREN expression RPAREN .)
|
|
PLUS reduce using rule 8 (factor -> LPAREN expression RPAREN .)
|
|
MINUS reduce using rule 8 (factor -> LPAREN expression RPAREN .)
|
|
$end reduce using rule 8 (factor -> LPAREN expression RPAREN .)
|
|
RPAREN reduce using rule 8 (factor -> LPAREN expression RPAREN .)
|
|
|