blob: 747efded2be27bb455ba42eb9119470506b6cebe (
plain) (
tree)
|
|
from front.lexer import Lexer
from front.parser import Parser
#from front.symbols import SymbolTable
def main():
source = '''fun fib[a]
if a < 2
@1
end
@( fib[a-1] + fib[a-2] )
end
# main function
fun main[]
sum = 0
i = 0
while (i < 10)
sum = sum + fib[i]
i = i + 1
end
@sum
end'''
#symbols = SymbolTable()
#lex = Lexer(source)
# testing
#while True:
# token = lex.scan()
# print token.__repr__()
# if not token:
# break
parse = Parser(Lexer(source))
print parse.parse()
if __name__ == "__main__":
main()
|