joosc.py 751 B
import sys
import random as random
from os import listdir
from os.path import isfile, join
from Scanning import scan
from Parsing import parse
from Weeding import weedTokens
def main():
inputfile = sys.argv[1]
content = open(inputfile, "r").read()
# Scanning
try:
(tokens, errorString) = scan(content)
except:
return 42
# Error in Scanning
if tokens is None:
return 42
# Weed the tokens
weeds = weedTokens(tokens, inputfile)
if weeds != "":
return 42
# Parsing
try:
(steps, error) = parse(tokens)
except:
return 42
if steps is None:
print(error)
return 42
print("success in scanning and parsing")
return 0
main()