summaryrefslogtreecommitdiffstats
path: root/src/front/__init__.py
blob: 747efded2be27bb455ba42eb9119470506b6cebe (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
35
36
37
38
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()