Added translation actions for do statements with counters, updated the test2.fort file to use this feature

This commit is contained in:
Mariano Uvalle 2019-04-22 16:02:27 -05:00
parent 5755fd5582
commit 8495205cd9
5 changed files with 429 additions and 249 deletions

View file

@ -268,7 +268,7 @@ def p_S(p):
| read RDimensional | read RDimensional
| print RDimOrString | print RDimOrString
| if action_16 Relif ElseOrEmpty end if action_20 | if action_16 Relif ElseOrEmpty end if action_20
| do id equals EA coma EA IntOrEmpty then B end do | do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do
| do then action_21 B action_22 end do | do then action_21 B action_22 end do
| swap Dimensional coma Dimensional | swap Dimensional coma Dimensional
| exit action_23 | exit action_23
@ -335,8 +335,8 @@ def p_ElseOrEmpty(p):
def p_IntOrEmpty(p): def p_IntOrEmpty(p):
''' '''
IntOrEmpty : coma int IntOrEmpty : coma int action_28
| | action_27
''' '''
@ -700,6 +700,100 @@ def p_action_23(p):
quadrupletIndex += 1 quadrupletIndex += 1
def p_action_24(p):
"action_24 :"
if p[-1] not in symbols:
raise Exception(f'The variable {p[-1]} was not declared')
direction = symbols[p[-1]]['direction']
sType = symbols[p[-1]]['type']
operandsStack.append(f'${direction}')
operandsStack.append(f'${direction}')
operandsStack.append(f'${direction}')
typesStack.append(sType)
typesStack.append(sType)
typesStack.append(sType)
def p_action_25(p):
"action_25 :"
global quadrupletIndex
global avail
operand2 = operandsStack.pop()
operand1 = operandsStack.pop()
type2 = typesStack.pop()
type1 = typesStack.pop()
# Result type only gets called to make sure the types are compatible.
resultingType('=', type1, type2)
resultQuadruplets.append('= ' + str(operand2) +
' ' + str(operand1) + '\n')
quadrupletIndex += 1
# Return the operand to the availbale if it is a temporal.
if (isTemp(operand2)):
avail = [operand2] + avail
def p_action_26(p):
"action_26 :"
global quadrupletIndex
global avail
operand2 = operandsStack.pop()
operand1 = operandsStack.pop()
type2 = typesStack.pop()
type1 = typesStack.pop()
# call function just to make sure types are compatible
resultingType('<=', type1, type2)
temp = avail.pop(0)
# push to the jumps stack so the program can return to this quadruplet after each cycle.
jumpsStack.append(quadrupletIndex)
resultQuadruplets.append(
'<=' + ' ' + str(operand1) + ' ' + str(operand2) + ' ' + str(temp) + '\n')
quadrupletIndex += 1
# push to the jumps stack so this gotoF can be filled later.
jumpsStack.append(quadrupletIndex)
resultQuadruplets.append(f'gotoF {str(temp)} _\n')
quadrupletIndex += 1
if (isTemp(operand2)):
avail = [operand2] + avail
if (isTemp(operand1)):
avail = [operand1] + avail
def p_action_27(p):
"action_27 :"
operandsStack.append("1")
typesStack.append("integer")
def p_action_28(p):
"action_28 :"
operandsStack.append(p[-1])
typesStack.append("integer")
def p_action_29(p):
"action_29 :"
global quadrupletIndex
global avail
incrementOperand = operandsStack.pop()
counterOperand = operandsStack.pop()
incrementType = typesStack.pop()
counterType = typesStack.pop()
temp = avail.pop(0)
# function call just to make sure that the types are compatible
resultingType('+', counterType, incrementType)
resultQuadruplets.append(f'+ {counterOperand} {incrementOperand} {temp}\n')
quadrupletIndex += 1
resultQuadruplets.append(f'= {temp} {counterOperand}\n')
quadrupletIndex += 1
# return the temp used to the avail vector
avail = [temp] + avail
gotoFPosition = jumpsStack.pop()
conditionPosition = jumpsStack.pop()
resultQuadruplets.append(f'goto {conditionPosition}\n')
quadrupletIndex += 1
fillGoto(gotoFPosition, quadrupletIndex)
def p_error(p): def p_error(p):
print('XXX Invalid program') print('XXX Invalid program')
print(p) print(p)

