From 41a2c1fdaa07b3b51bf6073bf6fbb0156b085fa5 Mon Sep 17 00:00:00 2001
From: Alexander Sulfrian <alexander@sulfrian.net>
Date: Tue, 23 Jun 2009 03:21:32 +0200
Subject: added parser

- commited parser (Michael Popov)
- changed encoding of parser.py to utf8
---
 src/front/__init__.py | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

(limited to 'src/front/__init__.py')

diff --git a/src/front/__init__.py b/src/front/__init__.py
index fdf35a8..747efde 100644
--- a/src/front/__init__.py
+++ b/src/front/__init__.py
@@ -1,11 +1,12 @@
 from front.lexer import Lexer
 from front.parser import Parser
-from front.symbols import SymbolTable
+#from front.symbols import SymbolTable
 
 def main():
     source = '''fun fib[a]
 	if a < 2
 		@1
+	end
 	@( fib[a-1] + fib[a-2] )
 end
 
@@ -14,23 +15,24 @@ fun main[]
 	sum = 0
 	i = 0
 	while (i < 10)
-		sum = sum + fib[i = i + 1]
+		sum = sum + fib[i]
+		i = i + 1
 	end
 	@sum
 end'''
 
-    symbols = SymbolTable()
-    lex = Lexer(source)
+    #symbols = SymbolTable()
+    #lex = Lexer(source)
 
     # testing
-    while True:
-        token = lex.scan()
-        print token.__repr__()
-        if not token:
-            break
-    
-    # parse = Parser(lex)
-    # parse.program()
+    #while True:
+    #    token = lex.scan()
+    #    print token.__repr__()
+    #    if not token:
+    #        break
+
+    parse = Parser(Lexer(source))
+    print parse.parse()
 
 if __name__ == "__main__":
     main()
-- 
cgit v1.2.3


From a4f2a248273064ec464e7d376f8f5778ac808bd6 Mon Sep 17 00:00:00 2001
From: Alexander Sulfrian <alexander@sulfrian.net>
Date: Sun, 28 Jun 2009 15:10:57 +0200
Subject: 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
---
 src/front/__init__.py | 38 --------------------------------------
 1 file changed, 38 deletions(-)

(limited to 'src/front/__init__.py')

diff --git a/src/front/__init__.py b/src/front/__init__.py
index 747efde..e69de29 100644
--- a/src/front/__init__.py
+++ b/src/front/__init__.py
@@ -1,38 +0,0 @@
-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()
-- 
cgit v1.2.3