-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlanguage.py
619 lines (589 loc) · 26.3 KB
/
language.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
"""
MIT License
Copyright (c) 2022 SkiingIsFun123
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
from __future__ import division
import types
from pyparsing import (Literal, CaselessLiteral, Word, Combine, Group, Optional, ZeroOrMore, Forward, nums, alphas, oneOf)
import math
import operator
from sys import *
import re
class NumericStringParser(object):
def pushFirst(self, strg, loc, toks):
self.exprStack.append(toks[0])
def pushUMinus(self, strg, loc, toks):
if toks and toks[0] == '-':
self.exprStack.append('unary -')
def __init__(self):
point = Literal(".")
e = CaselessLiteral("E")
fnumber = Combine(Word("+-" + nums, nums) +
Optional(point + Optional(Word(nums))) +
Optional(e + Word("+-" + nums, nums)))
ident = Word(alphas, alphas + nums + "_$")
plus = Literal("+")
minus = Literal("-")
mult = Literal("*")
div = Literal("/")
lpar = Literal("(").suppress()
rpar = Literal(")").suppress()
addop = plus | minus
multop = mult | div
expop = Literal("^")
pi = CaselessLiteral("PI")
expr = Forward()
atom = ((Optional(oneOf("- +")) +
(ident + lpar + expr + rpar | pi | e | fnumber).setParseAction(self.pushFirst))
| Optional(oneOf("- +")) + Group(lpar + expr + rpar)
).setParseAction(self.pushUMinus)
factor = Forward()
factor << atom + \
ZeroOrMore((expop + factor).setParseAction(self.pushFirst))
term = factor + \
ZeroOrMore((multop + factor).setParseAction(self.pushFirst))
expr << term + \
ZeroOrMore((addop + term).setParseAction(self.pushFirst))
self.bnf = expr
epsilon = 1e-12
self.opn = {"+": operator.add,
"-": operator.sub,
"*": operator.mul,
"/": operator.truediv,
"^": operator.pow}
self.fn = {"sin": math.sin,
"cos": math.cos,
"tan": math.tan,
"exp": math.exp,
"abs": abs,
"trunc": lambda a: int(a),
"round": round,
"sgn": lambda a: abs(a) > epsilon and cmp(a, 0) or 0}
def evaluateStack(self, s):
op = s.pop()
if op == 'unary -':
return -self.evaluateStack(s)
if op in "+-*/^":
op2 = self.evaluateStack(s)
op1 = self.evaluateStack(s)
return self.opn[op](op1, op2)
elif op == "PI":
return math.pi # 3.1415926535
elif op == "E":
return math.e # 2.718281828
elif op in self.fn:
return self.fn[op](self.evaluateStack(s))
elif op[0].isalpha():
return 0
else:
return float(op)
def eval(self, num_string, parseAll=True):
self.exprStack = []
results = self.bnf.parseString(num_string, parseAll)
val = self.evaluateStack(self.exprStack[:])
return val
#MODULE FOR EVALIATING COMBINED MATH EXPRESSIONS
global variables
variables = {}
global constants
constants = {}
global variableconstanttypes
variableconstanttypes = {}
def mathLogic(line, element):
elementfrommath = element
try:
#for i in range(1):
for elementforsplit in elementfrommath.split():
if variables.has_key(elementforsplit):
elementfrommath = elementfrommath.replace(elementforsplit, variables[elementforsplit])
#CHANGES VARIABLE TO NUMBER VALUE FOR MATH
elif constants.has_key(elementforsplit):
elementfrommath = elementfrommath.replace(elementforsplit, constants[elementforsplit])
#CHANGES CONSTANT TO NUMBER VALUE FOR MATH
else:
pass
except:
pass
if '+' in line and '-' not in line and '*' not in line and '/' not in line:
elementfrommath = elementfrommath.split('+')
newelement = elementfrommath[0]
for i in range(len(elementfrommath)):
if i == 0:
pass
else:
newelement = int(newelement) + int(elementfrommath[i])
return newelement
#ADDITION LOGIC
elif '-' in line and '+' not in line and '*' not in line and '/' not in line:
elementfrommath = elementfrommath.split('-')
newelement = elementfrommath[0]
for i in range(len(elementfrommath)):
if i == 0:
pass
else:
newelement = int(newelement) - int(elementfrommath[i])
return newelement
#SUBTRACTION LOGIC
elif '*' in line and '-' not in line and '+' not in line and '/' not in line:
elementfrommath = elementfrommath.split('*')
newelement = elementfrommath[0]
for i in range(len(elementfrommath)):
if i == 0:
pass
else:
newelement = int(newelement) * int(elementfrommath[i])
return newelement
#MULTIPLICATION LOGIC
elif '/' in line and '-' not in line and '*' not in line and '+' not in line:
elementfrommath = elementfrommath.split('/')
newelement = elementfrommath[0]
for i in range(len(elementfrommath)):
if i == 0:
pass
else:
newelement = int(newelement) / int(elementfrommath[i])
return newelement
#DIVISION LOGIC
else:
nsp = NumericStringParser()
result = nsp.eval(elementfrommath)
return int(result)
#COMBINED EXPRESSION LOGIC
def combineStringsLogic(variable):
if ' + ' in variable:
variablesplit = variable.split(' + ')
varforfinalvar = ""
itemlist = []
for element in variablesplit:
if "'" in element or '"' in element:
elementone = element.replace('"', '')
elementone = elementone.replace("'", "")
itemlist.append(elementone)
elif "'" not in element and '"' not in element:
if element in variables:
itemlist.append(variables[str(element)])
#ADDS VARIABLE TO STRING
elif element in constants:
itemlist.append(constants[str(element)])
#ADDS CONSTANT TO STRING
for i in range(len(itemlist)):
varforfinalvar = varforfinalvar + itemlist[i]
return varforfinalvar
#COMBINE STRINGS LOGIC
elif ' +' in variable:
variablesplit = variable.split(' +')
varforfinalvar = ""
itemlist = []
for element in variablesplit:
if "'" in element or '"' in element:
elementone = element.replace('"', '')
elementone = elementone.replace("'", "")
itemlist.append(elementone)
elif "'" not in element and '"' not in element:
itemlist.append(str(element))
for i in range(len(itemlist)):
varforfinalvar = varforfinalvar + itemlist[i]
return varforfinalvar
#COMBINE STRINGS LOGIC
elif '+ ' in variable:
variablesplit = variable.split('+ ')
varforfinalvar = ""
itemlist = []
for element in variablesplit:
if "'" in element or '"' in element:
elementone = element.replace('"', '')
elementone = elementone.replace("'", "")
itemlist.append(elementone)
elif "'" not in element and '"' not in element:
itemlist.append(str(element))
for i in range(len(itemlist)):
varforfinalvar = varforfinalvar + itemlist[i]
return varforfinalvar
#COMBINE STRINGS LOGIC
elif '+' in variable:
variablesplit = variable.split('+')
varforfinalvar = ""
itemlist = []
for element in variablesplit:
if "'" in element or '"' in element:
elementone = element.replace('"', '')
elementone = elementone.replace("'", "")
itemlist.append(elementone)
elif "'" not in element and '"' not in element:
itemlist.append(str(element))
for i in range(len(itemlist)):
varforfinalvar = varforfinalvar + itemlist[i]
return varforfinalvar
#COMBINE STRINGS LOGIC
def printLogic(line):
elementfromprint = line.split("print",1)[1]
elementfromprint = elementfromprint.replace("(", "")
elementfromprint = elementfromprint.replace(")", "")
for element in elementfromprint.split():
if '"' not in element:
if element in variables:
elementfromprint = elementfromprint.replace(element, '"' + variables[element] + '"')
#CHANGES VARIABLE TO NUMBER VALUE FOR MATH
elif element in constants:
elementfromprint = elementfromprint.replace(element, '"' + constants[element] + '"')
#CHANGES CONSTANT TO NUMBER VALUE FOR MATH
else:
pass
if '"' in elementfromprint or "'" in elementfromprint:
if '+' in elementfromprint:
elementforsave = combineStringsLogic(elementfromprint)
print(elementforsave)
#COMBINES AND PRINTS STRING VALUE TO OUTPUT
else:
elementone = elementfromprint.replace('"', '')
elementone = elementone.replace("'", "")
print(elementone)
#PRINTS STRING VALUE TO OUTPUT
elif "0" in line or "1" in line or "2" in line or "3" in line or "4" in line or "5" in line or "6" in line or "7" in line or "8" in line or "9" in line:
if '+' in line or '-' in line or '*' in line or '/' in line:
mathreturned = mathLogic(line, elementfromprint)
print(mathreturned)
#HANDLES MATH LOGIC FOR PRINT
elif '+' not in line and '-' not in line and '*' not in line and '/' not in line:
number = elementfromprint
print(number)
#PRINTS NUMBER TO OUTPUT
elif '+' in elementfromprint:
elementforsave = combineStringsLogic(elementfromprint)
print(elementforsave)
#COMBINES AND PRINTS STRING VALUE TO OUTPUT
else:
print(elementfromprint)
#PRINTS ELEMENT NOT IN ANY OTHER IF STATEMENT
def defineVariableLogic(line):
elementfromdefine = line.split("variable ",1)[1]
variable = elementfromdefine
if ' = ' in variable:
variablesplit = variable.split(' = ')
if '"' in variable or "'" in variable:
if "+" in variable:
variablesplitone = variable.split(' = ', 1)
elementforsave = combineStringsLogic(variablesplitone[1])
variables[str(variablesplitone[0])] = elementforsave
variableconstanttypes[variablesplitone[0]] = "str"
#COMBINE STRINGS LOGIC
else:
varforstr = variablesplit[1].replace('"', '')
varforstr = varforstr.replace("'", "")
variables[str(variablesplit[0])] = varforstr
variableconstanttypes[variablesplit[0]] = "str"
#STRING VARIABLE
elif "0" in line or "1" in line or "2" in line or "3" in line or "4" in line or "5" in line or "6" in line or "7" in line or "8" in line or "9" in line:
if '+' in line or '-' in line or '*' in line or '/' in line:
elementfromdefine = variablesplit[1]
mathreturned = mathLogic(line, elementfromdefine)
variables[str(variablesplit[0])] = mathreturned
variableconstanttypes[variablesplit[0]] = "int"
#HANDLES MATH LOGIC FOR DEFINING A VARIABLE
elif '+' not in line and '-' not in line and '*' not in line and '/' not in line:
number = variablesplit[1]
variables[str(variablesplit[0])] = number
variableconstanttypes[variablesplit[0]] = "int"
#SETS VARIABLE EQUAL TO MATH VALUE
elif '"' not in variable and "'" not in variable:
variables[str(variablesplit[0])] = variablesplit[1]
variableconstanttypes[variablesplit[0]] = "int"
#NUMBER VARIABLE
else:
print("ERROR")
#ERROR
elif '=' in variable:
variablesplit = variable.split('=')
#print(variablesplit)
if '"' in variable or "'" in variable:
if "+" in variable:
variablesplitone = variable.split('=')
elementforsave = combineStringsLogic(variablesplitone[1])
variables[str(variablesplitone[0])] = elementforsave
variableconstanttypes[variablesplitone[0]] = "str"
#COMBINE STRINGS LOGIC
else:
varforstr = variable.replace('"', '')
varforstr = varforstr.replace("'", "")
variables[str(variablesplit[0])] = varforstr
variableconstanttypes[variablesplit[0]] = "str"
#STRING VARIABLE
elif "0" in line or "1" in line or "2" in line or "3" in line or "4" in line or "5" in line or "6" in line or "7" in line or "8" in line or "9" in line:
if '+' in line or '-' in line or '*' in line or '/' in line:
elementfromdefine = variablesplit[1]
mathreturned = mathLogic(line, elementfromdefine)
variables[str(variablesplit[0])] = mathreturned
variableconstanttypes[variablesplit[0]] = "int"
#HANDLES MATH LOGIC FOR PRINT
elif '+' not in line and '-' not in line and '*' not in line and '/' not in line:
number = variablesplit[1]
variables[str(variablesplit[0])] = number
variableconstanttypes[variablesplit[0]] = "int"
#PRINTS NUMBER TO OUTPUT
elif '"' not in variable and "'" not in variable:
variables[str(variablesplit[0])] = variablesplit[1]
variableconstanttypes[variablesplit[0]] = "int"
#NUMBER VARIABLE
else:
print("ERROR")
#ERROR
elif '=' not in variable:
varforstr = variable.replace('"', '')
varforstr = varforstr.replace("'", "")
variables[str(variable)] = ""
variableconstanttypes[variable[0]] = ""
#DEFINE VARIABLE LOGIC
else:
print("ERROR")
#ERROR
def defineConstantLogic(line):
elementfromdefine = line.split("constant ",1)[1]
variable = elementfromdefine
if ' = ' in variable:
variablesplit = variable.split(' = ')
if '"' in variable or "'" in variable:
if "+" in variable:
variablesplitone = variable.split(' = ', 1)
elementforsave = combineStringsLogic(variablesplitone[1])
constants[variablesplitone[0]] = elementforsave
variableconstanttypes[variablesplitone[0]] = "str"
#COMBINE STRINGS LOGIC
else:
varforstr = variablesplit[1].replace('"', '')
varforstr = varforstr.replace("'", "")
constants[variablesplit[0]] = varforstr
variableconstanttypes[variablesplit[0]] = "str"
#STRING CONSTANT
elif "0" in line or "1" in line or "2" in line or "3" in line or "4" in line or "5" in line or "6" in line or "7" in line or "8" in line or "9" in line:
if '+' in line or '-' in line or '*' in line or '/' in line:
returnedmathvalue = mathLogic(line, variablesplit[1])
constants[variablesplit[0]] = returnedmathvalue
variableconstanttypes[variablesplit[0]] = "int"
#SETS CONSTANT EQUAL TO MATH OUTPUT
elif '+' not in line and '-' not in line and '*' not in line and '/' not in line:
number = variablesplit[1]
constants[variablesplit[0]] = number
variableconstanttypes[variablesplit[0]] = "int"
#SETS CONSTANT EQUAL TO NUMBER VALUE
elif '"' not in variable and "'" not in variable:
constants[variablesplit[0]] = variablesplit[1]
variableconstanttypes[variablesplit[0]] = "int"
#NUMBER CONSTANT
else:
print("ERROR")
#ERROR
elif '=' in variable:
variablesplit = variable.split('=')
if '"' in variable or "'" in variable:
if "+" in variable:
variablesplitone = variable.split('=')
elementforsave = combineStringsLogic(variablesplitone[1])
constants[variablesplitone[0]] = elementforsave
variableconstanttypes[variablesplitone[0]] = "str"
#COMBINE STRINGS LOGIC
else:
varforstr = variable.replace('"', '')
varforstr = varforstr.replace("'", "")
constants[variablesplit[0]] = varforstr
variableconstanttypes[variablesplit[0]] = "str"
#STRING VARIABLE
elif "0" in line or "1" in line or "2" in line or "3" in line or "4" in line or "5" in line or "6" in line or "7" in line or "8" in line or "9" in line:
if '+' in line or '-' in line or '*' in line or '/' in line:
returnedmathvalue = mathLogic(line, variablesplit[1])
constants[variablesplit[0]] = returnedmathvalue
variableconstanttypes[variablesplit[0]] = "int"
#SETS CONSTANT EQUAL TO MATH OUTPUT
elif '+' not in line and '-' not in line and '*' not in line and '/' not in line:
number = variablesplit[1]
constants[variablesplit[0]] = number
variableconstanttypes[variablesplit[0]] = "int"
#SETS CONSTANT EQUAL TO NUMBER VALUE
elif '"' not in variable and "'" not in variable:
constants[variablesplit[0]] = variablesplit[1]
variableconstanttypes[variablesplit[0]] = "int"
#NUMBER CONSTANT
else:
print("ERROR")
#ERROR
elif '=' not in variable:
varforstr = variable.replace('"', '')
varforstr = varforstr.replace("'", "")
constants[variable] = ""
variableconstanttypes[variablesplit[0]] = ""
#DEFINE CONSTANT LOGIC
def setVariableLogic(line):
elementfromset = line.split("set ",1)[1]
variable = elementfromset
if ' = ' in variable:
variablesplit = variable.split(' = ')
#print(variablesplit)
if '"' in variable or "'" in variable:
if "+" in variable:
variablesplitone = variable.split(' = ', 1)
elementforsave = combineStringsLogic(''.join(variablesplitone[1]))
variables[str(variablesplitone[0])] = elementforsave
variableconstanttypes[variablesplitone[0]] = "str"
#COMBINE STRINGS LOGIC
else:
varforstr = variablesplit[1].replace('"', '')
varforstr = varforstr.replace("'", "")
variables[str(variablesplit[0])] = varforstr
variableconstanttypes[variablesplit[0]] = "str"
#STRING VARIABLE
elif "0" in line or "1" in line or "2" in line or "3" in line or "4" in line or "5" in line or "6" in line or "7" in line or "8" in line or "9" in line:
if '+' in line or '-' in line or '*' in line or '/' in line:
returnedmathvalue = mathLogic(line, variablesplit[1])
variables[str(variablesplit[0])] = returnedmathvalue
#SETS VARIABLE EQUAL TO MATH OUTPUT
elif '+' not in line and '-' not in line and '*' not in line and '/' not in line:
number = variablesplit[1]
variables[str(variablesplit[0])] = number
variableconstanttypes[variablesplit[0]] = "int"
#SETS VARIABLE EQUAL TO NUMBER VALUE
elif '"' not in variable and "'" not in variable:
variables[str(variablesplit[0])] = variablesplit[1]
variableconstanttypes[variablesplit[0]] = "int"
#NUMBER VARIABLE
elif '=' in variable:
variablesplit = variable.split('=')
#print(variablesplit)
if '"' in variable or "'" in variable:
if "+" in variable:
variablesplitone = variable.split('=')
elementforsave = combineStringsLogic(''.join(variablesplitone[1]))
variables[str(variablesplitone[0])] = elementforsave
variableconstanttypes[variablesplitone[0]] = "str"
#COMBINE STRINGS LOGIC
else:
varforstr = variablesplit[1].replace('"', '')
varforstr = varforstr.replace("'", "")
variables[str(variablesplit[0])] = varforstr
variableconstanttypes[variablesplit[0]] = "str"
#STRING VARIABLE
elif "0" in line or "1" in line or "2" in line or "3" in line or "4" in line or "5" in line or "6" in line or "7" in line or "8" in line or "9" in line:
if '+' in line or '-' in line or '*' in line or '/' in line:
returnedmathvalue = mathLogic(line, variablesplit[1])
variables[str(variablesplit[0])] = returnedmathvalue
variableconstanttypes[variablesplit[0]] = "int"
#SETS VARIABLE EQUAL TO MATH OUTPUT
elif '+' not in line and '-' not in line and '*' not in line and '/' not in line:
number = variablesplit[1]
variables[str(variablesplit[0])] = number
variableconstanttypes[variablesplit[0]] = "int"
#SETS VARIABLE EQUAL TO NUMBER VALUE
elif '"' not in variable and "'" not in variable:
variables[str(variablesplit[0])] = variablesplit[1]
#NUMBER VARIABLE
elif '=' not in variable:
varforstr = variable.replace('"', '')
varforstr = varforstr.replace("'", "")
variables[str(variable)] = ""
variableconstanttypes[variable] = ""
#DEFINE VARIABLE LOGIC
def userInputLogic(line):
elementfromdefine = line.split("input ",1)[1]
uservalue = input(elementfromdefine + ' > ')
print(uservalue)
#def defineFunctionLogic(line):
#functionname = line.split()[2]
#print(functionname)
#DEFINE FUNCTION LOGIC
#def useFunctionLogic(line):
#functionname = line.split()[2]
#print(functionname)
# pass
#DEFINE FUNCTION LOGIC
def defineVariableNoValueLogic(line):
elementfromset = line.split("define variable ",1)[1]
variables[str(elementfromset)] = ""
#DEFINE VARIABLE WITH NO VALUE LOGIC
def defineConstantNoValueLogic(line):
elementfromset = line.split("define constant ",1)[1]
constants[elementfromset] = ""
#DEFINE CONSTANT WITH NO VALUE LOGIC
def typeLogic(line):
elementfromset = line.split("print ",1)[1].replace('.type()', '')
for element in elementfromset.split():
if element in variables.keys():
typeForVariable = variableconstanttypes[element]
#CHANGES VARIABLE TO NUMBER VALUE FOR MATH
elif element in constants.keys():
typeForVariable = variableconstanttypes[element]
#CHANGES CONSTANT TO NUMBER VALUE FOR MATH
else:
pass
return typeForVariable
def open_file(filename):
data = open(filename, "r").read()
data += "\n"
data += "<EOF>"
filenamesplit = filename.split('.')
if str(filenamesplit[1]) == 'language':
pass
else:
print('The file format ".' + str(filenamesplit[1]) + '" is not supported')
exit()
return data
def run():
fileinfo = ""
#fileinfo = open_file(argv[1])
fileinfo = open_file("test.language")
#try:
for i in range(1):
fileinfo = fileinfo.split('\n')
try:
fileinfo.remove('')
except:
pass
for line in fileinfo:
if "print" in line and line[:2] != '//' and '.type()' not in line:
printLogic(line)
elif "print" in line and line[:2] != '//' and '.type()' in line:
datafromtypelogic = typeLogic(line)
print(datafromtypelogic)
#elif "import" in line and line[:2] != '//':
# importLogic(line)
elif "set" in line and line[:2] != '//':
setVariableLogic(line)
elif "variable" in line and "define variable" not in line and line[:2] != '//':
defineVariableLogic(line)
elif "constant" in line and "define constant" not in line and line[:2] != '//':
defineConstantLogic(line)
elif "define variable" in line and line[:2] != '//':
defineVariableNoValueLogic(line)
elif "define constant" in line and line[:2] != '//':
defineConstantNoValueLogic(line)
elif "input" in line and line[:2] != '//':
userInputLogic(line)
#elif "define function" in line and line[:2] != '//':
#defineFunctionLogic(line)
#elif "use" in line and line[:2] != '//':
# useFunctionLogic(line)
elif line[:2] == '//':
pass
#COMMENT LOGIC
elif line == "<EOF>":
pass
#else:
# print(line)
# print('broke')
#except AttributeError:
# print("A file must be included for the interpreter to run")
#except:
# print("There was an error")
run()