X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=src%2Fparse.icl;h=af50de669050fc4f1a083517d9b85c231216eb8e;hb=96be5e0151b236a425025cf96e8dade73ee74fcf;hp=349c0e1dea4459f7eb862a6e8b88d0ae03a724d4;hpb=db22521b4ba8a77e3bf845e38de3c0cb6e40a180;p=cc1516.git diff --git a/src/parse.icl b/src/parse.icl index 349c0e1..af50de6 100644 --- a/src/parse.icl +++ b/src/parse.icl @@ -53,10 +53,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 tv, 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