View file

@ -22,7 +22,7 @@ Rule 16 S -> id parens
Rule 17 S -> read RDimensional Rule 17 S -> read RDimensional
Rule 18 S -> print RDimOrString Rule 18 S -> print RDimOrString
Rule 19 S -> if action_16 Relif ElseOrEmpty end if action_20 Rule 19 S -> if action_16 Relif ElseOrEmpty end if action_20
Rule 20 S -> do id equals EA coma EA IntOrEmpty then B end do Rule 20 S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do
Rule 21 S -> do then action_21 B action_22 end do Rule 21 S -> do then action_21 B action_22 end do
Rule 22 S -> swap Dimensional coma Dimensional Rule 22 S -> swap Dimensional coma Dimensional
Rule 23 S -> exit action_23 Rule 23 S -> exit action_23
@ -41,8 +41,8 @@ Rule 35 Relif -> openParen EL closedParen action_17 then B
Rule 36 Relif -> Relif elif action_18 openParen EL closedParen action_17 then B Rule 36 Relif -> Relif elif action_18 openParen EL closedParen action_17 then B
Rule 37 ElseOrEmpty -> else action_19 B Rule 37 ElseOrEmpty -> else action_19 B
Rule 38 ElseOrEmpty -> <empty> Rule 38 ElseOrEmpty -> <empty>
Rule 39 IntOrEmpty -> coma int Rule 39 IntOrEmpty -> coma int action_28
Rule 40 IntOrEmpty -> <empty> Rule 40 IntOrEmpty -> action_27
Rule 41 EA -> MultDiv Rule 41 EA -> MultDiv
Rule 42 EA -> EA SumOrSub action_3 MultDiv action_4 Rule 42 EA -> EA SumOrSub action_3 MultDiv action_4
Rule 43 SumOrSub -> plus Rule 43 SumOrSub -> plus
@ -93,6 +93,12 @@ Rule 87 action_20 -> <empty>
Rule 88 action_21 -> <empty> Rule 88 action_21 -> <empty>
Rule 89 action_22 -> <empty> Rule 89 action_22 -> <empty>
Rule 90 action_23 -> <empty> Rule 90 action_23 -> <empty>
Rule 91 action_24 -> <empty>
Rule 92 action_25 -> <empty>
Rule 93 action_26 -> <empty>
Rule 94 action_27 -> <empty>
Rule 95 action_28 -> <empty>
Rule 96 action_29 -> <empty>
Terminals, with rules where they appear Terminals, with rules where they appear
@ -181,6 +187,12 @@ action_20 : 19
action_21 : 21 action_21 : 21
action_22 : 21 action_22 : 21
action_23 : 23 action_23 : 23
action_24 : 20
action_25 : 20
action_26 : 20
action_27 : 40
action_28 : 39
action_29 : 20
action_2_rea : 60 action_2_rea : 60
action_3 : 42 action_3 : 42
action_4 : 42 action_4 : 42
@ -315,7 +327,7 @@ state 9
(17) S -> . read RDimensional (17) S -> . read RDimensional
(18) S -> . print RDimOrString (18) S -> . print RDimOrString
(19) S -> . if action_16 Relif ElseOrEmpty end if action_20 (19) S -> . if action_16 Relif ElseOrEmpty end if action_20
(20) S -> . do id equals EA coma EA IntOrEmpty then B end do (20) S -> . do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do
(21) S -> . do then action_21 B action_22 end do (21) S -> . do then action_21 B action_22 end do
(22) S -> . swap Dimensional coma Dimensional (22) S -> . swap Dimensional coma Dimensional
(23) S -> . exit action_23 (23) S -> . exit action_23
@ -439,7 +451,7 @@ state 19
state 20 state 20
(20) S -> do . id equals EA coma EA IntOrEmpty then B end do (20) S -> do . id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do
(21) S -> do . then action_21 B action_22 end do (21) S -> do . then action_21 B action_22 end do
id shift and go to state 39 id shift and go to state 39
@ -746,10 +758,12 @@ state 38
state 39 state 39
(20) S -> do id . equals EA coma EA IntOrEmpty then B end do (20) S -> do id . action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do
(91) action_24 -> .
equals shift and go to state 60 equals reduce using rule 91 (action_24 -> .)
action_24 shift and go to state 60
state 40 state 40
@ -799,7 +813,7 @@ state 43
(17) S -> . read RDimensional (17) S -> . read RDimensional
(18) S -> . print RDimOrString (18) S -> . print RDimOrString
(19) S -> . if action_16 Relif ElseOrEmpty end if action_20 (19) S -> . if action_16 Relif ElseOrEmpty end if action_20
(20) S -> . do id equals EA coma EA IntOrEmpty then B end do (20) S -> . do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do
(21) S -> . do then action_21 B action_22 end do (21) S -> . do then action_21 B action_22 end do
(22) S -> . swap Dimensional coma Dimensional (22) S -> . swap Dimensional coma Dimensional
(23) S -> . exit action_23 (23) S -> . exit action_23
@ -1166,28 +1180,10 @@ state 59
state 60 state 60
(20) S -> do id equals . EA coma EA IntOrEmpty then B end do (20) S -> do id action_24 . equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do
(41) EA -> . MultDiv
(42) EA -> . EA SumOrSub action_3 MultDiv action_4
(45) MultDiv -> . EAParens
(46) MultDiv -> . MultDiv MDSymbols action_5 EAParens action_6
(49) EAParens -> . EItem
(50) EAParens -> . openParen EA closedParen
(58) EItem -> . Dimensional action_1
(59) EItem -> . int action_2
(60) EItem -> . rea action_2_rea
(24) Dimensional -> . id DimensionsOrEmpty
openParen shift and go to state 47 equals shift and go to state 90
int shift and go to state 53
rea shift and go to state 54
id shift and go to state 33
EA shift and go to state 90
MultDiv shift and go to state 49
EAParens shift and go to state 50
EItem shift and go to state 51
Dimensional shift and go to state 52
state 61 state 61
@ -1634,16 +1630,28 @@ state 89
state 90 state 90
(20) S -> do id equals EA . coma EA IntOrEmpty then B end do (20) S -> do id action_24 equals . EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do
(42) EA -> EA . SumOrSub action_3 MultDiv action_4 (41) EA -> . MultDiv
(43) SumOrSub -> . plus (42) EA -> . EA SumOrSub action_3 MultDiv action_4
(44) SumOrSub -> . minus (45) MultDiv -> . EAParens
(46) MultDiv -> . MultDiv MDSymbols action_5 EAParens action_6
(49) EAParens -> . EItem
(50) EAParens -> . openParen EA closedParen
(58) EItem -> . Dimensional action_1
(59) EItem -> . int action_2
(60) EItem -> . rea action_2_rea
(24) Dimensional -> . id DimensionsOrEmpty
coma shift and go to state 117 openParen shift and go to state 47
plus shift and go to state 70 int shift and go to state 53
minus shift and go to state 71 rea shift and go to state 54
id shift and go to state 33
SumOrSub shift and go to state 68 EA shift and go to state 117
MultDiv shift and go to state 49
EAParens shift and go to state 50
EItem shift and go to state 51
Dimensional shift and go to state 52
state 91 state 91
@ -1655,7 +1663,7 @@ state 91
(17) S -> . read RDimensional (17) S -> . read RDimensional
(18) S -> . print RDimOrString (18) S -> . print RDimOrString
(19) S -> . if action_16 Relif ElseOrEmpty end if action_20 (19) S -> . if action_16 Relif ElseOrEmpty end if action_20
(20) S -> . do id equals EA coma EA IntOrEmpty then B end do (20) S -> . do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do
(21) S -> . do then action_21 B action_22 end do (21) S -> . do then action_21 B action_22 end do
(22) S -> . swap Dimensional coma Dimensional (22) S -> . swap Dimensional coma Dimensional
(23) S -> . exit action_23 (23) S -> . exit action_23
@ -2012,28 +2020,18 @@ state 116
state 117 state 117
(20) S -> do id equals EA coma . EA IntOrEmpty then B end do (20) S -> do id action_24 equals EA . action_25 coma EA action_26 IntOrEmpty then B action_29 end do
(41) EA -> . MultDiv (42) EA -> EA . SumOrSub action_3 MultDiv action_4
(42) EA -> . EA SumOrSub action_3 MultDiv action_4 (92) action_25 -> .
(45) MultDiv -> . EAParens (43) SumOrSub -> . plus
(46) MultDiv -> . MultDiv MDSymbols action_5 EAParens action_6 (44) SumOrSub -> . minus
(49) EAParens -> . EItem
(50) EAParens -> . openParen EA closedParen
(58) EItem -> . Dimensional action_1
(59) EItem -> . int action_2
(60) EItem -> . rea action_2_rea
(24) Dimensional -> . id DimensionsOrEmpty
openParen shift and go to state 47 coma reduce using rule 92 (action_25 -> .)
int shift and go to state 53 plus shift and go to state 70
rea shift and go to state 54 minus shift and go to state 71
id shift and go to state 33
EA shift and go to state 131 action_25 shift and go to state 131
MultDiv shift and go to state 49 SumOrSub shift and go to state 68
EAParens shift and go to state 50
EItem shift and go to state 51
Dimensional shift and go to state 52
state 118 state 118
@ -2157,7 +2155,7 @@ state 124
(17) S -> . read RDimensional (17) S -> . read RDimensional
(18) S -> . print RDimOrString (18) S -> . print RDimOrString
(19) S -> . if action_16 Relif ElseOrEmpty end if action_20 (19) S -> . if action_16 Relif ElseOrEmpty end if action_20
(20) S -> . do id equals EA coma EA IntOrEmpty then B end do (20) S -> . do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do
(21) S -> . do then action_21 B action_22 end do (21) S -> . do then action_21 B action_22 end do
(22) S -> . swap Dimensional coma Dimensional (22) S -> . swap Dimensional coma Dimensional
(23) S -> . exit action_23 (23) S -> . exit action_23
@ -2262,26 +2260,16 @@ state 130
state 131 state 131
(20) S -> do id equals EA coma EA . IntOrEmpty then B end do (20) S -> do id action_24 equals EA action_25 . coma EA action_26 IntOrEmpty then B action_29 end do
(42) EA -> EA . SumOrSub action_3 MultDiv action_4
(39) IntOrEmpty -> . coma int
(40) IntOrEmpty -> .
(43) SumOrSub -> . plus
(44) SumOrSub -> . minus
coma shift and go to state 141 coma shift and go to state 141
then reduce using rule 40 (IntOrEmpty -> .)
plus shift and go to state 70
minus shift and go to state 71
IntOrEmpty shift and go to state 142
SumOrSub shift and go to state 68
state 132 state 132
(21) S -> do then action_21 B action_22 end . do (21) S -> do then action_21 B action_22 end . do
do shift and go to state 143 do shift and go to state 142
state 133 state 133
@ -2349,7 +2337,7 @@ state 136
(36) Relif -> Relif elif action_18 openParen EL . closedParen action_17 then B (36) Relif -> Relif elif action_18 openParen EL . closedParen action_17 then B
(52) EL -> EL . or action_10 AND action_9 (52) EL -> EL . or action_10 AND action_9
closedParen shift and go to state 144 closedParen shift and go to state 143
or shift and go to state 107 or shift and go to state 107
@ -2370,7 +2358,7 @@ state 137
else reduce using rule 14 (B -> .) else reduce using rule 14 (B -> .)
end reduce using rule 14 (B -> .) end reduce using rule 14 (B -> .)
B shift and go to state 145 B shift and go to state 144
state 138 state 138
@ -2385,7 +2373,7 @@ state 138
! and [ reduce using rule 76 (action_9 -> .) ] ! and [ reduce using rule 76 (action_9 -> .) ]
action_9 shift and go to state 146 action_9 shift and go to state 145
state 139 state 139
@ -2396,7 +2384,7 @@ state 139
closedParen reduce using rule 78 (action_11 -> .) closedParen reduce using rule 78 (action_11 -> .)
or reduce using rule 78 (action_11 -> .) or reduce using rule 78 (action_11 -> .)
action_11 shift and go to state 147 action_11 shift and go to state 146
state 140 state 140
@ -2407,24 +2395,35 @@ state 140
closedParen reduce using rule 81 (action_14 -> .) closedParen reduce using rule 81 (action_14 -> .)
or reduce using rule 81 (action_14 -> .) or reduce using rule 81 (action_14 -> .)
action_14 shift and go to state 148 action_14 shift and go to state 147
state 141 state 141
(39) IntOrEmpty -> coma . int (20) S -> do id action_24 equals EA action_25 coma . EA action_26 IntOrEmpty then B action_29 end do
(41) EA -> . MultDiv
(42) EA -> . EA SumOrSub action_3 MultDiv action_4
(45) MultDiv -> . EAParens
(46) MultDiv -> . MultDiv MDSymbols action_5 EAParens action_6
(49) EAParens -> . EItem
(50) EAParens -> . openParen EA closedParen
(58) EItem -> . Dimensional action_1
(59) EItem -> . int action_2
(60) EItem -> . rea action_2_rea
(24) Dimensional -> . id DimensionsOrEmpty
int shift and go to state 149 openParen shift and go to state 47
int shift and go to state 53
rea shift and go to state 54
id shift and go to state 33
EA shift and go to state 148
MultDiv shift and go to state 49
EAParens shift and go to state 50
EItem shift and go to state 51
Dimensional shift and go to state 52
state 142 state 142
(20) S -> do id equals EA coma EA IntOrEmpty . then B end do
then shift and go to state 150
state 143
(21) S -> do then action_21 B action_22 end do . (21) S -> do then action_21 B action_22 end do .
end reduce using rule 21 (S -> do then action_21 B action_22 end do .) end reduce using rule 21 (S -> do then action_21 B action_22 end do .)
@ -2439,16 +2438,16 @@ state 143
else reduce using rule 21 (S -> do then action_21 B action_22 end do .) else reduce using rule 21 (S -> do then action_21 B action_22 end do .)
state 144 state 143
(36) Relif -> Relif elif action_18 openParen EL closedParen . action_17 then B (36) Relif -> Relif elif action_18 openParen EL closedParen . action_17 then B
(84) action_17 -> . (84) action_17 -> .
then reduce using rule 84 (action_17 -> .) then reduce using rule 84 (action_17 -> .)
action_17 shift and go to state 151 action_17 shift and go to state 149
state 145 state 144
(35) Relif -> openParen EL closedParen action_17 then B . (35) Relif -> openParen EL closedParen action_17 then B .
(13) B -> B . S (13) B -> B . S
@ -2457,7 +2456,7 @@ state 145
(17) S -> . read RDimensional (17) S -> . read RDimensional
(18) S -> . print RDimOrString (18) S -> . print RDimOrString
(19) S -> . if action_16 Relif ElseOrEmpty end if action_20 (19) S -> . if action_16 Relif ElseOrEmpty end if action_20
(20) S -> . do id equals EA coma EA IntOrEmpty then B end do (20) S -> . do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do
(21) S -> . do then action_21 B action_22 end do (21) S -> . do then action_21 B action_22 end do
(22) S -> . swap Dimensional coma Dimensional (22) S -> . swap Dimensional coma Dimensional
(23) S -> . exit action_23 (23) S -> . exit action_23
@ -2477,7 +2476,7 @@ state 145
S shift and go to state 15 S shift and go to state 15
Dimensional shift and go to state 16 Dimensional shift and go to state 16
state 146 state 145
(52) EL -> EL or action_10 AND action_9 . (52) EL -> EL or action_10 AND action_9 .
@ -2486,7 +2485,7 @@ state 146
and reduce using rule 52 (EL -> EL or action_10 AND action_9 .) and reduce using rule 52 (EL -> EL or action_10 AND action_9 .)
state 147 state 146
(54) AND -> AND and action_12 Equality action_11 . (54) AND -> AND and action_12 Equality action_11 .
@ -2495,7 +2494,7 @@ state 147
or reduce using rule 54 (AND -> AND and action_12 Equality action_11 .) or reduce using rule 54 (AND -> AND and action_12 Equality action_11 .)
state 148 state 147
(55) Equality -> EItem EQSymbols action_13 EItem action_14 . (55) Equality -> EItem EQSymbols action_13 EItem action_14 .
@ -2504,66 +2503,44 @@ state 148
or reduce using rule 55 (Equality -> EItem EQSymbols action_13 EItem action_14 .) or reduce using rule 55 (Equality -> EItem EQSymbols action_13 EItem action_14 .)
state 148
(20) S -> do id action_24 equals EA action_25 coma EA . action_26 IntOrEmpty then B action_29 end do
(42) EA -> EA . SumOrSub action_3 MultDiv action_4
(93) action_26 -> .
(43) SumOrSub -> . plus
(44) SumOrSub -> . minus
coma reduce using rule 93 (action_26 -> .)
then reduce using rule 93 (action_26 -> .)
plus shift and go to state 70
minus shift and go to state 71
action_26 shift and go to state 150
SumOrSub shift and go to state 68
state 149 state 149
(39) IntOrEmpty -> coma int . (36) Relif -> Relif elif action_18 openParen EL closedParen action_17 . then B
then reduce using rule 39 (IntOrEmpty -> coma int .) then shift and go to state 151
state 150 state 150
(20) S -> do id equals EA coma EA IntOrEmpty then . B end do (20) S -> do id action_24 equals EA action_25 coma EA action_26 . IntOrEmpty then B action_29 end do
(13) B -> . B S (39) IntOrEmpty -> . coma int action_28
(14) B -> . (40) IntOrEmpty -> . action_27
(94) action_27 -> .
end reduce using rule 14 (B -> .) coma shift and go to state 152
id reduce using rule 14 (B -> .) then reduce using rule 94 (action_27 -> .)
read reduce using rule 14 (B -> .)
print reduce using rule 14 (B -> .)
if reduce using rule 14 (B -> .)
do reduce using rule 14 (B -> .)
swap reduce using rule 14 (B -> .)
exit reduce using rule 14 (B -> .)
B shift and go to state 152 IntOrEmpty shift and go to state 153
action_27 shift and go to state 154
state 151 state 151
(36) Relif -> Relif elif action_18 openParen EL closedParen action_17 . then B
then shift and go to state 153
state 152
(20) S -> do id equals EA coma EA IntOrEmpty then B . end do
(13) B -> B . S
(15) S -> . Dimensional action_7 equals EA action_8
(16) S -> . id parens
(17) S -> . read RDimensional
(18) S -> . print RDimOrString
(19) S -> . if action_16 Relif ElseOrEmpty end if action_20
(20) S -> . do id equals EA coma EA IntOrEmpty then B end do
(21) S -> . do then action_21 B action_22 end do
(22) S -> . swap Dimensional coma Dimensional
(23) S -> . exit action_23
(24) Dimensional -> . id DimensionsOrEmpty
end shift and go to state 154
id shift and go to state 13
read shift and go to state 17
print shift and go to state 18
if shift and go to state 19
do shift and go to state 20
swap shift and go to state 21
exit shift and go to state 22
S shift and go to state 15
Dimensional shift and go to state 16
state 153
(36) Relif -> Relif elif action_18 openParen EL closedParen action_17 then . B (36) Relif -> Relif elif action_18 openParen EL closedParen action_17 then . B
(13) B -> . B S (13) B -> . B S
(14) B -> . (14) B -> .
@ -2581,11 +2558,25 @@ state 153
B shift and go to state 155 B shift and go to state 155
state 152
(39) IntOrEmpty -> coma . int action_28
int shift and go to state 156
state 153
(20) S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty . then B action_29 end do
then shift and go to state 157
state 154 state 154
(20) S -> do id equals EA coma EA IntOrEmpty then B end . do (40) IntOrEmpty -> action_27 .
do shift and go to state 156 then reduce using rule 40 (IntOrEmpty -> action_27 .)
state 155 state 155
@ -2597,7 +2588,7 @@ state 155
(17) S -> . read RDimensional (17) S -> . read RDimensional
(18) S -> . print RDimOrString (18) S -> . print RDimOrString
(19) S -> . if action_16 Relif ElseOrEmpty end if action_20 (19) S -> . if action_16 Relif ElseOrEmpty end if action_20
(20) S -> . do id equals EA coma EA IntOrEmpty then B end do (20) S -> . do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do
(21) S -> . do then action_21 B action_22 end do (21) S -> . do then action_21 B action_22 end do
(22) S -> . swap Dimensional coma Dimensional (22) S -> . swap Dimensional coma Dimensional
(23) S -> . exit action_23 (23) S -> . exit action_23
@ -2619,18 +2610,94 @@ state 155
state 156 state 156
(20) S -> do id equals EA coma EA IntOrEmpty then B end do . (39) IntOrEmpty -> coma int . action_28
(95) action_28 -> .
end reduce using rule 20 (S -> do id equals EA coma EA IntOrEmpty then B end do .) then reduce using rule 95 (action_28 -> .)
id reduce using rule 20 (S -> do id equals EA coma EA IntOrEmpty then B end do .)
read reduce using rule 20 (S -> do id equals EA coma EA IntOrEmpty then B end do .) action_28 shift and go to state 158
print reduce using rule 20 (S -> do id equals EA coma EA IntOrEmpty then B end do .)
if reduce using rule 20 (S -> do id equals EA coma EA IntOrEmpty then B end do .) state 157
do reduce using rule 20 (S -> do id equals EA coma EA IntOrEmpty then B end do .)
swap reduce using rule 20 (S -> do id equals EA coma EA IntOrEmpty then B end do .) (20) S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then . B action_29 end do
exit reduce using rule 20 (S -> do id equals EA coma EA IntOrEmpty then B end do .) (13) B -> . B S
elif reduce using rule 20 (S -> do id equals EA coma EA IntOrEmpty then B end do .) (14) B -> .
else reduce using rule 20 (S -> do id equals EA coma EA IntOrEmpty then B end do .)
id reduce using rule 14 (B -> .)
read reduce using rule 14 (B -> .)
print reduce using rule 14 (B -> .)
if reduce using rule 14 (B -> .)
do reduce using rule 14 (B -> .)
swap reduce using rule 14 (B -> .)
exit reduce using rule 14 (B -> .)
end reduce using rule 14 (B -> .)
B shift and go to state 159
state 158
(39) IntOrEmpty -> coma int action_28 .
then reduce using rule 39 (IntOrEmpty -> coma int action_28 .)
state 159
(20) S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B . action_29 end do
(13) B -> B . S
(96) action_29 -> .
(15) S -> . Dimensional action_7 equals EA action_8
(16) S -> . id parens
(17) S -> . read RDimensional
(18) S -> . print RDimOrString
(19) S -> . if action_16 Relif ElseOrEmpty end if action_20
(20) S -> . do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do
(21) S -> . do then action_21 B action_22 end do
(22) S -> . swap Dimensional coma Dimensional
(23) S -> . exit action_23
(24) Dimensional -> . id DimensionsOrEmpty
end reduce using rule 96 (action_29 -> .)
id shift and go to state 13
read shift and go to state 17
print shift and go to state 18
if shift and go to state 19
do shift and go to state 20
swap shift and go to state 21
exit shift and go to state 22
action_29 shift and go to state 160
S shift and go to state 15
Dimensional shift and go to state 16
state 160
(20) S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 . end do
end shift and go to state 161
state 161
(20) S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end . do
do shift and go to state 162
state 162
(20) S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do .
end reduce using rule 20 (S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do .)
id reduce using rule 20 (S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do .)
read reduce using rule 20 (S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do .)
print reduce using rule 20 (S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do .)
if reduce using rule 20 (S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do .)
do reduce using rule 20 (S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do .)
swap reduce using rule 20 (S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do .)
exit reduce using rule 20 (S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do .)
elif reduce using rule 20 (S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do .)
else reduce using rule 20 (S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do .)
WARNING: WARNING:
WARNING: Conflicts: WARNING: Conflicts:

File diff suppressed because one or more lines are too long

View file

@ -18,4 +18,8 @@ do then
end if end if
a = a + 1 a = a + 1
end do end do
b = 0
do a = b + 1, 10, 2 then
b = a
end do
end program end program

View file

@ -26,3 +26,12 @@ goto 29
+ $50 1 $2 + $50 1 $2
= $2 $50 = $2 $50
goto 21 goto 21
= 0 $51
+ $51 1 $2
= $2 $50
<= $50 10 $2
gotoF $2 38
= $50 $51
+ $50 2 $0
= $0 $50
goto 32