-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRiperPar.py
744 lines (596 loc) · 21.8 KB
/
RiperPar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
#To compile
#python RiperLex.py
#python RiperPar.py test.riper
import ply.yacc as yacc
import sys
import copy
import RiperLex
import CodeGeneration
from CodeGeneration import *
import Settings
from time import time
from VirtualMachine import *
# Variables needed for array index calculation
global R
R = 1
global arrDimensionDeclaration
arrDimensionDeclaration = []
# import the lexical tokens
tokens = RiperLex.tokens
# Global Riper code structure
def p_program(p):
'''program : globalVarDeclar generateGotoMain functionDeclar main'''
# This is a complete and correct program, generate the EndProc quadruple
GenerateRIPQuadruple()
# Generates the first quadruple to the main function
def p_generateGotoMain(p):
'''generateGotoMain : '''
GenerateGotoMainQuadruple()
# Global variable declaration section
def p_globalVarDeclar(p):
'''globalVarDeclar : initVarDeclar '''
if (len(p) > 1):
global localDirectory
if (len(localDirectory) > 0):
Settings.globalDirectory = localDirectory.copy()
localDirectory = {}
global globalTemporals
globalTemporals = Settings.memoryMap[1][1]
# Variable initialization section
def p_initVarDeclar(p):
'''initVarDeclar : varDeclar initVarDeclar
| '''
# Function declaration section
def p_functionDeclar(p):
'''functionDeclar : function functionDeclar
| '''
# Variable or array declaration statute
def p_varDeclar(p):
'''varDeclar : vars ';'
| ARRAY arrays ';' '''
# Variable declaration statue
def p_vars(p):
'''vars : type ID '=' expressionInput moreVar'''
if (len(p) > 1):
global localDirectory
if (p[2] in localDirectory or p[2] in Settings.globalDirectory):
print("ERROR, variable ", p[2], " has already been declared")
sys.exit()
else:
localDirectory[p[2]] = (0, currentType, Settings.memoryMap[insideFunction[0]][0][currentType])
operandStack.append((currentType, Settings.memoryMap[insideFunction[0]][0][currentType]))
operatorStack.append(p[3])
GenerateExpQuadruple()
Settings.memoryMap[insideFunction[0]][0][currentType] = Settings.memoryMap[insideFunction[0]][0][currentType] + 1
# Grammar rule used when more than one variable is declared
def p_moreVar(p):
'''moreVar : ',' ID '=' expressionInput moreVar
| '''
if (len(p) > 1):
global localDirectory
if (p[2] in localDirectory or p[2] in Settings.globalDirectory):
global insideFunction
if(insideFunction[0] or Settings.globalDirectory[p[2]][0] == 1):
print("ERROR, variable ", p[2], " has already been declared")
sys.exit()
else:
localDirectory[p[2]] = (0, currentType, Settings.memoryMap[insideFunction[0]][0][currentType])
operandStack.append((currentType, Settings.memoryMap[insideFunction[0]][0][currentType]))
operatorStack.append(p[3])
GenerateExpQuadruple()
Settings.memoryMap[insideFunction[0]][0][currentType] = Settings.memoryMap[insideFunction[0]][0][currentType] + 1
# Grammar rulle used to match to one of the basic variable type declaration tokens
def p_type(p):
'''type : INTTYPE
| FLOATTYPE
| STRINGTYPE
| BOOLTYPE '''
if (len(p) > 1):
global currentType
currentType = opMap[p[1]]
def p_function(p):
'''function : FUNCTION funcType idStartFunction '(' par ')' '{' block '}' '''
Settings.globalDirectory[p[3]][2] = [[i - j for i, j in zip(Settings.memoryMap[1][0], resetMemoryMap[0])],
[i - j for i, j in zip(Settings.memoryMap[1][1], resetMemoryMap[1])]]
global localDirectory
global insideFunction
if(CodeGeneration.currentFuncType < 4 and not CodeGeneration.foundReturn):
print("Function %s with type %s does not have a return value" %(insideFunction[1], invOpMap[CodeGeneration.currentFuncType]))
sys.exit()
GenerateEndProcQuadruple()
insideFunction = [0, '']
localDirectory = {}
def p_funcType(p):
'''funcType : INTTYPE
| FLOATTYPE
| STRINGTYPE
| BOOLTYPE
| VOID '''
if (len(p) > 1):
CodeGeneration.currentFuncType = opMap[p[1]]
def p_idStartFunction(p):
'''idStartFunction : ID '''
global localDirectory
localDirectory = {}
jumpStack.append(len(quadruples))
Settings.memoryMap[1] = copy.deepcopy(resetMemoryMap)
if(debugParser):
print("Resetting Settings.memoryMap")
global insideFunction
Settings.globalDirectory[p[1]] = [CodeGeneration.currentFuncType, jumpStack.pop(), None, None, None]
if(CodeGeneration.currentFuncType != 4):
Settings.globalDirectory[p[1]][3] = Settings.memoryMap[0][0][CodeGeneration.currentFuncType]
Settings.memoryMap[0][0][CodeGeneration.currentFuncType] = Settings.memoryMap[0][0][CodeGeneration.currentFuncType] + 1
insideFunction = [1, p[1]]
p[0] = p[1]
def p_returnType(p):
'''returnType : RETURN expression ';' '''
GenerateReturnProcQuadruple(insideFunction[1])
CodeGeneration.foundReturn = True
def p_main(p):
'''main : MAIN startMainFunction completeMainQuadruple '(' par ')' '{' blockMain '}' '''
if (len(p) > 1):
global localDirectory
Settings.globalDirectory['main'][2] = [[i - j for i, j in zip(Settings.memoryMap[1][0], resetMemoryMap[0])],
[i - j for i, j in zip(Settings.memoryMap[1][1], resetMemoryMap[1])]]
global functionParameterDeclaration
Settings.globalDirectory['main'][4] = functionParameterDeclaration
functionParameterDeclaration = []
localDirectory = {}
def p_startMainFunction(p):
'''startMainFunction : '''
global localDirectory
localDirectory = {}
jumpStack.append(len(quadruples))
global insideFunction
insideFunction = [1, 'main']
Settings.memoryMap[1] = copy.deepcopy(resetMemoryMap)
if(debugParser):
print("Resetting Settings.memoryMap")
# Empty production used to complete the first GOTO quadruple to main function
def p_completeMainQuadruple(p):
'''completeMainQuadruple : '''
Settings.globalDirectory['main'] = [-1, len(quadruples), None, None, None]
CompleteQuadruple(0, 0)
def p_par(p):
'''par : typeID morePar
| '''
global functionParameterDeclaration
Settings.globalDirectory[insideFunction[1]][4] = functionParameterDeclaration
functionParameterDeclaration = []
def p_morePar(p):
'''morePar : ',' typeID morePar
| '''
def p_typeID(p):
'''typeID : type ID'''
global currentType
global functionParameterDeclaration
localDirectory[p[2]] = (0, currentType, Settings.memoryMap[insideFunction[0]][0][currentType])
functionParameterDeclaration.append(currentType)
# Save in inside local variables
Settings.memoryMap[insideFunction[0]][0][currentType] = Settings.memoryMap[insideFunction[0]][0][currentType] + 1
def p_funcCall(p):
'''funcCall : ID '(' verifyParameterStack parIn ')' '''
global currentParameterList
global parameterList
# functype, funcStart, memoryNeeded
matchedID = Settings.globalDirectory.get(p[1])
if (matchedID is None):
print("ERROR, variable ", p[1], " has not been declared")
sys.exit()
p[0] = GenerateFuncCallQuadruples(p[1], matchedID, currentParameterList)
currentParameterList = []
operatorStack.pop()
if(parameterList):
currentParameterList = parameterList.pop()
def p_verifyParameterStack(p):
'''verifyParameterStack : '''
global currentParameterList
global parameterList
operatorStack.append('(')
if(currentParameterList):
parameterList.append(currentParameterList)
currentParameterList = []
def p_parIn(p):
'''parIn : parameter moreParIn
| '''
def p_moreParIn(p):
'''moreParIn : ',' parameter moreParIn
| '''
def p_parameter(p):
'''parameter : expression'''
global currentParameterList
global parameterList
parameter = operandStack.pop()
currentParameterList.append(parameter)
def p_block(p):
'''block : varDeclar block
| assign block
| conditional block
| loop block
| funcCall ';' block
| output block
| returnType block
| '''
def p_blockMain(p):
'''blockMain : varDeclar blockMain
| assign blockMain
| conditional blockMain
| loop blockMain
| funcCall ';' blockMain
| output blockMain
| '''
def p_loopBlock(p):
'''loopBlock : assign loopBlock
| conditional loopBlock
| loop loopBlock
| funcCall ';' loopBlock
| output loopBlock
| returnType loopBlock
| '''
def p_assign(p):
'''assign : possibleArray '=' expressionInput ';' '''
matchedDataType = p[1]
if(isinstance(p[1],str)):
global localDirectory
matchedDataType = localDirectory.get(p[1])
if (matchedDataType is None):
matchedDataType = Settings.globalDirectory.get(p[1])
if (matchedDataType is None):
print("ERROR, variable ", p[1], " has not been declared")
sys.exit()
else:
matchedDataType = (matchedDataType[1], matchedDataType[2])
else:
matchedDataType = (matchedDataType[1], matchedDataType[2])
operandStack.append(matchedDataType)
operatorStack.append(p[2])
GenerateExpQuadruple()
def p_expressionInput(p):
'''expressionInput : expression
| input
| array '''
def p_possibleArray(p):
'''possibleArray : ID
| arrayAccess'''
p[0] = p[1]
def p_conditional(p):
'''conditional : IF appendConditionalCountStack '(' gotofIfExpression ')' '{' block '}' possibleElif possibleElse completeGotoQuadruples '''
def p_appendConditionalCountStack(p):
'''appendConditionalCountStack : '''
AppendConditionalCountStack()
def p_gotofIfExpression(p):
'''gotofIfExpression : expression '''
IncreaseConsitionalCountStack()
GenerateGotofQuadruple()
def p_possibleElif(p):
'''possibleElif : ELIF '(' completeQuadruplePlus1 generateGoto gotofIfExpression ')' '{' block '}' possibleElif
| '''
def p_completeQuadruplePlus1(p):
''' completeQuadruplePlus1 : '''
CompleteQuadruple(-1, 1)
def p_completeGotoQuadruples(p):
'''completeGotoQuadruples : '''
CompleteGotoQuadruples()
def p_possibleElse(p):
'''possibleElse : ELSE completeQuadruplePlus1 generateGoto '{' block '}'
| '''
def p_generateGoto(p):
'''generateGoto : '''
GenerateGotoQuadruple()
def p_output(p):
'''output : CONSOLE '(' outputExpression possibleOutputExpressions ')' ';' '''
def p_outputExpression(p):
'''outputExpression : expression '''
GenerateOutputQuadruple()
def p_possibleOutputExpressions(p):
'''possibleOutputExpressions : ',' outputExpression possibleOutputExpressions
| '''
def p_loop(p):
'''loop : for
| while
| doWhile '''
def p_for(p):
'''for : FOR '(' appendJump gotofForExpression generateGoto ';' appendJump assign gotoJumpMinus4 ')' '{' completeQuadrupleJumpMinus2 loopBlock gotoJump completeQuadruple '}' '''
def p_completeQuadruple(p):
'''completeQuadruple : '''
CompleteQuadruple(-1, 0)
def p_gotofForExpression(p):
'''gotofForExpression : expression'''
GenerateGotofQuadruple()
def p_gotoJumpMinus4(p):
'''gotoJumpMinus4 : '''
GotoJump(-4)
def p_completeQuadrupleJumpMinus2(p):
'''completeQuadrupleJumpMinus2 : '''
CompleteQuadruple(-2, 0)
def p_while(p):
'''while : WHILE '(' appendJump expression gotofWhileExpression ')' '{' loopBlock completeQuadruplePlus1 gotoJump '}' '''
def p_gotofWhileExpression(p):
'''gotofWhileExpression : '''
GenerateGotofQuadruple()
def p_gotoJump(p):
'''gotoJump : '''
GotoJump(-1)
def p_doWhile(p):
'''doWhile : DO appendJump '{' loopBlock '}' WHILE '(' gototExpression ')' ';' '''
def p_appendJump(p):
'''appendJump : '''
AppendJump()
def p_gototExpression(p):
'''gototExpression : expression '''
GenerateGototQuadruple()
def p_expression(p):
'''expression : higherExp1 possibleHigherExp1'''
def p_possibleHigherExp1(p):
'''possibleHigherExp1 : operatorOR higherExp1 possibleHigherExp1
| '''
def p_operatorOR(p):
'''operatorOR : OR '''
if(debugParser):
print("PUSH ||")
operatorStack.append(p[1])
def p_higherExp1(p):
'''higherExp1 : higherExp2 possibleHigherExp2'''
if (len(operatorStack) > 0 and operatorStack[-1] == '||'):
if(debugParser):
print("TOP " + operatorStack[-1] + ", GENERATING")
GenerateExpQuadruple()
def p_possibleHigherExp2(p):
'''possibleHigherExp2 : operatorAND higherExp2 possibleHigherExp2
| '''
def p_operatorAND(p):
'''operatorAND : AND '''
if(debugParser):
print("PUSH &&")
operatorStack.append(p[1])
def p_higherExp2(p):
'''higherExp2 : exp possibleExp'''
if (len(operatorStack) > 0 and operatorStack[-1] == '&&'):
if(debugParser):
print("TOP " + operatorStack[-1] + ", GENERATING")
GenerateExpQuadruple()
def p_possibleExp(p):
'''possibleExp : possibleExpOp exp
| '''
def p_possibleExpOp(p):
'''possibleExpOp : LESS
| GREATER
| LESSEQUAL
| GREATEREQUAL
| DIFFERENT
| EQUALTO '''
if(debugParser):
print("PUSHING", p[1])
operatorStack.append(p[1])
def p_exp(p):
'''exp : possibleSign term possibleTerms'''
if (len(operatorStack) > 0 and operatorStack[-1] in ['<', '>', '<=', '>=', '!=', '==']):
if(debugParser):
print("TOP " + operatorStack[-1] + ", GENERATING")
GenerateExpQuadruple()
def p_possibleTerms(p):
'''possibleTerms : possibleTermOp possibleSign term possibleTerms
| '''
def p_possibleSign(p):
'''possibleSign : '+'
| '-'
| '''
if(len(p) > 1):
operatorStack.append('*')
if(p[1] == '-'):
operandStack.append((0, constantDirectory[-1]))
else:
operandStack.append((0, constantDirectory[1]))
def p_possibleTermOp(p):
'''possibleTermOp : '+'
| '-' '''
if(debugParser):
print("PUSHING", p[1])
operatorStack.append(p[1])
def p_term(p):
'''term : factor possibleFactors'''
if (len(operatorStack) > 0 and operatorStack[-1] in ['+', '-']):
if(debugParser):
print("TOP +-, GENERATING")
GenerateExpQuadruple()
def p_possibleFactors(p):
'''possibleFactors : possibleFactorOp factor possibleFactors
| '''
if (len(p) == 1):
p[0] = ''
def p_possibleFactorOp(p):
'''possibleFactorOp : '*'
| '/'
| '%' '''
p[0] = p[1]
if(debugParser):
print("PUSHING ", p[1])
operatorStack.append(p[1])
def p_factor(p):
'''factor : lPar expression rPar
| data'''
if (len(p) == 2):
p[0] = p[1]
if (len(operatorStack) > 0 and operatorStack[-1] in ['*', '/', '%']):
if(debugParser):
print("TOP GENERATING ", operatorStack[-1])
GenerateExpQuadruple()
def p_lPar(p):
'''lPar : '(' '''
if(debugParser):
print("PUSH (")
operatorStack.append(p[1])
def p_rPar(p):
'''rPar : ')' '''
if(debugParser):
print("POP (")
operatorStack.pop()
if (len(operatorStack) > 0 and operatorStack[-1] in ['*', '/', '%']):
GenerateExpQuadruple()
def p_data(p):
'''data : constant
| ID
| funcCall
| arrayAccess '''
if(isinstance(p[1],str)):
global localDirectory
variableTuple = localDirectory.get(p[1])
if (variableTuple is None):
variableTuple = Settings.globalDirectory.get(p[1])
if (variableTuple is None):
print("ERROR, variable ", p[1], " has not been declared")
sys.exit()
elif(isinstance(variableTuple, list)):
print("ERROR, ", p[1], " is a function")
sys.exit()
else:
variableTuple = (variableTuple[1], variableTuple[2])
else:
variableTuple = (variableTuple[1], variableTuple[2])
else:
variableTuple = p[1]
if(debugParser):
print("PUSHING OPERAND ", variableTuple)
operandStack.append(variableTuple)
# Used if more arrays are to be declared
def p_arrays(p):
'''arrays : array moreArray '''
# Array grammar declaration
def p_array(p):
'''array : type ID '[' calculateR moreArrayDimensions '''
global R
global arrDimensionDeclaration
arraySize = R
for idx in range(len(arrDimensionDeclaration)):
R = R/arrDimensionDeclaration[idx][0]
if(R not in constantDirectory):
constantDirectory[R] = globalMemoryMap[1][0]
globalMemoryMap[1][0] = globalMemoryMap[1][0] + 1
arrDimensionDeclaration[idx][1] = constantDirectory[R]
R = 1
global localDirectory
if (p[2] in localDirectory or p[2] in Settings.globalDirectory):
print("ERROR, variable ", p[2], " has already been declared")
sys.exit()
else:
localDirectory[p[2]] = (0, currentType, Settings.memoryMap[insideFunction[0]][0][currentType], arrDimensionDeclaration)
Settings.memoryMap[insideFunction[0]][0][currentType] = Settings.memoryMap[insideFunction[0]][0][currentType] + arraySize
arrDimensionDeclaration = []
def p_moreArrayDimensions(p):
'''moreArrayDimensions : '[' calculateR moreArrayDimensions
| '''
def p_calculateR(p):
'''calculateR : INT ']' '''
global R
global arrDimensionDeclaration
R = R * p[1][1]
arrDimensionDeclaration.append([p[1][1], None])
global arrDimensions
arrDimensions = -1
prevArrayDimensions = []
prevArraySignature = []
currentArraySignature = None
prevArraySums = []
currentArraySum = 0
def p_moreArray(p):
'''moreArray : ',' array moreArray
| '''
def p_arrayAccess(p):
'''arrayAccess : startArrayAccess '[' calculateAddress dimensionAccess '''
global currentArraySignature
global arrDimensions
operatorStack.pop()
operatorStack.append('+')
operandStack.append((0, [currentArraySignature[2]]))
GenerateExpQuadruple()
p[0] = (currentArraySignature[1], [operandStack[-1][1]])
operandStack.pop()
if(arrDimensions != len(currentArraySignature[3])):
print("ERROR, dimension access mismatch for array '%s'" % p[1])
sys.exit()
if(prevArrayDimensions):
arrDimensions = prevArrayDimensions.pop()
def p_startArrayAccess(p):
'''startArrayAccess : ID '''
global arrDimensions
global prevArrayDimensions
global prevArraySignature
global currentArraySignature
if(arrDimensions):
prevArrayDimensions.append(arrDimensions)
prevArraySignature.append(currentArraySignature)
if(p[1] in localDirectory):
currentArraySignature = localDirectory.get(p[1])
elif(p[1] in Settings.globalDirectory):
currentArraySignature = Settings.globalDirectory.get(p[1])
else:
print("ERROR, array variable ", p[1], " has not been declared")
sys.exit()
arrDimensions = 0
operatorStack.append('(')
p[0] = p[1]
def p_calculateAddress(p):
'''calculateAddress : expression ']' '''
global arrDimensions
global currentArraySum
global currentArraySignature
quadruples.append(["VER", operandStack[-1][1], 0, currentArraySignature[3][arrDimensions][0]])
operatorStack.append('*')
operandStack.append((0, currentArraySignature[3][arrDimensions][1]))
GenerateExpQuadruple()
if(arrDimensions > 0):
operatorStack.append('+')
GenerateExpQuadruple()
arrDimensions = arrDimensions + 1
def p_dimensionAccess(p):
'''dimensionAccess : '[' calculateAddress dimensionAccess
| '''
def p_constant(p):
'''constant : INT
| FLOAT
| BOOL
| STRING'''
(constType, constValue) = p[1]
if(constValue not in constantDirectory):
constantDirectory[constValue] = globalMemoryMap[1][constType]
globalMemoryMap[1][constType] = globalMemoryMap[1][constType] + 1
p[0] = (constType, constantDirectory[constValue])
def p_input(p):
'''input : INPUT '(' inputPar ')' '''
p[0] = (0, 'INPUT', p[1])
GenerateInputQuadruple(p[3][1], currentType)
def p_inputPar(p):
'''inputPar : STRING
| '''
if(len(p) > 1):
p[0] = p[1]
else:
p[0] = ''
def p_error(p):
print('Syntax error in line %d token %s with value %s' % (p.lineno, p.type, p.value))
sys.exit()
# Build the parser
RiperParser = yacc.yacc(debug=False, write_tables=False)
def Run(data):
RiperParser.parse(data, debug = False, tracking=True)
quadrupleNumber = 0;
if(len(sys.argv) > 2 and sys.argv[2] == 'quadruples'):
for quadruple in quadruples:
print("%s \t %s" % (quadrupleNumber, quadruple))
quadrupleNumber += 1
Execute(globalMemoryMap, globalTemporals, Settings.globalDirectory, quadruples, constantDirectory)
if __name__ == '__main__':
if(sys.argv[1][0] == '#'):
data = sys.argv[2][:-1]
else:
f = open(sys.argv[2],'r')
data = f.read()
f.close()
RiperParser.parse(data, debug = False, tracking=True)
quadrupleNumber = 0;
if(len(sys.argv) > 3 and sys.argv[3] == 'quadruples'):
for quadruple in quadruples:
print("%s \t %s" % (quadrupleNumber, quadruple))
quadrupleNumber += 1
Execute(globalMemoryMap, globalTemporals, Settings.globalDirectory, quadruples, constantDirectory)