gitignore
This commit is contained in:
commit
b17f895f0a
7 changed files with 470 additions and 0 deletions
31
cpq.py
Normal file
31
cpq.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
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)
|
Loading…
Add table
Add a link
Reference in a new issue