31 lines
572 B
Python
31 lines
572 B
Python
import sly
|
|
# for ease of reading, the compiler is broken down to multiple files
|
|
# parser.py for the parser
|
|
# lexer.py for the lexer
|
|
# and helper.py for helper functions(such as print_err)
|
|
from lexer import Lexer
|
|
from parser import Parser
|
|
from helper import print_err
|
|
|
|
|
|
|
|
|
|
print_err('Aviv Romem')
|
|
lexer = Lexer()
|
|
parser = Parser()
|
|
text = '''
|
|
a: int;
|
|
{
|
|
while(a < 10) {
|
|
a = a + 1;
|
|
if(a == 5)
|
|
break;
|
|
else
|
|
a = a + 0;
|
|
}
|
|
|
|
}
|
|
'''
|
|
parser.parse(lexer.tokenize(text))
|
|
for l, t in enumerate(parser.lines):
|
|
print(l,':',t)
|