2023-10-12 22:46:37 -07:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2023-10-13 00:15:31 -07:00
|
|
|
from codegen_message import *
|
|
|
|
from parser import *
|
2023-10-12 22:46:37 -07:00
|
|
|
|
|
|
|
def main():
|
|
|
|
if len(sys.argv) != 2:
|
|
|
|
sys.exit("Takes name of file.")
|
|
|
|
|
|
|
|
filename = sys.argv[1]
|
|
|
|
|
|
|
|
with open(filename, mode='r') as f:
|
|
|
|
filedata = f.read()
|
|
|
|
lexemes = lexer(filedata)
|
|
|
|
|
|
|
|
parser = Parser(lexemes)
|
2023-10-12 23:14:25 -07:00
|
|
|
ast = parser.parse()
|
|
|
|
type_check(ast)
|
2023-10-13 00:15:31 -07:00
|
|
|
|
|
|
|
print(generate_message_impl(filename, ast))
|
2023-10-12 22:46:37 -07:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|