Files
centvrion/main.py
NikolajDanger 1aff3b4486
2022-06-08 16:34:50 +02:00

38 lines
737 B
Python

from centvrion.lexer import Lexer
from centvrion.parser import Parser
from centvrion.ast_nodes import Program
text_input = """
CVM FORS
DESIGNA correct VT FORTIS_NVMERVS I C
DESIGNA gvess VT NVLLVS
DVM FALSITAS FACE {
DESIGNA gvess VT AVDI_NVMERVS
SI gvess MINVS correct TVNC {
DICE "Too low!"
} ALVID SI gvess PLVS correct TVNC {
DICE "Too high!"
} ALVID {
ERVMPE
}
}
DICE "You guessed correctly!"
"""
lexer = Lexer().get_lexer()
parser = Parser()
tokens = lexer.lex(text_input)
#for token in tokens:
# print(token)
program = parser.parse(tokens)
#print(x)
if isinstance(program, Program):
program.eval()
else:
raise Exception("Output not of type 'Program'", type(program))