summaryrefslogtreecommitdiffstats
path: root/src/__init__.py
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2009-06-28 15:10:57 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2009-06-28 15:10:57 +0200
commita4f2a248273064ec464e7d376f8f5778ac808bd6 (patch)
treeb2a0eed3f983181f91a96fc1b9e221c03e05a6fa /src/__init__.py
parent41a2c1fdaa07b3b51bf6073bf6fbb0156b085fa5 (diff)
downloadswppy-a4f2a248273064ec464e7d376f8f5778ac808bd6.tar.gz
swppy-a4f2a248273064ec464e7d376f8f5778ac808bd6.tar.xz
swppy-a4f2a248273064ec464e7d376f8f5778ac808bd6.zip
fixed error with not newline at file end
moved __init__.py with testcode from src/front to src/ added in lexer "\n\n" at source end to have a newline at file end added unexpected end of file message, if matched token is None
Diffstat (limited to 'src/__init__.py')
-rw-r--r--src/__init__.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/__init__.py b/src/__init__.py
new file mode 100644
index 0000000..747efde
--- /dev/null
+++ b/src/__init__.py
@@ -0,0 +1,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()