Errors nog steeds niet goede token :(
[cc1516.git] / src / parse.icl
index c28fb4c..edc23ac 100644 (file)
@@ -52,10 +52,11 @@ parseStmt = parseIfStmt <|> parseWhileStmt <|>
 
                parseIfStmt :: Parser Token Stmt
                parseIfStmt = liftM3 IfStmt
-                       (satTok IfToken *> parseBBraces parseExpr)
-                       (parseBlock <|> parseOneLine)
-                       (liftM (fromMaybe []) 
-                               (optional (satTok ElseToken *> (parseBlock<|> parseOneLine))))
+            (satTok IfToken *> parseBBraces parseExpr)
+            (parseBlock <|> parseOneLine)
+            (liftM (fromMaybe []) 
+                (optional (satTok ElseToken *> (parseBlock<|> parseOneLine))))
+
 
                parseWhileStmt :: Parser Token Stmt
                parseWhileStmt = satTok WhileToken *> 
@@ -175,7 +176,9 @@ trans1 t r = trans2 t $ const r
 derive gPrint TokenValue
 derive gEq TokenValue
 satTok :: TokenValue -> Parser Token Token
-satTok t = top >>= \tok=:(pos, tv) -> if (eq t tok) (return tok) (fail <?> (printToString t, pos))
+satTok t = top >>= \tok=:(pos, tv) -> if (eq t tok) 
+                                            (return tok) 
+                                            (fail <?> (printToString tv+++printToString t, pos))
        where
                eq (IdentToken _) (_, IdentToken _) = True
                eq (NumberToken _) (_, NumberToken _) = True
@@ -222,7 +225,7 @@ printStatements [s:ss] i = (case s of
        ) ++ printStatements ss i
        where
                printCodeBlock :: [Stmt] Int -> [String]
-               printCodeBlock [] _ = ["{}"]
+               printCodeBlock [] _ = ["{}\n"]
                printCodeBlock [x] i = ["\n":printStatements [x] (i+1)]
                printCodeBlock x i =
                        ["{\n":printStatements x (i+1)] ++ indent i ["}\n"]