From fb9e6a20ac7393b6cc27949ad2d2af7a305c96ba Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 20 May 2009 04:19:52 +0200 Subject: implemented lexer (with tokens and symbolTable) todo: beautify code, implement token classes for parser implemented test function with testcode moved token class to single file (token.py) --- src/front/__init__.py | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src/front/__init__.py') diff --git a/src/front/__init__.py b/src/front/__init__.py index 63529ef..426a16e 100644 --- a/src/front/__init__.py +++ b/src/front/__init__.py @@ -1,7 +1,33 @@ from front.lexer import Lexer from front.parser import Parser +from front.symbols import SymbolTable def main(): - lex = Lexer() - parse = Parser(lex) - parse.program() + 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''' + + symbols = SymbolTable() + lex = Lexer(source, symbols) + + # testing + while True: + token = lex.scan() + print token.__repr__() + if not token: + break + + # parse = Parser(lex) + # parse.program() -- cgit v1.2.3