blob: b72b44017f7792c82c07903b64f860e28552526e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
from front.lexer import Lexer
from front.parser import Parser
def main():
source = '''fun fib[a]
if a < 2
@1
@( fib[a-1] + fib[a-2] )
end
# main function
fun main[]
sum = 0
i = 0
while (i < 10)
sum = sum + fib[i = i + 1]
end
@sum
end'''
lex = Lexer(source)
# testing
while True:
token = lex.scan()
print token.__repr__()
if not token:
break
# parse = Parser(lex)
# parse.program()
if __name__ == "__main__":
main()
|