diff --git a/final_lang/fort.py b/final_lang/fort.py index 4fdcb54..04e0a2f 100644 --- a/final_lang/fort.py +++ b/final_lang/fort.py @@ -1,15 +1,39 @@ import ply.lex as lex import ply.yacc as yacc import sys +from stack import Stack + +resultQuadruplets = [] +quadrupletIndex = 1 + +# Auxiliary stacks. +operandsStack = [] +operatorsStack = [] +jumpsStack = [] +auxStack = [] +avail = [] +for i in range(50): + avail.append('T' + str(i)) # Operations related to the table of symbols symbolsNames = [] symbolsTypes = [] +symbols = {} -def addSymbol(name, symbolType): - symbolsNames.append(name) - symbolsTypes.append(symbolType) +# # Implementation using lists. +# def addSymbol(name, symbolType): +# symbolsNames.append(name) +# symbolsTypes.append(symbolType) + +# Implementation using a dictionary +def addSymbol(name, symbolsTypes): + initialValue = 0 if symbolsTypes == 'integer' else 0.0 + symbols[name] = [name, initialValue] +def peek(list): + if (len(list) == 0): + return None + return list[len(list) - 1] tokens = [ 'doubleColon', @@ -189,10 +213,13 @@ def p_S(p): | exit ''' +# Adjust the action to support matrices def p_Dimensional(p): ''' Dimensional : id DimensionsOrEmpty ''' + p[0] = p[1] + def p_DimensionsOrEmpty(p): ''' @@ -245,19 +272,21 @@ def p_IntOrEmpty(p): def p_EA(p): ''' EA : MultDiv - | EA SumOrSub MultDiv + | EA SumOrSub action_3 MultDiv action_4 ''' + def p_SumOrSub(p): ''' SumOrSub : plus | minus ''' + p[0] = p[1] def p_MultDiv(p): ''' MultDiv : EAParens - | MultDiv MDSymbols EAParens + | MultDiv MDSymbols action_5 EAParens action_6 ''' def p_MDSymbols(p): @@ -265,6 +294,7 @@ def p_MDSymbols(p): MDSymbols : mul | div ''' + p[0] = p[1] def p_EAParens(p): ''' @@ -293,9 +323,9 @@ def p_Equality(p): def p_EItem(p): ''' - EItem : Dimensional - | int - | rea + EItem : Dimensional action_1 + | int action_2 + | rea action_2 ''' def p_EQSymbols(p): @@ -308,6 +338,51 @@ def p_EQSymbols(p): | moreEquals ''' + +def p_action_1(p): + "action_1 :" + operandsStack.append(p[-1]) + + +def p_action_2(p): + "action_2 :" + operandsStack.append(p[-1]) + +def p_action_3(p): + "action_3 :" + operatorsStack.append(p[-1]) + +def p_action_4(p): + "action_4 :" + if (peek(operatorsStack) == '+' or peek(operatorsStack) == '-'): + global quadrupletIndex + operator = operatorsStack.pop() + operand2 = operandsStack.pop() + operand1 = operandsStack.pop() + temp = avail.pop(0) + operandsStack.append(temp) + resultQuadruplets.append(str(operator) + ' ' + str(operand1) + ' ' + str(operand2) + ' ' + str(temp) + '\n') + quadrupletIndex += 1 + + +def p_action_5(p): + "action_5 :" + operatorsStack.append(p[-1]) + + +def p_action_6(p): + "action_6 :" + if (peek(operatorsStack) == '*' or peek(operatorsStack) == '/'): + global quadrupletIndex + operator = operatorsStack.pop() + operand2 = operandsStack.pop() + operand1 = operandsStack.pop() + temp = avail.pop(0) + operandsStack.append(temp) + resultQuadruplets.append(str(operator) + ' ' + str(operand1) + ' ' + str(operand2) + ' ' + str(temp) + '\n') + quadrupletIndex += 1 + + def p_error(p): print('XXX Invalid program') print(p) @@ -317,11 +392,18 @@ parser = yacc.yacc() if (len(sys.argv) > 1): programName = sys.argv[1] programFile = open(programName, "r") + resultFile = open(programName + '.out', "w+") # This is neccessary because the read method parses literal ends # of lines as \\n instead of \n. program = programFile.read().replace('\\n', '\n') parser.parse(program) + + print(resultQuadruplets) + resultFile.writelines(resultQuadruplets) + + # Close the files. programFile.close() + resultFile.close() else: raise Exception(''' No file name was provided. diff --git a/final_lang/parser.out b/final_lang/parser.out index fe8884f..f8fb348 100644 --- a/final_lang/parser.out +++ b/final_lang/parser.out @@ -44,11 +44,11 @@ Rule 38 ElseOrEmpty -> Rule 39 IntOrEmpty -> coma int Rule 40 IntOrEmpty -> Rule 41 EA -> MultDiv -Rule 42 EA -> EA SumOrSub MultDiv +Rule 42 EA -> EA SumOrSub action_3 MultDiv action_4 Rule 43 SumOrSub -> plus Rule 44 SumOrSub -> minus Rule 45 MultDiv -> EAParens -Rule 46 MultDiv -> MultDiv MDSymbols EAParens +Rule 46 MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 Rule 47 MDSymbols -> mul Rule 48 MDSymbols -> div Rule 49 EAParens -> EItem @@ -60,15 +60,21 @@ Rule 54 AND -> AND and Equality Rule 55 Equality -> EItem EQSymbols EItem Rule 56 Equality -> openParen EL closedParen Rule 57 Equality -> not EL -Rule 58 EItem -> Dimensional -Rule 59 EItem -> int -Rule 60 EItem -> rea +Rule 58 EItem -> Dimensional action_1 +Rule 59 EItem -> int action_2 +Rule 60 EItem -> rea action_2 Rule 61 EQSymbols -> less Rule 62 EQSymbols -> more Rule 63 EQSymbols -> doubleEquals Rule 64 EQSymbols -> notEquals Rule 65 EQSymbols -> lessEquals Rule 66 EQSymbols -> moreEquals +Rule 67 action_1 -> +Rule 68 action_2 -> +Rule 69 action_3 -> +Rule 70 action_4 -> +Rule 71 action_5 -> +Rule 72 action_6 -> Terminals, with rules where they appear @@ -141,6 +147,12 @@ S : 13 SumOrSub : 42 Tipo : 2 V : 1 2 +action_1 : 58 +action_2 : 59 60 +action_3 : 42 +action_4 : 42 +action_5 : 46 +action_6 : 46 programa : 0 Parsing method: LALR @@ -500,23 +512,23 @@ state 27 notEquals reduce using rule 24 (Dimensional -> id DimensionsOrEmpty .) lessEquals reduce using rule 24 (Dimensional -> id DimensionsOrEmpty .) moreEquals reduce using rule 24 (Dimensional -> id DimensionsOrEmpty .) - then reduce using rule 24 (Dimensional -> id DimensionsOrEmpty .) and reduce using rule 24 (Dimensional -> id DimensionsOrEmpty .) or reduce using rule 24 (Dimensional -> id DimensionsOrEmpty .) + then reduce using rule 24 (Dimensional -> id DimensionsOrEmpty .) state 28 (25) DimensionsOrEmpty -> openParen . EA ComaEAOrEmpty closedParen (41) EA -> . MultDiv - (42) EA -> . EA SumOrSub MultDiv + (42) EA -> . EA SumOrSub action_3 MultDiv action_4 (45) MultDiv -> . EAParens - (46) MultDiv -> . MultDiv MDSymbols EAParens + (46) MultDiv -> . MultDiv MDSymbols action_5 EAParens action_6 (49) EAParens -> . EItem (50) EAParens -> . openParen EA closedParen - (58) EItem -> . Dimensional - (59) EItem -> . int - (60) EItem -> . rea + (58) EItem -> . Dimensional action_1 + (59) EItem -> . int action_2 + (60) EItem -> . rea action_2 (24) Dimensional -> . id DimensionsOrEmpty openParen shift and go to state 47 @@ -541,14 +553,14 @@ state 30 (15) S -> Dimensional equals . EA (41) EA -> . MultDiv - (42) EA -> . EA SumOrSub MultDiv + (42) EA -> . EA SumOrSub action_3 MultDiv action_4 (45) MultDiv -> . EAParens - (46) MultDiv -> . MultDiv MDSymbols EAParens + (46) MultDiv -> . MultDiv MDSymbols action_5 EAParens action_6 (49) EAParens -> . EItem (50) EAParens -> . openParen EA closedParen - (58) EItem -> . Dimensional - (59) EItem -> . int - (60) EItem -> . rea + (58) EItem -> . Dimensional action_1 + (59) EItem -> . int action_2 + (60) EItem -> . rea action_2 (24) Dimensional -> . id DimensionsOrEmpty openParen shift and go to state 47 @@ -626,9 +638,9 @@ state 33 notEquals reduce using rule 26 (DimensionsOrEmpty -> .) lessEquals reduce using rule 26 (DimensionsOrEmpty -> .) moreEquals reduce using rule 26 (DimensionsOrEmpty -> .) - then reduce using rule 26 (DimensionsOrEmpty -> .) and reduce using rule 26 (DimensionsOrEmpty -> .) or reduce using rule 26 (DimensionsOrEmpty -> .) + then reduce using rule 26 (DimensionsOrEmpty -> .) DimensionsOrEmpty shift and go to state 27 @@ -724,9 +736,9 @@ state 39 (55) Equality -> . EItem EQSymbols EItem (56) Equality -> . openParen EL closedParen (57) Equality -> . not EL - (58) EItem -> . Dimensional - (59) EItem -> . int - (60) EItem -> . rea + (58) EItem -> . Dimensional action_1 + (59) EItem -> . int action_2 + (60) EItem -> . rea action_2 (24) Dimensional -> . id DimensionsOrEmpty openParen shift and go to state 61 @@ -849,14 +861,14 @@ state 47 (50) EAParens -> openParen . EA closedParen (41) EA -> . MultDiv - (42) EA -> . EA SumOrSub MultDiv + (42) EA -> . EA SumOrSub action_3 MultDiv action_4 (45) MultDiv -> . EAParens - (46) MultDiv -> . MultDiv MDSymbols EAParens + (46) MultDiv -> . MultDiv MDSymbols action_5 EAParens action_6 (49) EAParens -> . EItem (50) EAParens -> . openParen EA closedParen - (58) EItem -> . Dimensional - (59) EItem -> . int - (60) EItem -> . rea + (58) EItem -> . Dimensional action_1 + (59) EItem -> . int action_2 + (60) EItem -> . rea action_2 (24) Dimensional -> . id DimensionsOrEmpty openParen shift and go to state 47 @@ -873,7 +885,7 @@ state 47 state 48 (25) DimensionsOrEmpty -> openParen EA . ComaEAOrEmpty closedParen - (42) EA -> EA . SumOrSub MultDiv + (42) EA -> EA . SumOrSub action_3 MultDiv action_4 (27) ComaEAOrEmpty -> . coma EA (28) ComaEAOrEmpty -> . (43) SumOrSub -> . plus @@ -890,7 +902,7 @@ state 48 state 49 (41) EA -> MultDiv . - (46) MultDiv -> MultDiv . MDSymbols EAParens + (46) MultDiv -> MultDiv . MDSymbols action_5 EAParens action_6 (47) MDSymbols -> . mul (48) MDSymbols -> . div @@ -962,101 +974,107 @@ state 51 state 52 - (58) EItem -> Dimensional . + (58) EItem -> Dimensional . action_1 + (67) action_1 -> . - mul reduce using rule 58 (EItem -> Dimensional .) - div reduce using rule 58 (EItem -> Dimensional .) - coma reduce using rule 58 (EItem -> Dimensional .) - plus reduce using rule 58 (EItem -> Dimensional .) - minus reduce using rule 58 (EItem -> Dimensional .) - closedParen reduce using rule 58 (EItem -> Dimensional .) - end reduce using rule 58 (EItem -> Dimensional .) - id reduce using rule 58 (EItem -> Dimensional .) - read reduce using rule 58 (EItem -> Dimensional .) - print reduce using rule 58 (EItem -> Dimensional .) - if reduce using rule 58 (EItem -> Dimensional .) - do reduce using rule 58 (EItem -> Dimensional .) - swap reduce using rule 58 (EItem -> Dimensional .) - exit reduce using rule 58 (EItem -> Dimensional .) - elif reduce using rule 58 (EItem -> Dimensional .) - else reduce using rule 58 (EItem -> Dimensional .) - less reduce using rule 58 (EItem -> Dimensional .) - more reduce using rule 58 (EItem -> Dimensional .) - doubleEquals reduce using rule 58 (EItem -> Dimensional .) - notEquals reduce using rule 58 (EItem -> Dimensional .) - lessEquals reduce using rule 58 (EItem -> Dimensional .) - moreEquals reduce using rule 58 (EItem -> Dimensional .) - then reduce using rule 58 (EItem -> Dimensional .) - and reduce using rule 58 (EItem -> Dimensional .) - or reduce using rule 58 (EItem -> Dimensional .) + mul reduce using rule 67 (action_1 -> .) + div reduce using rule 67 (action_1 -> .) + coma reduce using rule 67 (action_1 -> .) + plus reduce using rule 67 (action_1 -> .) + minus reduce using rule 67 (action_1 -> .) + closedParen reduce using rule 67 (action_1 -> .) + end reduce using rule 67 (action_1 -> .) + id reduce using rule 67 (action_1 -> .) + read reduce using rule 67 (action_1 -> .) + print reduce using rule 67 (action_1 -> .) + if reduce using rule 67 (action_1 -> .) + do reduce using rule 67 (action_1 -> .) + swap reduce using rule 67 (action_1 -> .) + exit reduce using rule 67 (action_1 -> .) + elif reduce using rule 67 (action_1 -> .) + else reduce using rule 67 (action_1 -> .) + less reduce using rule 67 (action_1 -> .) + more reduce using rule 67 (action_1 -> .) + doubleEquals reduce using rule 67 (action_1 -> .) + notEquals reduce using rule 67 (action_1 -> .) + lessEquals reduce using rule 67 (action_1 -> .) + moreEquals reduce using rule 67 (action_1 -> .) + and reduce using rule 67 (action_1 -> .) + or reduce using rule 67 (action_1 -> .) + then reduce using rule 67 (action_1 -> .) + action_1 shift and go to state 82 state 53 - (59) EItem -> int . + (59) EItem -> int . action_2 + (68) action_2 -> . - mul reduce using rule 59 (EItem -> int .) - div reduce using rule 59 (EItem -> int .) - coma reduce using rule 59 (EItem -> int .) - plus reduce using rule 59 (EItem -> int .) - minus reduce using rule 59 (EItem -> int .) - closedParen reduce using rule 59 (EItem -> int .) - end reduce using rule 59 (EItem -> int .) - id reduce using rule 59 (EItem -> int .) - read reduce using rule 59 (EItem -> int .) - print reduce using rule 59 (EItem -> int .) - if reduce using rule 59 (EItem -> int .) - do reduce using rule 59 (EItem -> int .) - swap reduce using rule 59 (EItem -> int .) - exit reduce using rule 59 (EItem -> int .) - elif reduce using rule 59 (EItem -> int .) - else reduce using rule 59 (EItem -> int .) - less reduce using rule 59 (EItem -> int .) - more reduce using rule 59 (EItem -> int .) - doubleEquals reduce using rule 59 (EItem -> int .) - notEquals reduce using rule 59 (EItem -> int .) - lessEquals reduce using rule 59 (EItem -> int .) - moreEquals reduce using rule 59 (EItem -> int .) - then reduce using rule 59 (EItem -> int .) - and reduce using rule 59 (EItem -> int .) - or reduce using rule 59 (EItem -> int .) + mul reduce using rule 68 (action_2 -> .) + div reduce using rule 68 (action_2 -> .) + coma reduce using rule 68 (action_2 -> .) + plus reduce using rule 68 (action_2 -> .) + minus reduce using rule 68 (action_2 -> .) + closedParen reduce using rule 68 (action_2 -> .) + end reduce using rule 68 (action_2 -> .) + id reduce using rule 68 (action_2 -> .) + read reduce using rule 68 (action_2 -> .) + print reduce using rule 68 (action_2 -> .) + if reduce using rule 68 (action_2 -> .) + do reduce using rule 68 (action_2 -> .) + swap reduce using rule 68 (action_2 -> .) + exit reduce using rule 68 (action_2 -> .) + elif reduce using rule 68 (action_2 -> .) + else reduce using rule 68 (action_2 -> .) + less reduce using rule 68 (action_2 -> .) + more reduce using rule 68 (action_2 -> .) + doubleEquals reduce using rule 68 (action_2 -> .) + notEquals reduce using rule 68 (action_2 -> .) + lessEquals reduce using rule 68 (action_2 -> .) + moreEquals reduce using rule 68 (action_2 -> .) + and reduce using rule 68 (action_2 -> .) + or reduce using rule 68 (action_2 -> .) + then reduce using rule 68 (action_2 -> .) + action_2 shift and go to state 83 state 54 - (60) EItem -> rea . + (60) EItem -> rea . action_2 + (68) action_2 -> . - mul reduce using rule 60 (EItem -> rea .) - div reduce using rule 60 (EItem -> rea .) - coma reduce using rule 60 (EItem -> rea .) - plus reduce using rule 60 (EItem -> rea .) - minus reduce using rule 60 (EItem -> rea .) - closedParen reduce using rule 60 (EItem -> rea .) - end reduce using rule 60 (EItem -> rea .) - id reduce using rule 60 (EItem -> rea .) - read reduce using rule 60 (EItem -> rea .) - print reduce using rule 60 (EItem -> rea .) - if reduce using rule 60 (EItem -> rea .) - do reduce using rule 60 (EItem -> rea .) - swap reduce using rule 60 (EItem -> rea .) - exit reduce using rule 60 (EItem -> rea .) - elif reduce using rule 60 (EItem -> rea .) - else reduce using rule 60 (EItem -> rea .) - less reduce using rule 60 (EItem -> rea .) - more reduce using rule 60 (EItem -> rea .) - doubleEquals reduce using rule 60 (EItem -> rea .) - notEquals reduce using rule 60 (EItem -> rea .) - lessEquals reduce using rule 60 (EItem -> rea .) - moreEquals reduce using rule 60 (EItem -> rea .) - then reduce using rule 60 (EItem -> rea .) - and reduce using rule 60 (EItem -> rea .) - or reduce using rule 60 (EItem -> rea .) + mul reduce using rule 68 (action_2 -> .) + div reduce using rule 68 (action_2 -> .) + coma reduce using rule 68 (action_2 -> .) + plus reduce using rule 68 (action_2 -> .) + minus reduce using rule 68 (action_2 -> .) + closedParen reduce using rule 68 (action_2 -> .) + end reduce using rule 68 (action_2 -> .) + id reduce using rule 68 (action_2 -> .) + read reduce using rule 68 (action_2 -> .) + print reduce using rule 68 (action_2 -> .) + if reduce using rule 68 (action_2 -> .) + do reduce using rule 68 (action_2 -> .) + swap reduce using rule 68 (action_2 -> .) + exit reduce using rule 68 (action_2 -> .) + elif reduce using rule 68 (action_2 -> .) + else reduce using rule 68 (action_2 -> .) + less reduce using rule 68 (action_2 -> .) + more reduce using rule 68 (action_2 -> .) + doubleEquals reduce using rule 68 (action_2 -> .) + notEquals reduce using rule 68 (action_2 -> .) + lessEquals reduce using rule 68 (action_2 -> .) + moreEquals reduce using rule 68 (action_2 -> .) + and reduce using rule 68 (action_2 -> .) + or reduce using rule 68 (action_2 -> .) + then reduce using rule 68 (action_2 -> .) + action_2 shift and go to state 84 state 55 (15) S -> Dimensional equals EA . - (42) EA -> EA . SumOrSub MultDiv + (42) EA -> EA . SumOrSub action_3 MultDiv action_4 (43) SumOrSub -> . plus (44) SumOrSub -> . minus @@ -1082,7 +1100,7 @@ state 56 id shift and go to state 33 - Dimensional shift and go to state 82 + Dimensional shift and go to state 85 state 57 @@ -1094,21 +1112,21 @@ state 57 string shift and go to state 37 id shift and go to state 33 - DimOrString shift and go to state 83 + DimOrString shift and go to state 86 Dimensional shift and go to state 36 state 58 (19) S -> if Relif ElseOrEmpty . end if - end shift and go to state 84 + end shift and go to state 87 state 59 (36) Relif -> Relif elif . openParen EL closedParen then B - openParen shift and go to state 85 + openParen shift and go to state 88 state 60 @@ -1126,7 +1144,7 @@ state 60 exit reduce using rule 14 (B -> .) end reduce using rule 14 (B -> .) - B shift and go to state 86 + B shift and go to state 89 state 61 @@ -1138,9 +1156,9 @@ state 61 (55) Equality -> . EItem EQSymbols EItem (56) Equality -> . openParen EL closedParen (57) Equality -> . not EL - (58) EItem -> . Dimensional - (59) EItem -> . int - (60) EItem -> . rea + (58) EItem -> . Dimensional action_1 + (59) EItem -> . int action_2 + (60) EItem -> . rea action_2 (24) Dimensional -> . id DimensionsOrEmpty openParen shift and go to state 61 @@ -1149,7 +1167,7 @@ state 61 rea shift and go to state 54 id shift and go to state 33 - EL shift and go to state 87 + EL shift and go to state 90 AND shift and go to state 63 Equality shift and go to state 64 EItem shift and go to state 65 @@ -1160,8 +1178,8 @@ state 62 (35) Relif -> openParen EL . closedParen then B (52) EL -> EL . or AND - closedParen shift and go to state 88 - or shift and go to state 89 + closedParen shift and go to state 91 + or shift and go to state 92 state 63 @@ -1172,7 +1190,7 @@ state 63 ! shift/reduce conflict for and resolved as shift closedParen reduce using rule 51 (EL -> AND .) or reduce using rule 51 (EL -> AND .) - and shift and go to state 90 + and shift and go to state 93 ! and [ reduce using rule 51 (EL -> AND .) ] @@ -1196,14 +1214,14 @@ state 65 (65) EQSymbols -> . lessEquals (66) EQSymbols -> . moreEquals - less shift and go to state 92 - more shift and go to state 93 - doubleEquals shift and go to state 94 - notEquals shift and go to state 95 - lessEquals shift and go to state 96 - moreEquals shift and go to state 97 + less shift and go to state 95 + more shift and go to state 96 + doubleEquals shift and go to state 97 + notEquals shift and go to state 98 + lessEquals shift and go to state 99 + moreEquals shift and go to state 100 - EQSymbols shift and go to state 91 + EQSymbols shift and go to state 94 state 66 @@ -1215,9 +1233,9 @@ state 66 (55) Equality -> . EItem EQSymbols EItem (56) Equality -> . openParen EL closedParen (57) Equality -> . not EL - (58) EItem -> . Dimensional - (59) EItem -> . int - (60) EItem -> . rea + (58) EItem -> . Dimensional action_1 + (59) EItem -> . int action_2 + (60) EItem -> . rea action_2 (24) Dimensional -> . id DimensionsOrEmpty openParen shift and go to state 61 @@ -1226,7 +1244,7 @@ state 66 rea shift and go to state 54 id shift and go to state 33 - EL shift and go to state 98 + EL shift and go to state 101 AND shift and go to state 63 Equality shift and go to state 64 EItem shift and go to state 65 @@ -1236,14 +1254,14 @@ state 67 (20) S -> do id equals . EA coma EA IntOrEmpty then B end do (41) EA -> . MultDiv - (42) EA -> . EA SumOrSub MultDiv + (42) EA -> . EA SumOrSub action_3 MultDiv action_4 (45) MultDiv -> . EAParens - (46) MultDiv -> . MultDiv MDSymbols EAParens + (46) MultDiv -> . MultDiv MDSymbols action_5 EAParens action_6 (49) EAParens -> . EItem (50) EAParens -> . openParen EA closedParen - (58) EItem -> . Dimensional - (59) EItem -> . int - (60) EItem -> . rea + (58) EItem -> . Dimensional action_1 + (59) EItem -> . int action_2 + (60) EItem -> . rea action_2 (24) Dimensional -> . id DimensionsOrEmpty openParen shift and go to state 47 @@ -1251,7 +1269,7 @@ state 67 rea shift and go to state 54 id shift and go to state 33 - EA shift and go to state 99 + EA shift and go to state 102 MultDiv shift and go to state 49 EAParens shift and go to state 50 EItem shift and go to state 51 @@ -1272,7 +1290,7 @@ state 68 (23) S -> . exit (24) Dimensional -> . id DimensionsOrEmpty - end shift and go to state 100 + end shift and go to state 103 id shift and go to state 13 read shift and go to state 17 print shift and go to state 18 @@ -1291,37 +1309,37 @@ state 69 id shift and go to state 33 - Dimensional shift and go to state 101 + Dimensional shift and go to state 104 state 70 (11) F -> F subroutine id B end . subroutine - subroutine shift and go to state 102 + subroutine shift and go to state 105 state 71 (5) Rid -> Rid coma . id - id shift and go to state 103 + id shift and go to state 106 state 72 (9) Dim -> openBra int closedBra openBra . int closedBra - int shift and go to state 104 + int shift and go to state 107 state 73 (50) EAParens -> openParen EA . closedParen - (42) EA -> EA . SumOrSub MultDiv + (42) EA -> EA . SumOrSub action_3 MultDiv action_4 (43) SumOrSub -> . plus (44) SumOrSub -> . minus - closedParen shift and go to state 105 + closedParen shift and go to state 108 plus shift and go to state 77 minus shift and go to state 78 @@ -1331,43 +1349,33 @@ state 74 (25) DimensionsOrEmpty -> openParen EA ComaEAOrEmpty . closedParen - closedParen shift and go to state 106 + closedParen shift and go to state 109 state 75 - (42) EA -> EA SumOrSub . MultDiv - (45) MultDiv -> . EAParens - (46) MultDiv -> . MultDiv MDSymbols EAParens - (49) EAParens -> . EItem - (50) EAParens -> . openParen EA closedParen - (58) EItem -> . Dimensional - (59) EItem -> . int - (60) EItem -> . rea - (24) Dimensional -> . id DimensionsOrEmpty + (42) EA -> EA SumOrSub . action_3 MultDiv action_4 + (69) action_3 -> . - 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 + openParen reduce using rule 69 (action_3 -> .) + int reduce using rule 69 (action_3 -> .) + rea reduce using rule 69 (action_3 -> .) + id reduce using rule 69 (action_3 -> .) - MultDiv shift and go to state 107 - EAParens shift and go to state 50 - EItem shift and go to state 51 - Dimensional shift and go to state 52 + action_3 shift and go to state 110 state 76 (27) ComaEAOrEmpty -> coma . EA (41) EA -> . MultDiv - (42) EA -> . EA SumOrSub MultDiv + (42) EA -> . EA SumOrSub action_3 MultDiv action_4 (45) MultDiv -> . EAParens - (46) MultDiv -> . MultDiv MDSymbols EAParens + (46) MultDiv -> . MultDiv MDSymbols action_5 EAParens action_6 (49) EAParens -> . EItem (50) EAParens -> . openParen EA closedParen - (58) EItem -> . Dimensional - (59) EItem -> . int - (60) EItem -> . rea + (58) EItem -> . Dimensional action_1 + (59) EItem -> . int action_2 + (60) EItem -> . rea action_2 (24) Dimensional -> . id DimensionsOrEmpty openParen shift and go to state 47 @@ -1375,7 +1383,7 @@ state 76 rea shift and go to state 54 id shift and go to state 33 - EA shift and go to state 108 + EA shift and go to state 111 MultDiv shift and go to state 49 EAParens shift and go to state 50 EItem shift and go to state 51 @@ -1403,22 +1411,15 @@ state 78 state 79 - (46) MultDiv -> MultDiv MDSymbols . EAParens - (49) EAParens -> . EItem - (50) EAParens -> . openParen EA closedParen - (58) EItem -> . Dimensional - (59) EItem -> . int - (60) EItem -> . rea - (24) Dimensional -> . id DimensionsOrEmpty + (46) MultDiv -> MultDiv MDSymbols . action_5 EAParens action_6 + (71) action_5 -> . - 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 + openParen reduce using rule 71 (action_5 -> .) + int reduce using rule 71 (action_5 -> .) + rea reduce using rule 71 (action_5 -> .) + id reduce using rule 71 (action_5 -> .) - EAParens shift and go to state 109 - EItem shift and go to state 51 - Dimensional shift and go to state 52 + action_5 shift and go to state 112 state 80 @@ -1442,6 +1443,99 @@ state 81 state 82 + (58) EItem -> Dimensional action_1 . + + mul reduce using rule 58 (EItem -> Dimensional action_1 .) + div reduce using rule 58 (EItem -> Dimensional action_1 .) + coma reduce using rule 58 (EItem -> Dimensional action_1 .) + plus reduce using rule 58 (EItem -> Dimensional action_1 .) + minus reduce using rule 58 (EItem -> Dimensional action_1 .) + closedParen reduce using rule 58 (EItem -> Dimensional action_1 .) + end reduce using rule 58 (EItem -> Dimensional action_1 .) + id reduce using rule 58 (EItem -> Dimensional action_1 .) + read reduce using rule 58 (EItem -> Dimensional action_1 .) + print reduce using rule 58 (EItem -> Dimensional action_1 .) + if reduce using rule 58 (EItem -> Dimensional action_1 .) + do reduce using rule 58 (EItem -> Dimensional action_1 .) + swap reduce using rule 58 (EItem -> Dimensional action_1 .) + exit reduce using rule 58 (EItem -> Dimensional action_1 .) + elif reduce using rule 58 (EItem -> Dimensional action_1 .) + else reduce using rule 58 (EItem -> Dimensional action_1 .) + less reduce using rule 58 (EItem -> Dimensional action_1 .) + more reduce using rule 58 (EItem -> Dimensional action_1 .) + doubleEquals reduce using rule 58 (EItem -> Dimensional action_1 .) + notEquals reduce using rule 58 (EItem -> Dimensional action_1 .) + lessEquals reduce using rule 58 (EItem -> Dimensional action_1 .) + moreEquals reduce using rule 58 (EItem -> Dimensional action_1 .) + and reduce using rule 58 (EItem -> Dimensional action_1 .) + or reduce using rule 58 (EItem -> Dimensional action_1 .) + then reduce using rule 58 (EItem -> Dimensional action_1 .) + + +state 83 + + (59) EItem -> int action_2 . + + mul reduce using rule 59 (EItem -> int action_2 .) + div reduce using rule 59 (EItem -> int action_2 .) + coma reduce using rule 59 (EItem -> int action_2 .) + plus reduce using rule 59 (EItem -> int action_2 .) + minus reduce using rule 59 (EItem -> int action_2 .) + closedParen reduce using rule 59 (EItem -> int action_2 .) + end reduce using rule 59 (EItem -> int action_2 .) + id reduce using rule 59 (EItem -> int action_2 .) + read reduce using rule 59 (EItem -> int action_2 .) + print reduce using rule 59 (EItem -> int action_2 .) + if reduce using rule 59 (EItem -> int action_2 .) + do reduce using rule 59 (EItem -> int action_2 .) + swap reduce using rule 59 (EItem -> int action_2 .) + exit reduce using rule 59 (EItem -> int action_2 .) + elif reduce using rule 59 (EItem -> int action_2 .) + else reduce using rule 59 (EItem -> int action_2 .) + less reduce using rule 59 (EItem -> int action_2 .) + more reduce using rule 59 (EItem -> int action_2 .) + doubleEquals reduce using rule 59 (EItem -> int action_2 .) + notEquals reduce using rule 59 (EItem -> int action_2 .) + lessEquals reduce using rule 59 (EItem -> int action_2 .) + moreEquals reduce using rule 59 (EItem -> int action_2 .) + and reduce using rule 59 (EItem -> int action_2 .) + or reduce using rule 59 (EItem -> int action_2 .) + then reduce using rule 59 (EItem -> int action_2 .) + + +state 84 + + (60) EItem -> rea action_2 . + + mul reduce using rule 60 (EItem -> rea action_2 .) + div reduce using rule 60 (EItem -> rea action_2 .) + coma reduce using rule 60 (EItem -> rea action_2 .) + plus reduce using rule 60 (EItem -> rea action_2 .) + minus reduce using rule 60 (EItem -> rea action_2 .) + closedParen reduce using rule 60 (EItem -> rea action_2 .) + end reduce using rule 60 (EItem -> rea action_2 .) + id reduce using rule 60 (EItem -> rea action_2 .) + read reduce using rule 60 (EItem -> rea action_2 .) + print reduce using rule 60 (EItem -> rea action_2 .) + if reduce using rule 60 (EItem -> rea action_2 .) + do reduce using rule 60 (EItem -> rea action_2 .) + swap reduce using rule 60 (EItem -> rea action_2 .) + exit reduce using rule 60 (EItem -> rea action_2 .) + elif reduce using rule 60 (EItem -> rea action_2 .) + else reduce using rule 60 (EItem -> rea action_2 .) + less reduce using rule 60 (EItem -> rea action_2 .) + more reduce using rule 60 (EItem -> rea action_2 .) + doubleEquals reduce using rule 60 (EItem -> rea action_2 .) + notEquals reduce using rule 60 (EItem -> rea action_2 .) + lessEquals reduce using rule 60 (EItem -> rea action_2 .) + moreEquals reduce using rule 60 (EItem -> rea action_2 .) + and reduce using rule 60 (EItem -> rea action_2 .) + or reduce using rule 60 (EItem -> rea action_2 .) + then reduce using rule 60 (EItem -> rea action_2 .) + + +state 85 + (30) RDimensional -> RDimensional coma Dimensional . coma reduce using rule 30 (RDimensional -> RDimensional coma Dimensional .) @@ -1457,7 +1551,7 @@ state 82 else reduce using rule 30 (RDimensional -> RDimensional coma Dimensional .) -state 83 +state 86 (32) RDimOrString -> RDimOrString coma DimOrString . @@ -1474,14 +1568,14 @@ state 83 else reduce using rule 32 (RDimOrString -> RDimOrString coma DimOrString .) -state 84 +state 87 (19) S -> if Relif ElseOrEmpty end . if - if shift and go to state 110 + if shift and go to state 113 -state 85 +state 88 (36) Relif -> Relif elif openParen . EL closedParen then B (51) EL -> . AND @@ -1491,9 +1585,9 @@ state 85 (55) Equality -> . EItem EQSymbols EItem (56) Equality -> . openParen EL closedParen (57) Equality -> . not EL - (58) EItem -> . Dimensional - (59) EItem -> . int - (60) EItem -> . rea + (58) EItem -> . Dimensional action_1 + (59) EItem -> . int action_2 + (60) EItem -> . rea action_2 (24) Dimensional -> . id DimensionsOrEmpty openParen shift and go to state 61 @@ -1502,13 +1596,13 @@ state 85 rea shift and go to state 54 id shift and go to state 33 - EL shift and go to state 111 + EL shift and go to state 114 AND shift and go to state 63 Equality shift and go to state 64 EItem shift and go to state 65 Dimensional shift and go to state 52 -state 86 +state 89 (37) ElseOrEmpty -> else B . (13) B -> B . S @@ -1535,23 +1629,23 @@ state 86 S shift and go to state 15 Dimensional shift and go to state 16 -state 87 +state 90 (56) Equality -> openParen EL . closedParen (52) EL -> EL . or AND - closedParen shift and go to state 112 - or shift and go to state 89 + closedParen shift and go to state 115 + or shift and go to state 92 -state 88 +state 91 (35) Relif -> openParen EL closedParen . then B - then shift and go to state 113 + then shift and go to state 116 -state 89 +state 92 (52) EL -> EL or . AND (53) AND -> . Equality @@ -1559,9 +1653,9 @@ state 89 (55) Equality -> . EItem EQSymbols EItem (56) Equality -> . openParen EL closedParen (57) Equality -> . not EL - (58) EItem -> . Dimensional - (59) EItem -> . int - (60) EItem -> . rea + (58) EItem -> . Dimensional action_1 + (59) EItem -> . int action_2 + (60) EItem -> . rea action_2 (24) Dimensional -> . id DimensionsOrEmpty openParen shift and go to state 61 @@ -1570,20 +1664,20 @@ state 89 rea shift and go to state 54 id shift and go to state 33 - AND shift and go to state 114 + AND shift and go to state 117 Equality shift and go to state 64 EItem shift and go to state 65 Dimensional shift and go to state 52 -state 90 +state 93 (54) AND -> AND and . Equality (55) Equality -> . EItem EQSymbols EItem (56) Equality -> . openParen EL closedParen (57) Equality -> . not EL - (58) EItem -> . Dimensional - (59) EItem -> . int - (60) EItem -> . rea + (58) EItem -> . Dimensional action_1 + (59) EItem -> . int action_2 + (60) EItem -> . rea action_2 (24) Dimensional -> . id DimensionsOrEmpty openParen shift and go to state 61 @@ -1592,26 +1686,26 @@ state 90 rea shift and go to state 54 id shift and go to state 33 - Equality shift and go to state 115 + Equality shift and go to state 118 EItem shift and go to state 65 Dimensional shift and go to state 52 -state 91 +state 94 (55) Equality -> EItem EQSymbols . EItem - (58) EItem -> . Dimensional - (59) EItem -> . int - (60) EItem -> . rea + (58) EItem -> . Dimensional action_1 + (59) EItem -> . int action_2 + (60) EItem -> . rea action_2 (24) Dimensional -> . id DimensionsOrEmpty int shift and go to state 53 rea shift and go to state 54 id shift and go to state 33 - EItem shift and go to state 116 + EItem shift and go to state 119 Dimensional shift and go to state 52 -state 92 +state 95 (61) EQSymbols -> less . @@ -1620,7 +1714,7 @@ state 92 id reduce using rule 61 (EQSymbols -> less .) -state 93 +state 96 (62) EQSymbols -> more . @@ -1629,7 +1723,7 @@ state 93 id reduce using rule 62 (EQSymbols -> more .) -state 94 +state 97 (63) EQSymbols -> doubleEquals . @@ -1638,7 +1732,7 @@ state 94 id reduce using rule 63 (EQSymbols -> doubleEquals .) -state 95 +state 98 (64) EQSymbols -> notEquals . @@ -1647,7 +1741,7 @@ state 95 id reduce using rule 64 (EQSymbols -> notEquals .) -state 96 +state 99 (65) EQSymbols -> lessEquals . @@ -1656,7 +1750,7 @@ state 96 id reduce using rule 65 (EQSymbols -> lessEquals .) -state 97 +state 100 (66) EQSymbols -> moreEquals . @@ -1665,7 +1759,7 @@ state 97 id reduce using rule 66 (EQSymbols -> moreEquals .) -state 98 +state 101 (57) Equality -> not EL . (52) EL -> EL . or AND @@ -1673,32 +1767,32 @@ state 98 ! shift/reduce conflict for or resolved as shift and reduce using rule 57 (Equality -> not EL .) closedParen reduce using rule 57 (Equality -> not EL .) - or shift and go to state 89 + or shift and go to state 92 ! or [ reduce using rule 57 (Equality -> not EL .) ] -state 99 +state 102 (20) S -> do id equals EA . coma EA IntOrEmpty then B end do - (42) EA -> EA . SumOrSub MultDiv + (42) EA -> EA . SumOrSub action_3 MultDiv action_4 (43) SumOrSub -> . plus (44) SumOrSub -> . minus - coma shift and go to state 117 + coma shift and go to state 120 plus shift and go to state 77 minus shift and go to state 78 SumOrSub shift and go to state 75 -state 100 +state 103 (21) S -> do then B end . do - do shift and go to state 118 + do shift and go to state 121 -state 101 +state 104 (22) S -> swap Dimensional coma Dimensional . @@ -1714,7 +1808,7 @@ state 101 else reduce using rule 22 (S -> swap Dimensional coma Dimensional .) -state 102 +state 105 (11) F -> F subroutine id B end subroutine . @@ -1729,7 +1823,7 @@ state 102 exit reduce using rule 11 (F -> F subroutine id B end subroutine .) -state 103 +state 106 (5) Rid -> Rid coma id . @@ -1747,14 +1841,14 @@ state 103 exit reduce using rule 5 (Rid -> Rid coma id .) -state 104 +state 107 (9) Dim -> openBra int closedBra openBra int . closedBra - closedBra shift and go to state 119 + closedBra shift and go to state 122 -state 105 +state 108 (50) EAParens -> openParen EA closedParen . @@ -1777,7 +1871,7 @@ state 105 then reduce using rule 50 (EAParens -> openParen EA closedParen .) -state 106 +state 109 (25) DimensionsOrEmpty -> openParen EA ComaEAOrEmpty closedParen . @@ -1804,42 +1898,37 @@ state 106 notEquals reduce using rule 25 (DimensionsOrEmpty -> openParen EA ComaEAOrEmpty closedParen .) lessEquals reduce using rule 25 (DimensionsOrEmpty -> openParen EA ComaEAOrEmpty closedParen .) moreEquals reduce using rule 25 (DimensionsOrEmpty -> openParen EA ComaEAOrEmpty closedParen .) - then reduce using rule 25 (DimensionsOrEmpty -> openParen EA ComaEAOrEmpty closedParen .) and reduce using rule 25 (DimensionsOrEmpty -> openParen EA ComaEAOrEmpty closedParen .) or reduce using rule 25 (DimensionsOrEmpty -> openParen EA ComaEAOrEmpty closedParen .) + then reduce using rule 25 (DimensionsOrEmpty -> openParen EA ComaEAOrEmpty closedParen .) -state 107 +state 110 - (42) EA -> EA SumOrSub MultDiv . - (46) MultDiv -> MultDiv . MDSymbols EAParens - (47) MDSymbols -> . mul - (48) MDSymbols -> . div + (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 + (24) Dimensional -> . id DimensionsOrEmpty - coma reduce using rule 42 (EA -> EA SumOrSub MultDiv .) - plus reduce using rule 42 (EA -> EA SumOrSub MultDiv .) - minus reduce using rule 42 (EA -> EA SumOrSub MultDiv .) - closedParen reduce using rule 42 (EA -> EA SumOrSub MultDiv .) - end reduce using rule 42 (EA -> EA SumOrSub MultDiv .) - id reduce using rule 42 (EA -> EA SumOrSub MultDiv .) - read reduce using rule 42 (EA -> EA SumOrSub MultDiv .) - print reduce using rule 42 (EA -> EA SumOrSub MultDiv .) - if reduce using rule 42 (EA -> EA SumOrSub MultDiv .) - do reduce using rule 42 (EA -> EA SumOrSub MultDiv .) - swap reduce using rule 42 (EA -> EA SumOrSub MultDiv .) - exit reduce using rule 42 (EA -> EA SumOrSub MultDiv .) - elif reduce using rule 42 (EA -> EA SumOrSub MultDiv .) - else reduce using rule 42 (EA -> EA SumOrSub MultDiv .) - then reduce using rule 42 (EA -> EA SumOrSub MultDiv .) - mul shift and go to state 80 - div shift and go to state 81 + 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 - MDSymbols shift and go to state 79 + MultDiv shift and go to state 123 + EAParens shift and go to state 50 + EItem shift and go to state 51 + Dimensional shift and go to state 52 -state 108 +state 111 (27) ComaEAOrEmpty -> coma EA . - (42) EA -> EA . SumOrSub MultDiv + (42) EA -> EA . SumOrSub action_3 MultDiv action_4 (43) SumOrSub -> . plus (44) SumOrSub -> . minus @@ -1849,30 +1938,26 @@ state 108 SumOrSub shift and go to state 75 -state 109 +state 112 - (46) MultDiv -> MultDiv MDSymbols 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 + (24) Dimensional -> . id DimensionsOrEmpty - mul reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - div reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - coma reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - plus reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - minus reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - closedParen reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - end reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - id reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - read reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - print reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - if reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - do reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - swap reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - exit reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - elif reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - else reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) - then reduce using rule 46 (MultDiv -> MultDiv MDSymbols EAParens .) + 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 + EAParens shift and go to state 124 + EItem shift and go to state 51 + Dimensional shift and go to state 52 -state 110 +state 113 (19) S -> if Relif ElseOrEmpty end if . @@ -1888,16 +1973,16 @@ state 110 else reduce using rule 19 (S -> if Relif ElseOrEmpty end if .) -state 111 +state 114 (36) Relif -> Relif elif openParen EL . closedParen then B (52) EL -> EL . or AND - closedParen shift and go to state 120 - or shift and go to state 89 + closedParen shift and go to state 125 + or shift and go to state 92 -state 112 +state 115 (56) Equality -> openParen EL closedParen . @@ -1906,7 +1991,7 @@ state 112 or reduce using rule 56 (Equality -> openParen EL closedParen .) -state 113 +state 116 (35) Relif -> openParen EL closedParen then . B (13) B -> . B S @@ -1923,9 +2008,9 @@ state 113 else reduce using rule 14 (B -> .) end reduce using rule 14 (B -> .) - B shift and go to state 121 + B shift and go to state 126 -state 114 +state 117 (52) EL -> EL or AND . (54) AND -> AND . and Equality @@ -1933,12 +2018,12 @@ state 114 ! shift/reduce conflict for and resolved as shift closedParen reduce using rule 52 (EL -> EL or AND .) or reduce using rule 52 (EL -> EL or AND .) - and shift and go to state 90 + and shift and go to state 93 ! and [ reduce using rule 52 (EL -> EL or AND .) ] -state 115 +state 118 (54) AND -> AND and Equality . @@ -1947,7 +2032,7 @@ state 115 or reduce using rule 54 (AND -> AND and Equality .) -state 116 +state 119 (55) Equality -> EItem EQSymbols EItem . @@ -1956,18 +2041,18 @@ state 116 or reduce using rule 55 (Equality -> EItem EQSymbols EItem .) -state 117 +state 120 (20) S -> do id equals EA coma . EA IntOrEmpty then B end do (41) EA -> . MultDiv - (42) EA -> . EA SumOrSub MultDiv + (42) EA -> . EA SumOrSub action_3 MultDiv action_4 (45) MultDiv -> . EAParens - (46) MultDiv -> . MultDiv MDSymbols EAParens + (46) MultDiv -> . MultDiv MDSymbols action_5 EAParens action_6 (49) EAParens -> . EItem (50) EAParens -> . openParen EA closedParen - (58) EItem -> . Dimensional - (59) EItem -> . int - (60) EItem -> . rea + (58) EItem -> . Dimensional action_1 + (59) EItem -> . int action_2 + (60) EItem -> . rea action_2 (24) Dimensional -> . id DimensionsOrEmpty openParen shift and go to state 47 @@ -1975,13 +2060,13 @@ state 117 rea shift and go to state 54 id shift and go to state 33 - EA shift and go to state 122 + EA shift and go to state 127 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 118 +state 121 (21) S -> do then B end do . @@ -1997,21 +2082,75 @@ state 118 else reduce using rule 21 (S -> do then B end do .) -state 119 +state 122 (9) Dim -> openBra int closedBra openBra int closedBra . doubleColon reduce using rule 9 (Dim -> openBra int closedBra openBra int closedBra .) -state 120 +state 123 + + (42) EA -> EA SumOrSub action_3 MultDiv . action_4 + (46) MultDiv -> MultDiv . MDSymbols action_5 EAParens action_6 + (70) action_4 -> . + (47) MDSymbols -> . mul + (48) MDSymbols -> . div + + coma reduce using rule 70 (action_4 -> .) + plus reduce using rule 70 (action_4 -> .) + minus reduce using rule 70 (action_4 -> .) + closedParen reduce using rule 70 (action_4 -> .) + end reduce using rule 70 (action_4 -> .) + id reduce using rule 70 (action_4 -> .) + read reduce using rule 70 (action_4 -> .) + print reduce using rule 70 (action_4 -> .) + if reduce using rule 70 (action_4 -> .) + do reduce using rule 70 (action_4 -> .) + swap reduce using rule 70 (action_4 -> .) + exit reduce using rule 70 (action_4 -> .) + elif reduce using rule 70 (action_4 -> .) + else reduce using rule 70 (action_4 -> .) + then reduce using rule 70 (action_4 -> .) + mul shift and go to state 80 + div shift and go to state 81 + + action_4 shift and go to state 128 + MDSymbols shift and go to state 79 + +state 124 + + (46) MultDiv -> MultDiv MDSymbols action_5 EAParens . action_6 + (72) action_6 -> . + + mul reduce using rule 72 (action_6 -> .) + div reduce using rule 72 (action_6 -> .) + coma reduce using rule 72 (action_6 -> .) + plus reduce using rule 72 (action_6 -> .) + minus reduce using rule 72 (action_6 -> .) + closedParen reduce using rule 72 (action_6 -> .) + end reduce using rule 72 (action_6 -> .) + id reduce using rule 72 (action_6 -> .) + read reduce using rule 72 (action_6 -> .) + print reduce using rule 72 (action_6 -> .) + if reduce using rule 72 (action_6 -> .) + do reduce using rule 72 (action_6 -> .) + swap reduce using rule 72 (action_6 -> .) + exit reduce using rule 72 (action_6 -> .) + elif reduce using rule 72 (action_6 -> .) + else reduce using rule 72 (action_6 -> .) + then reduce using rule 72 (action_6 -> .) + + action_6 shift and go to state 129 + +state 125 (36) Relif -> Relif elif openParen EL closedParen . then B - then shift and go to state 123 + then shift and go to state 130 -state 121 +state 126 (35) Relif -> openParen EL closedParen then B . (13) B -> B . S @@ -2040,24 +2179,68 @@ state 121 S shift and go to state 15 Dimensional shift and go to state 16 -state 122 +state 127 (20) S -> do id equals EA coma EA . IntOrEmpty then B end do - (42) EA -> EA . SumOrSub MultDiv + (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 124 + coma shift and go to state 131 then reduce using rule 40 (IntOrEmpty -> .) plus shift and go to state 77 minus shift and go to state 78 - IntOrEmpty shift and go to state 125 + IntOrEmpty shift and go to state 132 SumOrSub shift and go to state 75 -state 123 +state 128 + + (42) EA -> EA SumOrSub action_3 MultDiv action_4 . + + coma reduce using rule 42 (EA -> EA SumOrSub action_3 MultDiv action_4 .) + plus reduce using rule 42 (EA -> EA SumOrSub action_3 MultDiv action_4 .) + minus reduce using rule 42 (EA -> EA SumOrSub action_3 MultDiv action_4 .) + closedParen reduce using rule 42 (EA -> EA SumOrSub action_3 MultDiv action_4 .) + end reduce using rule 42 (EA -> EA SumOrSub action_3 MultDiv action_4 .) + id reduce using rule 42 (EA -> EA SumOrSub action_3 MultDiv action_4 .) + read reduce using rule 42 (EA -> EA SumOrSub action_3 MultDiv action_4 .) + print reduce using rule 42 (EA -> EA SumOrSub action_3 MultDiv action_4 .) + if reduce using rule 42 (EA -> EA SumOrSub action_3 MultDiv action_4 .) + do reduce using rule 42 (EA -> EA SumOrSub action_3 MultDiv action_4 .) + swap reduce using rule 42 (EA -> EA SumOrSub action_3 MultDiv action_4 .) + exit reduce using rule 42 (EA -> EA SumOrSub action_3 MultDiv action_4 .) + elif reduce using rule 42 (EA -> EA SumOrSub action_3 MultDiv action_4 .) + else reduce using rule 42 (EA -> EA SumOrSub action_3 MultDiv action_4 .) + then reduce using rule 42 (EA -> EA SumOrSub action_3 MultDiv action_4 .) + + +state 129 + + (46) MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 . + + mul reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + div reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + coma reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + plus reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + minus reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + closedParen reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + end reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + id reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + read reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + print reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + if reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + do reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + swap reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + exit reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + elif reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + else reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + then reduce using rule 46 (MultDiv -> MultDiv MDSymbols action_5 EAParens action_6 .) + + +state 130 (36) Relif -> Relif elif openParen EL closedParen then . B (13) B -> . B S @@ -2074,23 +2257,23 @@ state 123 else reduce using rule 14 (B -> .) end reduce using rule 14 (B -> .) - B shift and go to state 126 + B shift and go to state 133 -state 124 +state 131 (39) IntOrEmpty -> coma . int - int shift and go to state 127 + int shift and go to state 134 -state 125 +state 132 (20) S -> do id equals EA coma EA IntOrEmpty . then B end do - then shift and go to state 128 + then shift and go to state 135 -state 126 +state 133 (36) Relif -> Relif elif openParen EL closedParen then B . (13) B -> B . S @@ -2119,14 +2302,14 @@ state 126 S shift and go to state 15 Dimensional shift and go to state 16 -state 127 +state 134 (39) IntOrEmpty -> coma int . then reduce using rule 39 (IntOrEmpty -> coma int .) -state 128 +state 135 (20) S -> do id equals EA coma EA IntOrEmpty then . B end do (13) B -> . B S @@ -2141,9 +2324,9 @@ state 128 swap reduce using rule 14 (B -> .) exit reduce using rule 14 (B -> .) - B shift and go to state 129 + B shift and go to state 136 -state 129 +state 136 (20) S -> do id equals EA coma EA IntOrEmpty then B . end do (13) B -> B . S @@ -2158,7 +2341,7 @@ state 129 (23) S -> . exit (24) Dimensional -> . id DimensionsOrEmpty - end shift and go to state 130 + end shift and go to state 137 id shift and go to state 13 read shift and go to state 17 print shift and go to state 18 @@ -2170,14 +2353,14 @@ state 129 S shift and go to state 15 Dimensional shift and go to state 16 -state 130 +state 137 (20) S -> do id equals EA coma EA IntOrEmpty then B end . do - do shift and go to state 131 + do shift and go to state 138 -state 131 +state 138 (20) S -> do id equals EA coma EA IntOrEmpty then B end do . @@ -2196,5 +2379,5 @@ WARNING: WARNING: Conflicts: WARNING: WARNING: shift/reduce conflict for and in state 63 resolved as shift -WARNING: shift/reduce conflict for or in state 98 resolved as shift -WARNING: shift/reduce conflict for and in state 114 resolved as shift +WARNING: shift/reduce conflict for or in state 101 resolved as shift +WARNING: shift/reduce conflict for and in state 117 resolved as shift diff --git a/final_lang/parsetab.py b/final_lang/parsetab.py index 16f24e9..0b6782e 100644 --- a/final_lang/parsetab.py +++ b/final_lang/parsetab.py @@ -6,9 +6,9 @@ _tabversion = '3.10' _lr_method = 'LALR' -_lr_signature = 'and closedBra closedParen coma div do doubleColon doubleEquals elif else end equals exit id if int integer less lessEquals minus more moreEquals mul not notEquals openBra openParen or parens plus print program rea read real string subroutine swap then\n programa : program id V F B end program\n \n V : V Tipo Dim doubleColon Rid\n |\n \n Rid : id\n | Rid coma id\n \n Tipo : integer\n | real\n \n Dim : openBra int closedBra\n | openBra int closedBra openBra int closedBra\n |\n \n F : F subroutine id B end subroutine\n |\n \n B : B S\n |\n \n S : Dimensional equals EA\n | id parens\n | read RDimensional\n | print RDimOrString\n | if Relif ElseOrEmpty end if\n | do id equals EA coma EA IntOrEmpty then B end do\n | do then B end do\n | swap Dimensional coma Dimensional\n | exit\n \n Dimensional : id DimensionsOrEmpty\n \n DimensionsOrEmpty : openParen EA ComaEAOrEmpty closedParen\n |\n \n ComaEAOrEmpty : coma EA\n |\n \n RDimensional : Dimensional\n | RDimensional coma Dimensional\n \n RDimOrString : DimOrString\n | RDimOrString coma DimOrString\n \n DimOrString : Dimensional\n | string\n \n Relif : openParen EL closedParen then B\n | Relif elif openParen EL closedParen then B\n \n ElseOrEmpty : else B\n |\n \n IntOrEmpty : coma int\n |\n \n EA : MultDiv\n | EA SumOrSub MultDiv\n \n SumOrSub : plus\n | minus\n \n MultDiv : EAParens\n | MultDiv MDSymbols EAParens\n \n MDSymbols : mul\n | div\n \n EAParens : EItem\n | openParen EA closedParen\n \n EL : AND\n | EL or AND\n \n AND : Equality\n | AND and Equality\n \n Equality : EItem EQSymbols EItem\n | openParen EL closedParen\n | not EL\n \n EItem : Dimensional\n | int\n | rea\n \n EQSymbols : less\n | more\n | doubleEquals\n | notEquals\n | lessEquals\n | moreEquals\n ' +_lr_signature = 'and closedBra closedParen coma div do doubleColon doubleEquals elif else end equals exit id if int integer less lessEquals minus more moreEquals mul not notEquals openBra openParen or parens plus print program rea read real string subroutine swap then\n programa : program id V F B end program\n \n V : V Tipo Dim doubleColon Rid\n |\n \n Rid : id\n | Rid coma id\n \n Tipo : integer\n | real\n \n Dim : openBra int closedBra\n | openBra int closedBra openBra int closedBra\n |\n \n F : F subroutine id B end subroutine\n |\n \n B : B S\n |\n \n S : Dimensional equals EA\n | id parens\n | read RDimensional\n | print RDimOrString\n | if Relif ElseOrEmpty end if\n | do id equals EA coma EA IntOrEmpty then B end do\n | do then B end do\n | swap Dimensional coma Dimensional\n | exit\n \n Dimensional : id DimensionsOrEmpty\n \n DimensionsOrEmpty : openParen EA ComaEAOrEmpty closedParen\n |\n \n ComaEAOrEmpty : coma EA\n |\n \n RDimensional : Dimensional\n | RDimensional coma Dimensional\n \n RDimOrString : DimOrString\n | RDimOrString coma DimOrString\n \n DimOrString : Dimensional\n | string\n \n Relif : openParen EL closedParen then B\n | Relif elif openParen EL closedParen then B\n \n ElseOrEmpty : else B\n |\n \n IntOrEmpty : coma int\n |\n \n EA : MultDiv\n | EA SumOrSub action_3 MultDiv action_4\n \n SumOrSub : plus\n | minus\n \n MultDiv : EAParens\n | MultDiv MDSymbols action_5 EAParens action_6\n \n MDSymbols : mul\n | div\n \n EAParens : EItem\n | openParen EA closedParen\n \n EL : AND\n | EL or AND\n \n AND : Equality\n | AND and Equality\n \n Equality : EItem EQSymbols EItem\n | openParen EL closedParen\n | not EL\n \n EItem : Dimensional action_1\n | int action_2\n | rea action_2\n \n EQSymbols : less\n | more\n | doubleEquals\n | notEquals\n | lessEquals\n | moreEquals\n action_1 :action_2 :action_3 :action_4 :action_5 :action_6 :' -_lr_action_items = {'program':([0,14,],[2,29,]),'$end':([1,29,],[0,-1,]),'id':([2,3,4,5,9,10,15,17,18,20,21,22,23,24,26,27,28,30,31,32,33,34,35,36,37,39,41,43,44,45,47,49,50,51,52,53,54,55,56,57,60,61,66,67,68,69,71,75,76,77,78,79,80,81,82,83,85,86,89,90,91,92,93,94,95,96,97,101,102,103,105,106,107,109,110,113,117,118,121,123,126,128,129,131,],[3,-3,-12,-14,13,23,-13,33,33,40,33,-23,-14,45,-16,-24,33,33,-17,-29,-26,-18,-31,-33,-34,33,-14,13,-2,-4,33,-41,-45,-49,-58,-59,-60,-15,33,33,-14,33,33,33,13,33,103,33,33,-43,-44,33,-47,-48,-30,-32,33,13,33,33,33,-61,-62,-63,-64,-65,-66,-22,-11,-5,-50,-25,-42,-46,-19,-14,33,-21,13,-14,13,-14,13,-20,]),'integer':([3,4,44,45,103,],[-3,7,-2,-4,-5,]),'real':([3,4,44,45,103,],[-3,8,-2,-4,-5,]),'subroutine':([3,4,5,44,45,70,102,103,],[-3,-12,10,-2,-4,102,-11,-5,]),'end':([3,4,5,9,15,22,23,26,27,31,32,33,34,35,36,37,38,41,43,44,45,49,50,51,52,53,54,55,58,60,68,82,83,86,101,102,103,105,106,107,109,110,113,118,121,123,126,128,129,131,],[-3,-12,-14,14,-13,-23,-14,-16,-24,-17,-29,-26,-18,-31,-33,-34,-38,-14,70,-2,-4,-41,-45,-49,-58,-59,-60,-15,84,-14,100,-30,-32,-37,-22,-11,-5,-50,-25,-42,-46,-19,-14,-21,-35,-14,-36,-14,130,-20,]),'read':([3,4,5,9,15,22,23,26,27,31,32,33,34,35,36,37,41,43,44,45,49,50,51,52,53,54,55,60,68,82,83,86,101,102,103,105,106,107,109,110,113,118,121,123,126,128,129,131,],[-3,-12,-14,17,-13,-23,-14,-16,-24,-17,-29,-26,-18,-31,-33,-34,-14,17,-2,-4,-41,-45,-49,-58,-59,-60,-15,-14,17,-30,-32,17,-22,-11,-5,-50,-25,-42,-46,-19,-14,-21,17,-14,17,-14,17,-20,]),'print':([3,4,5,9,15,22,23,26,27,31,32,33,34,35,36,37,41,43,44,45,49,50,51,52,53,54,55,60,68,82,83,86,101,102,103,105,106,107,109,110,113,118,121,123,126,128,129,131,],[-3,-12,-14,18,-13,-23,-14,-16,-24,-17,-29,-26,-18,-31,-33,-34,-14,18,-2,-4,-41,-45,-49,-58,-59,-60,-15,-14,18,-30,-32,18,-22,-11,-5,-50,-25,-42,-46,-19,-14,-21,18,-14,18,-14,18,-20,]),'if':([3,4,5,9,15,22,23,26,27,31,32,33,34,35,36,37,41,43,44,45,49,50,51,52,53,54,55,60,68,82,83,84,86,101,102,103,105,106,107,109,110,113,118,121,123,126,128,129,131,],[-3,-12,-14,19,-13,-23,-14,-16,-24,-17,-29,-26,-18,-31,-33,-34,-14,19,-2,-4,-41,-45,-49,-58,-59,-60,-15,-14,19,-30,-32,110,19,-22,-11,-5,-50,-25,-42,-46,-19,-14,-21,19,-14,19,-14,19,-20,]),'do':([3,4,5,9,15,22,23,26,27,31,32,33,34,35,36,37,41,43,44,45,49,50,51,52,53,54,55,60,68,82,83,86,100,101,102,103,105,106,107,109,110,113,118,121,123,126,128,129,130,131,],[-3,-12,-14,20,-13,-23,-14,-16,-24,-17,-29,-26,-18,-31,-33,-34,-14,20,-2,-4,-41,-45,-49,-58,-59,-60,-15,-14,20,-30,-32,20,118,-22,-11,-5,-50,-25,-42,-46,-19,-14,-21,20,-14,20,-14,20,131,-20,]),'swap':([3,4,5,9,15,22,23,26,27,31,32,33,34,35,36,37,41,43,44,45,49,50,51,52,53,54,55,60,68,82,83,86,101,102,103,105,106,107,109,110,113,118,121,123,126,128,129,131,],[-3,-12,-14,21,-13,-23,-14,-16,-24,-17,-29,-26,-18,-31,-33,-34,-14,21,-2,-4,-41,-45,-49,-58,-59,-60,-15,-14,21,-30,-32,21,-22,-11,-5,-50,-25,-42,-46,-19,-14,-21,21,-14,21,-14,21,-20,]),'exit':([3,4,5,9,15,22,23,26,27,31,32,33,34,35,36,37,41,43,44,45,49,50,51,52,53,54,55,60,68,82,83,86,101,102,103,105,106,107,109,110,113,118,121,123,126,128,129,131,],[-3,-12,-14,22,-13,-23,-14,-16,-24,-17,-29,-26,-18,-31,-33,-34,-14,22,-2,-4,-41,-45,-49,-58,-59,-60,-15,-14,22,-30,-32,22,-22,-11,-5,-50,-25,-42,-46,-19,-14,-21,22,-14,22,-14,22,-20,]),'openBra':([6,7,8,46,],[12,-6,-7,72,]),'doubleColon':([6,7,8,11,46,119,],[-10,-6,-7,24,-8,-9,]),'int':([12,28,30,39,47,61,66,67,72,75,76,77,78,79,80,81,85,89,90,91,92,93,94,95,96,97,117,124,],[25,53,53,53,53,53,53,53,104,53,53,-43,-44,53,-47,-48,53,53,53,53,-61,-62,-63,-64,-65,-66,53,127,]),'parens':([13,],[26,]),'openParen':([13,19,28,30,33,39,47,59,61,66,67,75,76,77,78,79,80,81,85,89,90,117,],[28,39,47,47,28,61,47,85,61,61,47,47,47,-43,-44,47,-47,-48,61,61,61,47,]),'equals':([13,16,27,40,106,],[-26,30,-24,67,-25,]),'elif':([15,22,26,27,31,32,33,34,35,36,37,38,49,50,51,52,53,54,55,82,83,101,105,106,107,109,110,113,118,121,123,126,131,],[-13,-23,-16,-24,-17,-29,-26,-18,-31,-33,-34,59,-41,-45,-49,-58,-59,-60,-15,-30,-32,-22,-50,-25,-42,-46,-19,-14,-21,-35,-14,-36,-20,]),'else':([15,22,26,27,31,32,33,34,35,36,37,38,49,50,51,52,53,54,55,82,83,101,105,106,107,109,110,113,118,121,123,126,131,],[-13,-23,-16,-24,-17,-29,-26,-18,-31,-33,-34,60,-41,-45,-49,-58,-59,-60,-15,-30,-32,-22,-50,-25,-42,-46,-19,-14,-21,-35,-14,-36,-20,]),'string':([18,57,],[37,37,]),'then':([20,27,33,49,50,51,52,53,54,88,105,106,107,109,120,122,125,127,],[41,-24,-26,-41,-45,-49,-58,-59,-60,113,-50,-25,-42,-46,123,-40,128,-39,]),'closedBra':([25,104,],[46,119,]),'coma':([27,31,32,33,34,35,36,37,42,44,45,48,49,50,51,52,53,54,82,83,99,103,105,106,107,109,122,],[-24,56,-29,-26,57,-31,-33,-34,69,71,-4,76,-41,-45,-49,-58,-59,-60,-30,-32,117,-5,-50,-25,-42,-46,124,]),'mul':([27,33,49,50,51,52,53,54,105,106,107,109,],[-24,-26,80,-45,-49,-58,-59,-60,-50,-25,80,-46,]),'div':([27,33,49,50,51,52,53,54,105,106,107,109,],[-24,-26,81,-45,-49,-58,-59,-60,-50,-25,81,-46,]),'plus':([27,33,48,49,50,51,52,53,54,55,73,99,105,106,107,108,109,122,],[-24,-26,77,-41,-45,-49,-58,-59,-60,77,77,77,-50,-25,-42,77,-46,77,]),'minus':([27,33,48,49,50,51,52,53,54,55,73,99,105,106,107,108,109,122,],[-24,-26,78,-41,-45,-49,-58,-59,-60,78,78,78,-50,-25,-42,78,-46,78,]),'closedParen':([27,33,48,49,50,51,52,53,54,62,63,64,73,74,87,98,105,106,107,108,109,111,112,114,115,116,],[-24,-26,-28,-41,-45,-49,-58,-59,-60,88,-51,-53,105,106,112,-57,-50,-25,-42,-27,-46,120,-56,-52,-54,-55,]),'less':([27,33,52,53,54,65,106,],[-24,-26,-58,-59,-60,92,-25,]),'more':([27,33,52,53,54,65,106,],[-24,-26,-58,-59,-60,93,-25,]),'doubleEquals':([27,33,52,53,54,65,106,],[-24,-26,-58,-59,-60,94,-25,]),'notEquals':([27,33,52,53,54,65,106,],[-24,-26,-58,-59,-60,95,-25,]),'lessEquals':([27,33,52,53,54,65,106,],[-24,-26,-58,-59,-60,96,-25,]),'moreEquals':([27,33,52,53,54,65,106,],[-24,-26,-58,-59,-60,97,-25,]),'and':([27,33,52,53,54,63,64,98,106,112,114,115,116,],[-24,-26,-58,-59,-60,90,-53,-57,-25,-56,90,-54,-55,]),'or':([27,33,52,53,54,62,63,64,87,98,106,111,112,114,115,116,],[-24,-26,-58,-59,-60,89,-51,-53,89,89,-25,89,-56,-52,-54,-55,]),'rea':([28,30,39,47,61,66,67,75,76,77,78,79,80,81,85,89,90,91,92,93,94,95,96,97,117,],[54,54,54,54,54,54,54,54,54,-43,-44,54,-47,-48,54,54,54,54,-61,-62,-63,-64,-65,-66,54,]),'not':([39,61,66,85,89,90,],[66,66,66,66,66,66,]),} +_lr_action_items = {'program':([0,14,],[2,29,]),'$end':([1,29,],[0,-1,]),'id':([2,3,4,5,9,10,15,17,18,20,21,22,23,24,26,27,28,30,31,32,33,34,35,36,37,39,41,43,44,45,47,49,50,51,52,53,54,55,56,57,60,61,66,67,68,69,71,75,76,77,78,79,80,81,82,83,84,85,86,88,89,92,93,94,95,96,97,98,99,100,104,105,106,108,109,110,112,113,116,120,121,123,124,126,128,129,130,133,135,136,138,],[3,-3,-12,-14,13,23,-13,33,33,40,33,-23,-14,45,-16,-24,33,33,-17,-29,-26,-18,-31,-33,-34,33,-14,13,-2,-4,33,-41,-45,-49,-67,-68,-68,-15,33,33,-14,33,33,33,13,33,106,-69,33,-43,-44,-71,-47,-48,-58,-59,-60,-30,-32,33,13,33,33,33,-61,-62,-63,-64,-65,-66,-22,-11,-5,-50,-25,33,33,-19,-14,33,-21,-70,-72,13,-42,-46,-14,13,-14,13,-20,]),'integer':([3,4,44,45,106,],[-3,7,-2,-4,-5,]),'real':([3,4,44,45,106,],[-3,8,-2,-4,-5,]),'subroutine':([3,4,5,44,45,70,105,106,],[-3,-12,10,-2,-4,105,-11,-5,]),'end':([3,4,5,9,15,22,23,26,27,31,32,33,34,35,36,37,38,41,43,44,45,49,50,51,52,53,54,55,58,60,68,82,83,84,85,86,89,104,105,106,108,109,113,116,121,123,124,126,128,129,130,133,135,136,138,],[-3,-12,-14,14,-13,-23,-14,-16,-24,-17,-29,-26,-18,-31,-33,-34,-38,-14,70,-2,-4,-41,-45,-49,-67,-68,-68,-15,87,-14,103,-58,-59,-60,-30,-32,-37,-22,-11,-5,-50,-25,-19,-14,-21,-70,-72,-35,-42,-46,-14,-36,-14,137,-20,]),'read':([3,4,5,9,15,22,23,26,27,31,32,33,34,35,36,37,41,43,44,45,49,50,51,52,53,54,55,60,68,82,83,84,85,86,89,104,105,106,108,109,113,116,121,123,124,126,128,129,130,133,135,136,138,],[-3,-12,-14,17,-13,-23,-14,-16,-24,-17,-29,-26,-18,-31,-33,-34,-14,17,-2,-4,-41,-45,-49,-67,-68,-68,-15,-14,17,-58,-59,-60,-30,-32,17,-22,-11,-5,-50,-25,-19,-14,-21,-70,-72,17,-42,-46,-14,17,-14,17,-20,]),'print':([3,4,5,9,15,22,23,26,27,31,32,33,34,35,36,37,41,43,44,45,49,50,51,52,53,54,55,60,68,82,83,84,85,86,89,104,105,106,108,109,113,116,121,123,124,126,128,129,130,133,135,136,138,],[-3,-12,-14,18,-13,-23,-14,-16,-24,-17,-29,-26,-18,-31,-33,-34,-14,18,-2,-4,-41,-45,-49,-67,-68,-68,-15,-14,18,-58,-59,-60,-30,-32,18,-22,-11,-5,-50,-25,-19,-14,-21,-70,-72,18,-42,-46,-14,18,-14,18,-20,]),'if':([3,4,5,9,15,22,23,26,27,31,32,33,34,35,36,37,41,43,44,45,49,50,51,52,53,54,55,60,68,82,83,84,85,86,87,89,104,105,106,108,109,113,116,121,123,124,126,128,129,130,133,135,136,138,],[-3,-12,-14,19,-13,-23,-14,-16,-24,-17,-29,-26,-18,-31,-33,-34,-14,19,-2,-4,-41,-45,-49,-67,-68,-68,-15,-14,19,-58,-59,-60,-30,-32,113,19,-22,-11,-5,-50,-25,-19,-14,-21,-70,-72,19,-42,-46,-14,19,-14,19,-20,]),'do':([3,4,5,9,15,22,23,26,27,31,32,33,34,35,36,37,41,43,44,45,49,50,51,52,53,54,55,60,68,82,83,84,85,86,89,103,104,105,106,108,109,113,116,121,123,124,126,128,129,130,133,135,136,137,138,],[-3,-12,-14,20,-13,-23,-14,-16,-24,-17,-29,-26,-18,-31,-33,-34,-14,20,-2,-4,-41,-45,-49,-67,-68,-68,-15,-14,20,-58,-59,-60,-30,-32,20,121,-22,-11,-5,-50,-25,-19,-14,-21,-70,-72,20,-42,-46,-14,20,-14,20,138,-20,]),'swap':([3,4,5,9,15,22,23,26,27,31,32,33,34,35,36,37,41,43,44,45,49,50,51,52,53,54,55,60,68,82,83,84,85,86,89,104,105,106,108,109,113,116,121,123,124,126,128,129,130,133,135,136,138,],[-3,-12,-14,21,-13,-23,-14,-16,-24,-17,-29,-26,-18,-31,-33,-34,-14,21,-2,-4,-41,-45,-49,-67,-68,-68,-15,-14,21,-58,-59,-60,-30,-32,21,-22,-11,-5,-50,-25,-19,-14,-21,-70,-72,21,-42,-46,-14,21,-14,21,-20,]),'exit':([3,4,5,9,15,22,23,26,27,31,32,33,34,35,36,37,41,43,44,45,49,50,51,52,53,54,55,60,68,82,83,84,85,86,89,104,105,106,108,109,113,116,121,123,124,126,128,129,130,133,135,136,138,],[-3,-12,-14,22,-13,-23,-14,-16,-24,-17,-29,-26,-18,-31,-33,-34,-14,22,-2,-4,-41,-45,-49,-67,-68,-68,-15,-14,22,-58,-59,-60,-30,-32,22,-22,-11,-5,-50,-25,-19,-14,-21,-70,-72,22,-42,-46,-14,22,-14,22,-20,]),'openBra':([6,7,8,46,],[12,-6,-7,72,]),'doubleColon':([6,7,8,11,46,122,],[-10,-6,-7,24,-8,-9,]),'int':([12,28,30,39,47,61,66,67,72,75,76,77,78,79,80,81,88,92,93,94,95,96,97,98,99,100,110,112,120,131,],[25,53,53,53,53,53,53,53,107,-69,53,-43,-44,-71,-47,-48,53,53,53,53,-61,-62,-63,-64,-65,-66,53,53,53,134,]),'parens':([13,],[26,]),'openParen':([13,19,28,30,33,39,47,59,61,66,67,75,76,77,78,79,80,81,88,92,93,110,112,120,],[28,39,47,47,28,61,47,88,61,61,47,-69,47,-43,-44,-71,-47,-48,61,61,61,47,47,47,]),'equals':([13,16,27,40,109,],[-26,30,-24,67,-25,]),'elif':([15,22,26,27,31,32,33,34,35,36,37,38,49,50,51,52,53,54,55,82,83,84,85,86,104,108,109,113,116,121,123,124,126,128,129,130,133,138,],[-13,-23,-16,-24,-17,-29,-26,-18,-31,-33,-34,59,-41,-45,-49,-67,-68,-68,-15,-58,-59,-60,-30,-32,-22,-50,-25,-19,-14,-21,-70,-72,-35,-42,-46,-14,-36,-20,]),'else':([15,22,26,27,31,32,33,34,35,36,37,38,49,50,51,52,53,54,55,82,83,84,85,86,104,108,109,113,116,121,123,124,126,128,129,130,133,138,],[-13,-23,-16,-24,-17,-29,-26,-18,-31,-33,-34,60,-41,-45,-49,-67,-68,-68,-15,-58,-59,-60,-30,-32,-22,-50,-25,-19,-14,-21,-70,-72,-35,-42,-46,-14,-36,-20,]),'string':([18,57,],[37,37,]),'then':([20,27,33,49,50,51,52,53,54,82,83,84,91,108,109,123,124,125,127,128,129,132,134,],[41,-24,-26,-41,-45,-49,-67,-68,-68,-58,-59,-60,116,-50,-25,-70,-72,130,-40,-42,-46,135,-39,]),'closedBra':([25,107,],[46,122,]),'coma':([27,31,32,33,34,35,36,37,42,44,45,48,49,50,51,52,53,54,82,83,84,85,86,102,106,108,109,123,124,127,128,129,],[-24,56,-29,-26,57,-31,-33,-34,69,71,-4,76,-41,-45,-49,-67,-68,-68,-58,-59,-60,-30,-32,120,-5,-50,-25,-70,-72,131,-42,-46,]),'mul':([27,33,49,50,51,52,53,54,82,83,84,108,109,123,124,129,],[-24,-26,80,-45,-49,-67,-68,-68,-58,-59,-60,-50,-25,80,-72,-46,]),'div':([27,33,49,50,51,52,53,54,82,83,84,108,109,123,124,129,],[-24,-26,81,-45,-49,-67,-68,-68,-58,-59,-60,-50,-25,81,-72,-46,]),'plus':([27,33,48,49,50,51,52,53,54,55,73,82,83,84,102,108,109,111,123,124,127,128,129,],[-24,-26,77,-41,-45,-49,-67,-68,-68,77,77,-58,-59,-60,77,-50,-25,77,-70,-72,77,-42,-46,]),'minus':([27,33,48,49,50,51,52,53,54,55,73,82,83,84,102,108,109,111,123,124,127,128,129,],[-24,-26,78,-41,-45,-49,-67,-68,-68,78,78,-58,-59,-60,78,-50,-25,78,-70,-72,78,-42,-46,]),'closedParen':([27,33,48,49,50,51,52,53,54,62,63,64,73,74,82,83,84,90,101,108,109,111,114,115,117,118,119,123,124,128,129,],[-24,-26,-28,-41,-45,-49,-67,-68,-68,91,-51,-53,108,109,-58,-59,-60,115,-57,-50,-25,-27,125,-56,-52,-54,-55,-70,-72,-42,-46,]),'less':([27,33,52,53,54,65,82,83,84,109,],[-24,-26,-67,-68,-68,95,-58,-59,-60,-25,]),'more':([27,33,52,53,54,65,82,83,84,109,],[-24,-26,-67,-68,-68,96,-58,-59,-60,-25,]),'doubleEquals':([27,33,52,53,54,65,82,83,84,109,],[-24,-26,-67,-68,-68,97,-58,-59,-60,-25,]),'notEquals':([27,33,52,53,54,65,82,83,84,109,],[-24,-26,-67,-68,-68,98,-58,-59,-60,-25,]),'lessEquals':([27,33,52,53,54,65,82,83,84,109,],[-24,-26,-67,-68,-68,99,-58,-59,-60,-25,]),'moreEquals':([27,33,52,53,54,65,82,83,84,109,],[-24,-26,-67,-68,-68,100,-58,-59,-60,-25,]),'and':([27,33,52,53,54,63,64,82,83,84,101,109,115,117,118,119,],[-24,-26,-67,-68,-68,93,-53,-58,-59,-60,-57,-25,-56,93,-54,-55,]),'or':([27,33,52,53,54,62,63,64,82,83,84,90,101,109,114,115,117,118,119,],[-24,-26,-67,-68,-68,92,-51,-53,-58,-59,-60,92,92,-25,92,-56,-52,-54,-55,]),'rea':([28,30,39,47,61,66,67,75,76,77,78,79,80,81,88,92,93,94,95,96,97,98,99,100,110,112,120,],[54,54,54,54,54,54,54,-69,54,-43,-44,-71,-47,-48,54,54,54,54,-61,-62,-63,-64,-65,-66,54,54,54,]),'not':([39,61,66,88,92,93,],[66,66,66,66,66,66,]),} _lr_action = {} for _k, _v in _lr_action_items.items(): @@ -17,7 +17,7 @@ for _k, _v in _lr_action_items.items(): _lr_action[_x][_k] = _y del _lr_action_items -_lr_goto_items = {'programa':([0,],[1,]),'V':([3,],[4,]),'F':([4,],[5,]),'Tipo':([4,],[6,]),'B':([5,23,41,60,113,123,128,],[9,43,68,86,121,126,129,]),'Dim':([6,],[11,]),'S':([9,43,68,86,121,126,129,],[15,15,15,15,15,15,15,]),'Dimensional':([9,17,18,21,28,30,39,43,47,56,57,61,66,67,68,69,75,76,79,85,86,89,90,91,117,121,126,129,],[16,32,36,42,52,52,52,16,52,82,36,52,52,52,16,101,52,52,52,52,16,52,52,52,52,16,16,16,]),'DimensionsOrEmpty':([13,33,],[27,27,]),'RDimensional':([17,],[31,]),'RDimOrString':([18,],[34,]),'DimOrString':([18,57,],[35,83,]),'Relif':([19,],[38,]),'Rid':([24,],[44,]),'EA':([28,30,47,67,76,117,],[48,55,73,99,108,122,]),'MultDiv':([28,30,47,67,75,76,117,],[49,49,49,49,107,49,49,]),'EAParens':([28,30,47,67,75,76,79,117,],[50,50,50,50,50,50,109,50,]),'EItem':([28,30,39,47,61,66,67,75,76,79,85,89,90,91,117,],[51,51,65,51,65,65,51,51,51,51,65,65,65,116,51,]),'ElseOrEmpty':([38,],[58,]),'EL':([39,61,66,85,],[62,87,98,111,]),'AND':([39,61,66,85,89,],[63,63,63,63,114,]),'Equality':([39,61,66,85,89,90,],[64,64,64,64,64,115,]),'ComaEAOrEmpty':([48,],[74,]),'SumOrSub':([48,55,73,99,108,122,],[75,75,75,75,75,75,]),'MDSymbols':([49,107,],[79,79,]),'EQSymbols':([65,],[91,]),'IntOrEmpty':([122,],[125,]),} +_lr_goto_items = {'programa':([0,],[1,]),'V':([3,],[4,]),'F':([4,],[5,]),'Tipo':([4,],[6,]),'B':([5,23,41,60,116,130,135,],[9,43,68,89,126,133,136,]),'Dim':([6,],[11,]),'S':([9,43,68,89,126,133,136,],[15,15,15,15,15,15,15,]),'Dimensional':([9,17,18,21,28,30,39,43,47,56,57,61,66,67,68,69,76,88,89,92,93,94,110,112,120,126,133,136,],[16,32,36,42,52,52,52,16,52,85,36,52,52,52,16,104,52,52,16,52,52,52,52,52,52,16,16,16,]),'DimensionsOrEmpty':([13,33,],[27,27,]),'RDimensional':([17,],[31,]),'RDimOrString':([18,],[34,]),'DimOrString':([18,57,],[35,86,]),'Relif':([19,],[38,]),'Rid':([24,],[44,]),'EA':([28,30,47,67,76,120,],[48,55,73,102,111,127,]),'MultDiv':([28,30,47,67,76,110,120,],[49,49,49,49,49,123,49,]),'EAParens':([28,30,47,67,76,110,112,120,],[50,50,50,50,50,50,124,50,]),'EItem':([28,30,39,47,61,66,67,76,88,92,93,94,110,112,120,],[51,51,65,51,65,65,51,51,65,65,65,119,51,51,51,]),'ElseOrEmpty':([38,],[58,]),'EL':([39,61,66,88,],[62,90,101,114,]),'AND':([39,61,66,88,92,],[63,63,63,63,117,]),'Equality':([39,61,66,88,92,93,],[64,64,64,64,64,118,]),'ComaEAOrEmpty':([48,],[74,]),'SumOrSub':([48,55,73,102,111,127,],[75,75,75,75,75,75,]),'MDSymbols':([49,123,],[79,79,]),'action_1':([52,],[82,]),'action_2':([53,54,],[83,84,]),'EQSymbols':([65,],[94,]),'action_3':([75,],[110,]),'action_5':([79,],[112,]),'action_4':([123,],[128,]),'action_6':([124,],[129,]),'IntOrEmpty':([127,],[132,]),} _lr_goto = {} for _k, _v in _lr_goto_items.items(): @@ -27,70 +27,76 @@ for _k, _v in _lr_goto_items.items(): del _lr_goto_items _lr_productions = [ ("S' -> programa","S'",1,None,None,None), - ('programa -> program id V F B end program','programa',7,'p_programa','lex_yacc.py',115), - ('V -> V Tipo Dim doubleColon Rid','V',5,'p_V','lex_yacc.py',121), - ('V -> ','V',0,'p_V','lex_yacc.py',122), - ('Rid -> id','Rid',1,'p_Rid','lex_yacc.py',127), - ('Rid -> Rid coma id','Rid',3,'p_Rid','lex_yacc.py',128), - ('Tipo -> integer','Tipo',1,'p_Tipo','lex_yacc.py',133), - ('Tipo -> real','Tipo',1,'p_Tipo','lex_yacc.py',134), - ('Dim -> openBra int closedBra','Dim',3,'p_Dim','lex_yacc.py',139), - ('Dim -> openBra int closedBra openBra int closedBra','Dim',6,'p_Dim','lex_yacc.py',140), - ('Dim -> ','Dim',0,'p_Dim','lex_yacc.py',141), - ('F -> F subroutine id B end subroutine','F',6,'p_F','lex_yacc.py',146), - ('F -> ','F',0,'p_F','lex_yacc.py',147), - ('B -> B S','B',2,'p_B','lex_yacc.py',152), - ('B -> ','B',0,'p_B','lex_yacc.py',153), - ('S -> Dimensional equals EA','S',3,'p_S','lex_yacc.py',158), - ('S -> id parens','S',2,'p_S','lex_yacc.py',159), - ('S -> read RDimensional','S',2,'p_S','lex_yacc.py',160), - ('S -> print RDimOrString','S',2,'p_S','lex_yacc.py',161), - ('S -> if Relif ElseOrEmpty end if','S',5,'p_S','lex_yacc.py',162), - ('S -> do id equals EA coma EA IntOrEmpty then B end do','S',11,'p_S','lex_yacc.py',163), - ('S -> do then B end do','S',5,'p_S','lex_yacc.py',164), - ('S -> swap Dimensional coma Dimensional','S',4,'p_S','lex_yacc.py',165), - ('S -> exit','S',1,'p_S','lex_yacc.py',166), - ('Dimensional -> id DimensionsOrEmpty','Dimensional',2,'p_Dimensional','lex_yacc.py',171), - ('DimensionsOrEmpty -> openParen EA ComaEAOrEmpty closedParen','DimensionsOrEmpty',4,'p_DimensionsOrEmpty','lex_yacc.py',176), - ('DimensionsOrEmpty -> ','DimensionsOrEmpty',0,'p_DimensionsOrEmpty','lex_yacc.py',177), - ('ComaEAOrEmpty -> coma EA','ComaEAOrEmpty',2,'p_ComaEAOrEmpty','lex_yacc.py',182), - ('ComaEAOrEmpty -> ','ComaEAOrEmpty',0,'p_ComaEAOrEmpty','lex_yacc.py',183), - ('RDimensional -> Dimensional','RDimensional',1,'p_RDimensional','lex_yacc.py',188), - ('RDimensional -> RDimensional coma Dimensional','RDimensional',3,'p_RDimensional','lex_yacc.py',189), - ('RDimOrString -> DimOrString','RDimOrString',1,'p_RDimOrString','lex_yacc.py',194), - ('RDimOrString -> RDimOrString coma DimOrString','RDimOrString',3,'p_RDimOrString','lex_yacc.py',195), - ('DimOrString -> Dimensional','DimOrString',1,'p_DimOrString','lex_yacc.py',200), - ('DimOrString -> string','DimOrString',1,'p_DimOrString','lex_yacc.py',201), - ('Relif -> openParen EL closedParen then B','Relif',5,'p_Relif','lex_yacc.py',206), - ('Relif -> Relif elif openParen EL closedParen then B','Relif',7,'p_Relif','lex_yacc.py',207), - ('ElseOrEmpty -> else B','ElseOrEmpty',2,'p_ElseOrEmpty','lex_yacc.py',212), - ('ElseOrEmpty -> ','ElseOrEmpty',0,'p_ElseOrEmpty','lex_yacc.py',213), - ('IntOrEmpty -> coma int','IntOrEmpty',2,'p_IntOrEmpty','lex_yacc.py',218), - ('IntOrEmpty -> ','IntOrEmpty',0,'p_IntOrEmpty','lex_yacc.py',219), - ('EA -> MultDiv','EA',1,'p_EA','lex_yacc.py',224), - ('EA -> EA SumOrSub MultDiv','EA',3,'p_EA','lex_yacc.py',225), - ('SumOrSub -> plus','SumOrSub',1,'p_SumOrSub','lex_yacc.py',230), - ('SumOrSub -> minus','SumOrSub',1,'p_SumOrSub','lex_yacc.py',231), - ('MultDiv -> EAParens','MultDiv',1,'p_MultDiv','lex_yacc.py',236), - ('MultDiv -> MultDiv MDSymbols EAParens','MultDiv',3,'p_MultDiv','lex_yacc.py',237), - ('MDSymbols -> mul','MDSymbols',1,'p_MDSymbols','lex_yacc.py',242), - ('MDSymbols -> div','MDSymbols',1,'p_MDSymbols','lex_yacc.py',243), - ('EAParens -> EItem','EAParens',1,'p_EAParens','lex_yacc.py',248), - ('EAParens -> openParen EA closedParen','EAParens',3,'p_EAParens','lex_yacc.py',249), - ('EL -> AND','EL',1,'p_EL','lex_yacc.py',254), - ('EL -> EL or AND','EL',3,'p_EL','lex_yacc.py',255), - ('AND -> Equality','AND',1,'p_AND','lex_yacc.py',260), - ('AND -> AND and Equality','AND',3,'p_AND','lex_yacc.py',261), - ('Equality -> EItem EQSymbols EItem','Equality',3,'p_Equality','lex_yacc.py',266), - ('Equality -> openParen EL closedParen','Equality',3,'p_Equality','lex_yacc.py',267), - ('Equality -> not EL','Equality',2,'p_Equality','lex_yacc.py',268), - ('EItem -> Dimensional','EItem',1,'p_EItem','lex_yacc.py',273), - ('EItem -> int','EItem',1,'p_EItem','lex_yacc.py',274), - ('EItem -> rea','EItem',1,'p_EItem','lex_yacc.py',275), - ('EQSymbols -> less','EQSymbols',1,'p_EQSymbols','lex_yacc.py',280), - ('EQSymbols -> more','EQSymbols',1,'p_EQSymbols','lex_yacc.py',281), - ('EQSymbols -> doubleEquals','EQSymbols',1,'p_EQSymbols','lex_yacc.py',282), - ('EQSymbols -> notEquals','EQSymbols',1,'p_EQSymbols','lex_yacc.py',283), - ('EQSymbols -> lessEquals','EQSymbols',1,'p_EQSymbols','lex_yacc.py',284), - ('EQSymbols -> moreEquals','EQSymbols',1,'p_EQSymbols','lex_yacc.py',285), + ('programa -> program id V F B end program','programa',7,'p_programa','fort.py',148), + ('V -> V Tipo Dim doubleColon Rid','V',5,'p_V','fort.py',154), + ('V -> ','V',0,'p_V','fort.py',155), + ('Rid -> id','Rid',1,'p_Rid','fort.py',166), + ('Rid -> Rid coma id','Rid',3,'p_Rid','fort.py',167), + ('Tipo -> integer','Tipo',1,'p_Tipo','fort.py',178), + ('Tipo -> real','Tipo',1,'p_Tipo','fort.py',179), + ('Dim -> openBra int closedBra','Dim',3,'p_Dim','fort.py',186), + ('Dim -> openBra int closedBra openBra int closedBra','Dim',6,'p_Dim','fort.py',187), + ('Dim -> ','Dim',0,'p_Dim','fort.py',188), + ('F -> F subroutine id B end subroutine','F',6,'p_F','fort.py',193), + ('F -> ','F',0,'p_F','fort.py',194), + ('B -> B S','B',2,'p_B','fort.py',199), + ('B -> ','B',0,'p_B','fort.py',200), + ('S -> Dimensional equals EA','S',3,'p_S','fort.py',205), + ('S -> id parens','S',2,'p_S','fort.py',206), + ('S -> read RDimensional','S',2,'p_S','fort.py',207), + ('S -> print RDimOrString','S',2,'p_S','fort.py',208), + ('S -> if Relif ElseOrEmpty end if','S',5,'p_S','fort.py',209), + ('S -> do id equals EA coma EA IntOrEmpty then B end do','S',11,'p_S','fort.py',210), + ('S -> do then B end do','S',5,'p_S','fort.py',211), + ('S -> swap Dimensional coma Dimensional','S',4,'p_S','fort.py',212), + ('S -> exit','S',1,'p_S','fort.py',213), + ('Dimensional -> id DimensionsOrEmpty','Dimensional',2,'p_Dimensional','fort.py',219), + ('DimensionsOrEmpty -> openParen EA ComaEAOrEmpty closedParen','DimensionsOrEmpty',4,'p_DimensionsOrEmpty','fort.py',226), + ('DimensionsOrEmpty -> ','DimensionsOrEmpty',0,'p_DimensionsOrEmpty','fort.py',227), + ('ComaEAOrEmpty -> coma EA','ComaEAOrEmpty',2,'p_ComaEAOrEmpty','fort.py',232), + ('ComaEAOrEmpty -> ','ComaEAOrEmpty',0,'p_ComaEAOrEmpty','fort.py',233), + ('RDimensional -> Dimensional','RDimensional',1,'p_RDimensional','fort.py',238), + ('RDimensional -> RDimensional coma Dimensional','RDimensional',3,'p_RDimensional','fort.py',239), + ('RDimOrString -> DimOrString','RDimOrString',1,'p_RDimOrString','fort.py',244), + ('RDimOrString -> RDimOrString coma DimOrString','RDimOrString',3,'p_RDimOrString','fort.py',245), + ('DimOrString -> Dimensional','DimOrString',1,'p_DimOrString','fort.py',250), + ('DimOrString -> string','DimOrString',1,'p_DimOrString','fort.py',251), + ('Relif -> openParen EL closedParen then B','Relif',5,'p_Relif','fort.py',256), + ('Relif -> Relif elif openParen EL closedParen then B','Relif',7,'p_Relif','fort.py',257), + ('ElseOrEmpty -> else B','ElseOrEmpty',2,'p_ElseOrEmpty','fort.py',262), + ('ElseOrEmpty -> ','ElseOrEmpty',0,'p_ElseOrEmpty','fort.py',263), + ('IntOrEmpty -> coma int','IntOrEmpty',2,'p_IntOrEmpty','fort.py',268), + ('IntOrEmpty -> ','IntOrEmpty',0,'p_IntOrEmpty','fort.py',269), + ('EA -> MultDiv','EA',1,'p_EA','fort.py',274), + ('EA -> EA SumOrSub action_3 MultDiv action_4','EA',5,'p_EA','fort.py',275), + ('SumOrSub -> plus','SumOrSub',1,'p_SumOrSub','fort.py',281), + ('SumOrSub -> minus','SumOrSub',1,'p_SumOrSub','fort.py',282), + ('MultDiv -> EAParens','MultDiv',1,'p_MultDiv','fort.py',288), + ('MultDiv -> MultDiv MDSymbols action_5 EAParens action_6','MultDiv',5,'p_MultDiv','fort.py',289), + ('MDSymbols -> mul','MDSymbols',1,'p_MDSymbols','fort.py',294), + ('MDSymbols -> div','MDSymbols',1,'p_MDSymbols','fort.py',295), + ('EAParens -> EItem','EAParens',1,'p_EAParens','fort.py',301), + ('EAParens -> openParen EA closedParen','EAParens',3,'p_EAParens','fort.py',302), + ('EL -> AND','EL',1,'p_EL','fort.py',307), + ('EL -> EL or AND','EL',3,'p_EL','fort.py',308), + ('AND -> Equality','AND',1,'p_AND','fort.py',313), + ('AND -> AND and Equality','AND',3,'p_AND','fort.py',314), + ('Equality -> EItem EQSymbols EItem','Equality',3,'p_Equality','fort.py',319), + ('Equality -> openParen EL closedParen','Equality',3,'p_Equality','fort.py',320), + ('Equality -> not EL','Equality',2,'p_Equality','fort.py',321), + ('EItem -> Dimensional action_1','EItem',2,'p_EItem','fort.py',326), + ('EItem -> int action_2','EItem',2,'p_EItem','fort.py',327), + ('EItem -> rea action_2','EItem',2,'p_EItem','fort.py',328), + ('EQSymbols -> less','EQSymbols',1,'p_EQSymbols','fort.py',333), + ('EQSymbols -> more','EQSymbols',1,'p_EQSymbols','fort.py',334), + ('EQSymbols -> doubleEquals','EQSymbols',1,'p_EQSymbols','fort.py',335), + ('EQSymbols -> notEquals','EQSymbols',1,'p_EQSymbols','fort.py',336), + ('EQSymbols -> lessEquals','EQSymbols',1,'p_EQSymbols','fort.py',337), + ('EQSymbols -> moreEquals','EQSymbols',1,'p_EQSymbols','fort.py',338), + ('action_1 -> ','action_1',0,'p_action_1','fort.py',343), + ('action_2 -> ','action_2',0,'p_action_2','fort.py',348), + ('action_3 -> ','action_3',0,'p_action_3','fort.py',352), + ('action_4 -> ','action_4',0,'p_action_4','fort.py',356), + ('action_5 -> ','action_5',0,'p_action_5','fort.py',368), + ('action_6 -> ','action_6',0,'p_action_6','fort.py',373), ] diff --git a/final_lang/stack.py b/final_lang/stack.py new file mode 100644 index 0000000..c5d830b --- /dev/null +++ b/final_lang/stack.py @@ -0,0 +1,20 @@ +class Stack: + def __init__(self): + self.items = [] + + def isEmpty(self): + return self.items == [] + + def push(self, item): + self.items.append(item) + + def pop(self): + return self.items.pop() + + def peek(self): + if (self.isEmpty): + return None + return self.items[len(self.items)-1] + + def size(self): + return len(self.items) \ No newline at end of file diff --git a/final_lang/test2.fort b/final_lang/test2.fort index f970386..f095164 100644 --- a/final_lang/test2.fort +++ b/final_lang/test2.fort @@ -1,5 +1,5 @@ program test integer :: a, b -a = 1 + 2 +a = (2 + 1) * 2 b = a end program \ No newline at end of file diff --git a/final_lang/test2.fort.out b/final_lang/test2.fort.out new file mode 100644 index 0000000..9677fba --- /dev/null +++ b/final_lang/test2.fort.out @@ -0,0 +1,2 @@ ++ 2 1 T0 +* T0 2 T1