i think its ready

This commit is contained in:
Rusty Striker 2024-04-04 09:56:28 +03:00
parent 954ef31cd2
commit 75e3c031bf
Signed by: RustyStriker
GPG key ID: 87E4D691632DFF15
6 changed files with 24 additions and 39 deletions

6
cpq.py
View file

@ -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')