Skip to content
Snippets Groups Projects
Commit 4c77709a authored by pycsham's avatar pycsham
Browse files

Added a main.py file (for submission) and a Test.py file to automate testing

parent cbe2cebe
No related branches found
No related tags found
No related merge requests found
......@@ -207,10 +207,10 @@ def parse(input):
print(result)
# TODO: this function can go outside into a tester file
def main():
inputfile = sys.argv[1]
inputfile = "./ParseTests/" + inputfile
with open(inputfile) as f:
input = f.read().replace('\n', ' ')
parse(input)
main()
# def main():
# inputfile = sys.argv[1]
# inputfile = "./ParseTests/" + inputfile
# with open(inputfile) as f:
# input = f.read().replace('\n', ' ')
# parse(input)
# main()
......@@ -3,34 +3,38 @@ from os import listdir
from os.path import isfile, join
from Scanning import scan
from Parsing import parse
def allFiles(testDir):
return [testDir + f for f in listdir(testDir) if isfile(join(testDir, f))]
def main():
# Lines of Tokens
tlines = []
# Reading in all files in test directory
mypath = "./ScanTests/"
onlyfiles = [mypath + f for f in listdir(mypath) if isfile(join(mypath, f))]
# All files in the test directory
testDirectory = "./Tests/"
testFiles = allFiles(testDirectory)
print("**********************************************************")
for f in onlyfiles:
content = open(f, "r")
content = content.read()
print(f)
for f in testFiles:
# Scanning
result = scan(content)
tokens = result[0]
errorString = result[1]
content = open(f, "r").read()
(tokens, errorString) = scan(content)
# Error in Scanning
if tokens is None:
print("ERROR in Scanning: " + errorString)
print("**********************************************************")
continue
s = ""
s = "All Tokens: "
for token in tokens:
if (token.name and token.lex):
s += '(' + token.name + ',' + token.lex + '), '
print(s)
# Parsing
# parse(tokens)
print("**********************************************************")
main()
\ No newline at end of file
File moved
File moved
File moved
File moved
File moved
File moved
File moved
main.py 0 → 100644
import sys
from os import listdir
from os.path import isfile, join
from Scanning import scan
from Parsing import parse
def main():
inputfile = sys.argv[1]
content = open(inputfile, "r").read()
# Scanning
(tokens, errorString) = scan(content)
# Error in Scanning
if tokens is None:
return 42
# Parsing
# parse(input)
return 0
main()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment