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 >= 6 || a == 5) break; else a = a + 0; } output(a); switch(a * 5) { case 1: a = 5; break; case 5: output(a); default: break; } output(a); } ''' parser.parse(lexer.tokenize(text)) for l, t in enumerate(parser.lines): print(l,':',t)