i think its ready
This commit is contained in:
parent
954ef31cd2
commit
75e3c031bf
6 changed files with 24 additions and 39 deletions
6
cpq.py
6
cpq.py
|
@ -8,13 +8,15 @@ from lexer import Lexer
|
|||
from parser import Parser
|
||||
from helper import print_err
|
||||
|
||||
|
||||
# print signature
|
||||
print_err('Aviv Romem')
|
||||
|
||||
# invalid usage
|
||||
if len(sys.argv) != 2 or not sys.argv[1].endswith('.ou'):
|
||||
print('USAGE: python cpq.py <file-name>.ou')
|
||||
exit(1)
|
||||
|
||||
# load file and parser
|
||||
file = sys.argv[1]
|
||||
output = file[:-3] + '.qud'
|
||||
f = open(file, 'r')
|
||||
|
@ -24,7 +26,7 @@ lexer = Lexer()
|
|||
parser = Parser()
|
||||
|
||||
file = sys.argv[1]
|
||||
|
||||
# parse and write file if valid
|
||||
parser.parse(lexer.tokenize(text))
|
||||
if not parser.had_errors:
|
||||
f = open(output, 'w')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue