Fixed issue with do statements with counter where artihmetic expressions couldn't be used as conditions only contants or variables, created the program 1
This commit is contained in:
parent
34d4697aa9
commit
c7d211f0b5
9 changed files with 426 additions and 101 deletions
6
final_lang/experiments.fort
Normal file
6
final_lang/experiments.fort
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
program test
|
||||
integer :: a
|
||||
do a = 0, 2+1 then
|
||||
print a, endline
|
||||
end do
|
||||
end program
|
||||
10
final_lang/experiments.fort.out
Normal file
10
final_lang/experiments.fort.out
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
goto 2
|
||||
= 0 $50
|
||||
+ 2 1 $0
|
||||
<= $50 $0 $1
|
||||
gotoF $1 11
|
||||
print $50
|
||||
print endline
|
||||
+ $50 1 $2
|
||||
= $2 $50
|
||||
goto 4
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
quads = ['= a b c', 'goto _', 'gotoF $2 _']
|
||||
|
||||
def fillGoto(position, fillValue):
|
||||
global quads
|
||||
quads[position] = quads[position].replace('_', str(fillValue))
|
||||
return
|
||||
|
||||
print(quads)
|
||||
fillGoto(1, 4)
|
||||
print(quads)
|
||||
fillGoto(2, 5)
|
||||
print(quads)
|
||||
|
|
@ -22,13 +22,13 @@ typesStack = []
|
|||
jumpsStack = []
|
||||
exitsStack = []
|
||||
avail = []
|
||||
for i in range(50):
|
||||
for i in range(200):
|
||||
avail.append('$' + str(i))
|
||||
|
||||
# Operations related to the table of symbols
|
||||
symbols = {}
|
||||
# Our variables start at direction 50, the temps take the first 49 directions.
|
||||
currentIndex = 50
|
||||
currentIndex = 200
|
||||
|
||||
# Multi dimensional variables dimensions just for declaration.
|
||||
globalDimension1 = 0
|
||||
|
|
@ -809,8 +809,6 @@ def p_action_26(p):
|
|||
jumpsStack.append(quadrupletIndex)
|
||||
resultQuadruplets.append(f'gotoF {str(temp)} _\n')
|
||||
quadrupletIndex += 1
|
||||
if (isTemp(operand2)):
|
||||
avail = [operand2.replace('*', '$')] + avail
|
||||
if (isTemp(operand1)):
|
||||
avail = [operand1.replace('*', '$')] + avail
|
||||
|
||||
|
|
|
|||
|
|
@ -27,82 +27,82 @@ for _k, _v in _lr_goto_items.items():
|
|||
del _lr_goto_items
|
||||
_lr_productions = [
|
||||
("S' -> programa","S'",1,None,None,None),
|
||||
('programa -> program action_37 id V F action_38 B end program','programa',9,'p_programa','fort.py',225),
|
||||
('V -> V Tipo Dim doubleColon Rid action_addSymbols action_32','V',7,'p_V','fort.py',232),
|
||||
('V -> <empty>','V',0,'p_V','fort.py',233),
|
||||
('Rid -> id','Rid',1,'p_Rid','fort.py',239),
|
||||
('Rid -> Rid coma id','Rid',3,'p_Rid','fort.py',240),
|
||||
('Tipo -> integer','Tipo',1,'p_Tipo','fort.py',252),
|
||||
('Tipo -> real','Tipo',1,'p_Tipo','fort.py',253),
|
||||
('Dim -> openBra int action_30 closedBra','Dim',4,'p_Dim','fort.py',261),
|
||||
('Dim -> openBra int action_30 closedBra openBra int action_31 closedBra','Dim',8,'p_Dim','fort.py',262),
|
||||
('Dim -> <empty>','Dim',0,'p_Dim','fort.py',263),
|
||||
('F -> F subroutine id action_39 B end subroutine action_40','F',8,'p_F','fort.py',269),
|
||||
('F -> <empty>','F',0,'p_F','fort.py',270),
|
||||
('B -> B S','B',2,'p_B','fort.py',276),
|
||||
('B -> <empty>','B',0,'p_B','fort.py',277),
|
||||
('S -> Dimensional equals EA action_8','S',4,'p_S','fort.py',283),
|
||||
('S -> id parens action_41','S',3,'p_S','fort.py',284),
|
||||
('S -> read RDimensional','S',2,'p_S','fort.py',285),
|
||||
('S -> print RDimOrString','S',2,'p_S','fort.py',286),
|
||||
('S -> if action_16 Relif ElseOrEmpty end if action_20','S',7,'p_S','fort.py',287),
|
||||
('S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do','S',15,'p_S','fort.py',288),
|
||||
('S -> do then action_21 B action_22 end do','S',7,'p_S','fort.py',289),
|
||||
('S -> swap Dimensional coma Dimensional','S',4,'p_S','fort.py',290),
|
||||
('S -> exit action_23','S',2,'p_S','fort.py',291),
|
||||
('Dimensional -> id DimensionsOrEmpty action_1','Dimensional',3,'p_Dimensional','fort.py',299),
|
||||
('DimensionsOrEmpty -> openParen EA action_setDim1 ComaEAOrEmpty closedParen','DimensionsOrEmpty',5,'p_DimensionsOrEmpty','fort.py',306),
|
||||
('DimensionsOrEmpty -> <empty>','DimensionsOrEmpty',0,'p_DimensionsOrEmpty','fort.py',307),
|
||||
('ComaEAOrEmpty -> coma EA action_setDim2','ComaEAOrEmpty',3,'p_ComaEAOrEmpty','fort.py',313),
|
||||
('ComaEAOrEmpty -> <empty>','ComaEAOrEmpty',0,'p_ComaEAOrEmpty','fort.py',314),
|
||||
('RDimensional -> Dimensional action_36','RDimensional',2,'p_RDimensional','fort.py',320),
|
||||
('RDimensional -> RDimensional coma Dimensional action_36','RDimensional',4,'p_RDimensional','fort.py',321),
|
||||
('RDimOrString -> DimOrString','RDimOrString',1,'p_RDimOrString','fort.py',327),
|
||||
('RDimOrString -> RDimOrString coma DimOrString','RDimOrString',3,'p_RDimOrString','fort.py',328),
|
||||
('DimOrString -> Dimensional action_33','DimOrString',2,'p_DimOrString','fort.py',334),
|
||||
('DimOrString -> string action_34','DimOrString',2,'p_DimOrString','fort.py',335),
|
||||
('DimOrString -> endline action_34','DimOrString',2,'p_DimOrString','fort.py',336),
|
||||
('Relif -> openParen EL closedParen action_17 then B','Relif',6,'p_Relif','fort.py',342),
|
||||
('Relif -> Relif elif action_18 openParen EL closedParen action_17 then B','Relif',9,'p_Relif','fort.py',343),
|
||||
('ElseOrEmpty -> else action_19 B','ElseOrEmpty',3,'p_ElseOrEmpty','fort.py',349),
|
||||
('ElseOrEmpty -> <empty>','ElseOrEmpty',0,'p_ElseOrEmpty','fort.py',350),
|
||||
('IntOrEmpty -> coma int action_28','IntOrEmpty',3,'p_IntOrEmpty','fort.py',356),
|
||||
('IntOrEmpty -> action_27','IntOrEmpty',1,'p_IntOrEmpty','fort.py',357),
|
||||
('EA -> MultDiv','EA',1,'p_EA','fort.py',363),
|
||||
('EA -> EA SumOrSub action_3 MultDiv action_4','EA',5,'p_EA','fort.py',364),
|
||||
('SumOrSub -> plus','SumOrSub',1,'p_SumOrSub','fort.py',370),
|
||||
('SumOrSub -> minus','SumOrSub',1,'p_SumOrSub','fort.py',371),
|
||||
('MultDiv -> EAParens','MultDiv',1,'p_MultDiv','fort.py',378),
|
||||
('MultDiv -> MultDiv MDSymbols action_5 EAParens action_6','MultDiv',5,'p_MultDiv','fort.py',379),
|
||||
('MDSymbols -> mul','MDSymbols',1,'p_MDSymbols','fort.py',385),
|
||||
('MDSymbols -> div','MDSymbols',1,'p_MDSymbols','fort.py',386),
|
||||
('EAParens -> EItem','EAParens',1,'p_EAParens','fort.py',393),
|
||||
('EAParens -> openParen EA closedParen','EAParens',3,'p_EAParens','fort.py',394),
|
||||
('EL -> AND','EL',1,'p_EL','fort.py',400),
|
||||
('EL -> EL or action_10 AND action_9','EL',5,'p_EL','fort.py',401),
|
||||
('AND -> Equality','AND',1,'p_AND','fort.py',407),
|
||||
('AND -> AND and action_12 Equality action_11','AND',5,'p_AND','fort.py',408),
|
||||
('Equality -> EItem EQSymbols action_13 EItem action_14','Equality',5,'p_Equality','fort.py',414),
|
||||
('Equality -> openParen EL closedParen','Equality',3,'p_Equality','fort.py',415),
|
||||
('Equality -> not EL action_15','Equality',3,'p_Equality','fort.py',416),
|
||||
('EItem -> Dimensional','EItem',1,'p_EItem','fort.py',422),
|
||||
('EItem -> int action_2','EItem',2,'p_EItem','fort.py',423),
|
||||
('EItem -> rea action_2_rea','EItem',2,'p_EItem','fort.py',424),
|
||||
('EQSymbols -> less','EQSymbols',1,'p_EQSymbols','fort.py',430),
|
||||
('EQSymbols -> more','EQSymbols',1,'p_EQSymbols','fort.py',431),
|
||||
('EQSymbols -> doubleEquals','EQSymbols',1,'p_EQSymbols','fort.py',432),
|
||||
('EQSymbols -> notEquals','EQSymbols',1,'p_EQSymbols','fort.py',433),
|
||||
('EQSymbols -> lessEquals','EQSymbols',1,'p_EQSymbols','fort.py',434),
|
||||
('EQSymbols -> moreEquals','EQSymbols',1,'p_EQSymbols','fort.py',435),
|
||||
('action_addSymbols -> <empty>','action_addSymbols',0,'p_action_addSymbols','fort.py',445),
|
||||
('action_1 -> <empty>','action_1',0,'p_action_1','fort.py',451),
|
||||
('action_2 -> <empty>','action_2',0,'p_action_2','fort.py',499),
|
||||
('action_2_rea -> <empty>','action_2_rea',0,'p_action_2_rea','fort.py',505),
|
||||
('action_3 -> <empty>','action_3',0,'p_action_3','fort.py',511),
|
||||
('action_4 -> <empty>','action_4',0,'p_action_4','fort.py',516),
|
||||
('action_5 -> <empty>','action_5',0,'p_action_5','fort.py',539),
|
||||
('action_6 -> <empty>','action_6',0,'p_action_6','fort.py',544),
|
||||
('action_8 -> <empty>','action_8',0,'p_action_8','fort.py',567),
|
||||
('programa -> program action_37 id V F action_38 B end program','programa',9,'p_programa','fort.py',223),
|
||||
('V -> V Tipo Dim doubleColon Rid action_addSymbols action_32','V',7,'p_V','fort.py',230),
|
||||
('V -> <empty>','V',0,'p_V','fort.py',231),
|
||||
('Rid -> id','Rid',1,'p_Rid','fort.py',237),
|
||||
('Rid -> Rid coma id','Rid',3,'p_Rid','fort.py',238),
|
||||
('Tipo -> integer','Tipo',1,'p_Tipo','fort.py',250),
|
||||
('Tipo -> real','Tipo',1,'p_Tipo','fort.py',251),
|
||||
('Dim -> openBra int action_30 closedBra','Dim',4,'p_Dim','fort.py',259),
|
||||
('Dim -> openBra int action_30 closedBra openBra int action_31 closedBra','Dim',8,'p_Dim','fort.py',260),
|
||||
('Dim -> <empty>','Dim',0,'p_Dim','fort.py',261),
|
||||
('F -> F subroutine id action_39 B end subroutine action_40','F',8,'p_F','fort.py',267),
|
||||
('F -> <empty>','F',0,'p_F','fort.py',268),
|
||||
('B -> B S','B',2,'p_B','fort.py',274),
|
||||
('B -> <empty>','B',0,'p_B','fort.py',275),
|
||||
('S -> Dimensional equals EA action_8','S',4,'p_S','fort.py',281),
|
||||
('S -> id parens action_41','S',3,'p_S','fort.py',282),
|
||||
('S -> read RDimensional','S',2,'p_S','fort.py',283),
|
||||
('S -> print RDimOrString','S',2,'p_S','fort.py',284),
|
||||
('S -> if action_16 Relif ElseOrEmpty end if action_20','S',7,'p_S','fort.py',285),
|
||||
('S -> do id action_24 equals EA action_25 coma EA action_26 IntOrEmpty then B action_29 end do','S',15,'p_S','fort.py',286),
|
||||
('S -> do then action_21 B action_22 end do','S',7,'p_S','fort.py',287),
|
||||
('S -> swap Dimensional coma Dimensional','S',4,'p_S','fort.py',288),
|
||||
('S -> exit action_23','S',2,'p_S','fort.py',289),
|
||||
('Dimensional -> id DimensionsOrEmpty action_1','Dimensional',3,'p_Dimensional','fort.py',297),
|
||||
('DimensionsOrEmpty -> openParen EA action_setDim1 ComaEAOrEmpty closedParen','DimensionsOrEmpty',5,'p_DimensionsOrEmpty','fort.py',304),
|
||||
('DimensionsOrEmpty -> <empty>','DimensionsOrEmpty',0,'p_DimensionsOrEmpty','fort.py',305),
|
||||
('ComaEAOrEmpty -> coma EA action_setDim2','ComaEAOrEmpty',3,'p_ComaEAOrEmpty','fort.py',311),
|
||||
('ComaEAOrEmpty -> <empty>','ComaEAOrEmpty',0,'p_ComaEAOrEmpty','fort.py',312),
|
||||
('RDimensional -> Dimensional action_36','RDimensional',2,'p_RDimensional','fort.py',318),
|
||||
('RDimensional -> RDimensional coma Dimensional action_36','RDimensional',4,'p_RDimensional','fort.py',319),
|
||||
('RDimOrString -> DimOrString','RDimOrString',1,'p_RDimOrString','fort.py',325),
|
||||
('RDimOrString -> RDimOrString coma DimOrString','RDimOrString',3,'p_RDimOrString','fort.py',326),
|
||||
('DimOrString -> Dimensional action_33','DimOrString',2,'p_DimOrString','fort.py',332),
|
||||
('DimOrString -> string action_34','DimOrString',2,'p_DimOrString','fort.py',333),
|
||||
('DimOrString -> endline action_34','DimOrString',2,'p_DimOrString','fort.py',334),
|
||||
('Relif -> openParen EL closedParen action_17 then B','Relif',6,'p_Relif','fort.py',340),
|
||||
('Relif -> Relif elif action_18 openParen EL closedParen action_17 then B','Relif',9,'p_Relif','fort.py',341),
|
||||
('ElseOrEmpty -> else action_19 B','ElseOrEmpty',3,'p_ElseOrEmpty','fort.py',347),
|
||||
('ElseOrEmpty -> <empty>','ElseOrEmpty',0,'p_ElseOrEmpty','fort.py',348),
|
||||
('IntOrEmpty -> coma int action_28','IntOrEmpty',3,'p_IntOrEmpty','fort.py',354),
|
||||
('IntOrEmpty -> action_27','IntOrEmpty',1,'p_IntOrEmpty','fort.py',355),
|
||||
('EA -> MultDiv','EA',1,'p_EA','fort.py',361),
|
||||
('EA -> EA SumOrSub action_3 MultDiv action_4','EA',5,'p_EA','fort.py',362),
|
||||
('SumOrSub -> plus','SumOrSub',1,'p_SumOrSub','fort.py',368),
|
||||
('SumOrSub -> minus','SumOrSub',1,'p_SumOrSub','fort.py',369),
|
||||
('MultDiv -> EAParens','MultDiv',1,'p_MultDiv','fort.py',376),
|
||||
('MultDiv -> MultDiv MDSymbols action_5 EAParens action_6','MultDiv',5,'p_MultDiv','fort.py',377),
|
||||
('MDSymbols -> mul','MDSymbols',1,'p_MDSymbols','fort.py',383),
|
||||
('MDSymbols -> div','MDSymbols',1,'p_MDSymbols','fort.py',384),
|
||||
('EAParens -> EItem','EAParens',1,'p_EAParens','fort.py',391),
|
||||
('EAParens -> openParen EA closedParen','EAParens',3,'p_EAParens','fort.py',392),
|
||||
('EL -> AND','EL',1,'p_EL','fort.py',398),
|
||||
('EL -> EL or action_10 AND action_9','EL',5,'p_EL','fort.py',399),
|
||||
('AND -> Equality','AND',1,'p_AND','fort.py',405),
|
||||
('AND -> AND and action_12 Equality action_11','AND',5,'p_AND','fort.py',406),
|
||||
('Equality -> EItem EQSymbols action_13 EItem action_14','Equality',5,'p_Equality','fort.py',412),
|
||||
('Equality -> openParen EL closedParen','Equality',3,'p_Equality','fort.py',413),
|
||||
('Equality -> not EL action_15','Equality',3,'p_Equality','fort.py',414),
|
||||
('EItem -> Dimensional','EItem',1,'p_EItem','fort.py',420),
|
||||
('EItem -> int action_2','EItem',2,'p_EItem','fort.py',421),
|
||||
('EItem -> rea action_2_rea','EItem',2,'p_EItem','fort.py',422),
|
||||
('EQSymbols -> less','EQSymbols',1,'p_EQSymbols','fort.py',428),
|
||||
('EQSymbols -> more','EQSymbols',1,'p_EQSymbols','fort.py',429),
|
||||
('EQSymbols -> doubleEquals','EQSymbols',1,'p_EQSymbols','fort.py',430),
|
||||
('EQSymbols -> notEquals','EQSymbols',1,'p_EQSymbols','fort.py',431),
|
||||
('EQSymbols -> lessEquals','EQSymbols',1,'p_EQSymbols','fort.py',432),
|
||||
('EQSymbols -> moreEquals','EQSymbols',1,'p_EQSymbols','fort.py',433),
|
||||
('action_addSymbols -> <empty>','action_addSymbols',0,'p_action_addSymbols','fort.py',443),
|
||||
('action_1 -> <empty>','action_1',0,'p_action_1','fort.py',449),
|
||||
('action_2 -> <empty>','action_2',0,'p_action_2','fort.py',497),
|
||||
('action_2_rea -> <empty>','action_2_rea',0,'p_action_2_rea','fort.py',503),
|
||||
('action_3 -> <empty>','action_3',0,'p_action_3','fort.py',509),
|
||||
('action_4 -> <empty>','action_4',0,'p_action_4','fort.py',514),
|
||||
('action_5 -> <empty>','action_5',0,'p_action_5','fort.py',537),
|
||||
('action_6 -> <empty>','action_6',0,'p_action_6','fort.py',542),
|
||||
('action_8 -> <empty>','action_8',0,'p_action_8','fort.py',565),
|
||||
('action_9 -> <empty>','action_9',0,'p_action_9','fort.py',585),
|
||||
('action_10 -> <empty>','action_10',0,'p_action_10','fort.py',608),
|
||||
('action_11 -> <empty>','action_11',0,'p_action_11','fort.py',613),
|
||||
|
|
@ -128,13 +128,13 @@ _lr_productions = [
|
|||
('action_31 -> <empty>','action_31',0,'p_action_31','fort.py',863),
|
||||
('action_32 -> <empty>','action_32',0,'p_action_32','fort.py',871),
|
||||
('action_33 -> <empty>','action_33',0,'p_action_33','fort.py',881),
|
||||
('action_34 -> <empty>','action_34',0,'p_action_34','fort.py',890),
|
||||
('action_36 -> <empty>','action_36',0,'p_action_36','fort.py',897),
|
||||
('action_37 -> <empty>','action_37',0,'p_action_37','fort.py',906),
|
||||
('action_38 -> <empty>','action_38',0,'p_action_38','fort.py',913),
|
||||
('action_39 -> <empty>','action_39',0,'p_action_39','fort.py',919),
|
||||
('action_40 -> <empty>','action_40',0,'p_action_40','fort.py',926),
|
||||
('action_41 -> <empty>','action_41',0,'p_action_41','fort.py',933),
|
||||
('action_setDim1 -> <empty>','action_setDim1',0,'p_action_setDim1','fort.py',947),
|
||||
('action_setDim2 -> <empty>','action_setDim2',0,'p_action_setDim2','fort.py',958),
|
||||
('action_34 -> <empty>','action_34',0,'p_action_34','fort.py',893),
|
||||
('action_36 -> <empty>','action_36',0,'p_action_36','fort.py',900),
|
||||
('action_37 -> <empty>','action_37',0,'p_action_37','fort.py',909),
|
||||
('action_38 -> <empty>','action_38',0,'p_action_38','fort.py',916),
|
||||
('action_39 -> <empty>','action_39',0,'p_action_39','fort.py',922),
|
||||
('action_40 -> <empty>','action_40',0,'p_action_40','fort.py',929),
|
||||
('action_41 -> <empty>','action_41',0,'p_action_41','fort.py',936),
|
||||
('action_setDim1 -> <empty>','action_setDim1',0,'p_action_setDim1','fort.py',948),
|
||||
('action_setDim2 -> <empty>','action_setDim2',0,'p_action_setDim2','fort.py',959),
|
||||
]
|
||||
|
|
|
|||
105
final_lang/programa1.fort
Normal file
105
final_lang/programa1.fort
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
program p1
|
||||
integer [5][5] :: m1, m2, m3
|
||||
integer :: i, j, k, cTemp, rTemp, temp, option
|
||||
integer [3] :: columns, rows
|
||||
subroutine readDim
|
||||
do then
|
||||
print 'Enter number of rows: '
|
||||
read rTemp
|
||||
if (rTemp <= 5 .and. rTemp > 0) then
|
||||
exit
|
||||
end if
|
||||
print 'number of rows must be greater than 0 and less than 6', endline
|
||||
end do
|
||||
do then
|
||||
print 'Enter number of columns: '
|
||||
read cTemp
|
||||
if (cTemp <= 5 .and. cTemp > 0) then
|
||||
exit
|
||||
end if
|
||||
print 'number of columns must be greater than 0 and less than 6', endline
|
||||
end do
|
||||
end subroutine
|
||||
subroutine readM1
|
||||
do i = 0, rows(0) - 1 then
|
||||
do j = 0, columns(0) - 1 then
|
||||
print 'Enter value (', i, ',', j, ') for matrix 1', endline
|
||||
read m1(i,j)
|
||||
end do
|
||||
end do
|
||||
end subroutine
|
||||
subroutine readM2
|
||||
do i = 0, rows(1) - 1 then
|
||||
do j = 0, columns(1) - 1 then
|
||||
print 'Enter value (', i, ',', j, ') for matrix 2', endline
|
||||
read m2(i,j)
|
||||
end do
|
||||
end do
|
||||
end subroutine
|
||||
subroutine sumMats
|
||||
do i = 0, rows(0) - 1 then
|
||||
do j = 0, columns(0) - 1 then
|
||||
m3(i,j) = m1(i,j) + m2(i,j)
|
||||
end do
|
||||
end do
|
||||
end subroutine
|
||||
subroutine multMats
|
||||
do i = 0, rows(2) - 1 then
|
||||
do j = 0, columns(2) - 1 then
|
||||
temp = 0
|
||||
do k = 0, columns(0) - 1 then
|
||||
temp = temp + m1(i,k) * m2(k,j)
|
||||
end do
|
||||
m3(i,j) = temp
|
||||
end do
|
||||
end do
|
||||
end subroutine
|
||||
subroutine printResult
|
||||
do i = 0, rows(2) - 1 then
|
||||
do j = 0, columns(2) - 1 then
|
||||
print m3(i,j), ' '
|
||||
end do
|
||||
print endline
|
||||
end do
|
||||
end subroutine
|
||||
do temp = 1, 2 then
|
||||
print 'Enter dimensions for matrix ', temp, endline
|
||||
readDim()
|
||||
rows(temp - 1) = rTemp
|
||||
columns(temp - 1) = cTemp
|
||||
end do
|
||||
readM1()
|
||||
readM2()
|
||||
do then
|
||||
print 'Choose and option', endline
|
||||
print '1 - Multiply the matrices', endline
|
||||
print '2 - Sum the matrices', endline
|
||||
read option
|
||||
if (option == 1) then
|
||||
if (columns(0) == rows(1)) then
|
||||
rows(2) = rows(0)
|
||||
columns(2) = columns(1)
|
||||
multMats()
|
||||
printResult()
|
||||
else
|
||||
print 'Sorry cannnot multiply matrices with theses dimensions', endline
|
||||
end if
|
||||
elif (option == 2) then
|
||||
if (rows(0) == rows(1) .and. columns(0) == columns(1)) then
|
||||
rows(2) = rows(0)
|
||||
columns(2) = columns(0)
|
||||
sumMats()
|
||||
printResult()
|
||||
else
|
||||
print 'Sorry cannnot sum matrices with theses dimensions', endline
|
||||
end if
|
||||
else
|
||||
print 'Not a valid option', endline
|
||||
end if
|
||||
print 'Would you like to make another calculation? (type 1 for yes or 0 for no)', endline
|
||||
read option
|
||||
if (option == 0) then
|
||||
exit
|
||||
end if
|
||||
end do
|
||||
end program
|
||||
215
final_lang/programa1.fort.out
Normal file
215
final_lang/programa1.fort.out
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
goto 156
|
||||
print 'Enter number of rows: '
|
||||
read $279
|
||||
<= $279 5 $0
|
||||
> $279 0 $1
|
||||
.and. $0 $1 $2
|
||||
gotoF $2 9
|
||||
goto 12
|
||||
print 'number of rows must be greater than 0 and less than 6'
|
||||
print endline
|
||||
goto 2
|
||||
print 'Enter number of columns: '
|
||||
read $278
|
||||
<= $278 5 $2
|
||||
> $278 0 $0
|
||||
.and. $2 $0 $1
|
||||
gotoF $1 19
|
||||
goto 22
|
||||
print 'number of columns must be greater than 0 and less than 6'
|
||||
print endline
|
||||
goto 12
|
||||
goback
|
||||
= 0 $275
|
||||
- $285 1 $2
|
||||
<= $275 $2 $0
|
||||
gotoF $0 47
|
||||
= 0 $276
|
||||
- $282 1 $4
|
||||
<= $276 $4 $5
|
||||
gotoF $5 44
|
||||
print 'Enter value ('
|
||||
print $275
|
||||
print ','
|
||||
print $276
|
||||
print ') for matrix 1'
|
||||
print endline
|
||||
* $275 5 $6
|
||||
+ $276 $6 $6
|
||||
+ 200 $6 $6
|
||||
read *6
|
||||
+ $276 1 $7
|
||||
= $7 $276
|
||||
goto 29
|
||||
+ $275 1 $7
|
||||
= $7 $275
|
||||
goto 25
|
||||
goback
|
||||
= 0 $275
|
||||
- $286 1 $8
|
||||
<= $275 $8 $9
|
||||
gotoF $9 72
|
||||
= 0 $276
|
||||
- $283 1 $11
|
||||
<= $276 $11 $12
|
||||
gotoF $12 69
|
||||
print 'Enter value ('
|
||||
print $275
|
||||
print ','
|
||||
print $276
|
||||
print ') for matrix 2'
|
||||
print endline
|
||||
* $275 5 $13
|
||||
+ $276 $13 $13
|
||||
+ 225 $13 $13
|
||||
read *13
|
||||
+ $276 1 $14
|
||||
= $14 $276
|
||||
goto 54
|
||||
+ $275 1 $14
|
||||
= $14 $275
|
||||
goto 50
|
||||
goback
|
||||
= 0 $275
|
||||
- $285 1 $15
|
||||
<= $275 $15 $16
|
||||
gotoF $16 98
|
||||
= 0 $276
|
||||
- $282 1 $18
|
||||
<= $276 $18 $19
|
||||
gotoF $19 95
|
||||
* $275 5 $20
|
||||
+ $276 $20 $20
|
||||
+ 250 $20 $20
|
||||
* $275 5 $21
|
||||
+ $276 $21 $21
|
||||
+ 200 $21 $21
|
||||
* $275 5 $22
|
||||
+ $276 $22 $22
|
||||
+ 225 $22 $22
|
||||
+ *21 *22 $23
|
||||
= $23 *20
|
||||
+ $276 1 $20
|
||||
= $20 $276
|
||||
goto 79
|
||||
+ $275 1 $20
|
||||
= $20 $275
|
||||
goto 75
|
||||
goback
|
||||
= 0 $275
|
||||
- $287 1 $23
|
||||
<= $275 $23 $21
|
||||
gotoF $21 134
|
||||
= 0 $276
|
||||
- $284 1 $24
|
||||
<= $276 $24 $25
|
||||
gotoF $25 131
|
||||
= 0 $280
|
||||
= 0 $277
|
||||
- $282 1 $27
|
||||
<= $277 $27 $28
|
||||
gotoF $28 124
|
||||
* $275 5 $29
|
||||
+ $277 $29 $29
|
||||
+ 200 $29 $29
|
||||
* $277 5 $30
|
||||
+ $276 $30 $30
|
||||
+ 225 $30 $30
|
||||
* *29 *30 $31
|
||||
+ $280 $31 $29
|
||||
= $29 $280
|
||||
+ $277 1 $29
|
||||
= $29 $277
|
||||
goto 110
|
||||
* $275 5 $29
|
||||
+ $276 $29 $29
|
||||
+ 250 $29 $29
|
||||
= $280 *29
|
||||
+ $276 1 $29
|
||||
= $29 $276
|
||||
goto 105
|
||||
+ $275 1 $29
|
||||
= $29 $275
|
||||
goto 101
|
||||
goback
|
||||
= 0 $275
|
||||
- $287 1 $31
|
||||
<= $275 $31 $30
|
||||
gotoF $30 155
|
||||
= 0 $276
|
||||
- $284 1 $33
|
||||
<= $276 $33 $34
|
||||
gotoF $34 151
|
||||
* $275 5 $35
|
||||
+ $276 $35 $35
|
||||
+ 250 $35 $35
|
||||
print *35
|
||||
print ' '
|
||||
+ $276 1 $35
|
||||
= $35 $276
|
||||
goto 141
|
||||
print endline
|
||||
+ $275 1 $35
|
||||
= $35 $275
|
||||
goto 137
|
||||
goback
|
||||
= 1 $280
|
||||
<= $280 2 $35
|
||||
gotoF $35 172
|
||||
print 'Enter dimensions for matrix '
|
||||
print $280
|
||||
print endline
|
||||
call 2
|
||||
- $280 1 $36
|
||||
+ 285 $36 $37
|
||||
= $279 *37
|
||||
- $280 1 $37
|
||||
+ 282 $37 $38
|
||||
= $278 *38
|
||||
+ $280 1 $38
|
||||
= $38 $280
|
||||
goto 157
|
||||
call 23
|
||||
call 48
|
||||
print 'Choose and option'
|
||||
print endline
|
||||
print '1 - Multiply the matrices'
|
||||
print endline
|
||||
print '2 - Sum the matrices'
|
||||
print endline
|
||||
read $281
|
||||
== $281 1 $38
|
||||
gotoF $38 193
|
||||
== $282 $286 $40
|
||||
gotoF $40 190
|
||||
= $285 $287
|
||||
= $283 $284
|
||||
call 99
|
||||
call 135
|
||||
goto 192
|
||||
print 'Sorry cannnot multiply matrices with theses dimensions'
|
||||
print endline
|
||||
goto 209
|
||||
== $281 2 $44
|
||||
gotoF $44 207
|
||||
== $285 $286 $46
|
||||
== $282 $283 $49
|
||||
.and. $46 $49 $50
|
||||
gotoF $50 204
|
||||
= $285 $287
|
||||
= $282 $284
|
||||
call 73
|
||||
call 135
|
||||
goto 206
|
||||
print 'Sorry cannnot sum matrices with theses dimensions'
|
||||
print endline
|
||||
goto 209
|
||||
print 'Not a valid option'
|
||||
print endline
|
||||
print 'Would you like to make another calculation? (type 1 for yes or 0 for no)'
|
||||
print endline
|
||||
read $281
|
||||
== $281 0 $53
|
||||
gotoF $53 215
|
||||
goto 216
|
||||
goto 174
|
||||
|
|
@ -10,4 +10,5 @@ print 'a(j) = ', a(j), endline
|
|||
a(i) = a(j) + a(i)
|
||||
print 'a(i) = ', a(i), endline
|
||||
i = j + 2
|
||||
print i, endline
|
||||
end program
|
||||
|
|
@ -40,3 +40,5 @@ print *0
|
|||
print endline
|
||||
+ $151 2 $0
|
||||
= $0 $150
|
||||
print $150
|
||||
print endline
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue