diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2009-05-20 04:19:52 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2009-05-20 04:19:52 +0200 |
commit | fb9e6a20ac7393b6cc27949ad2d2af7a305c96ba (patch) | |
tree | 2be8d1ea500651ae7415deb9ba718473969468e0 /src/front/__init__.py | |
parent | b649933b98691a43e7e3adf158109ced285e802c (diff) | |
download | swppy-fb9e6a20ac7393b6cc27949ad2d2af7a305c96ba.tar.gz swppy-fb9e6a20ac7393b6cc27949ad2d2af7a305c96ba.tar.xz swppy-fb9e6a20ac7393b6cc27949ad2d2af7a305c96ba.zip |
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)
Diffstat (limited to 'src/front/__init__.py')
-rw-r--r-- | src/front/__init__.py | 32 |
1 files changed, 29 insertions, 3 deletions
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() |