38 lines
743 B
Python
38 lines
743 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 CXXVIII
|
|
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))
|