X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;ds=inline;f=src%2Fparse.icl;h=d64efcb97c7111b3854e014200a8dc5808b38c38;hb=43d45105726b3ad3e5cc5165f8c9b066ec8d2790;hp=fc6e740b946a818a46a582ce3ce4197727ffefb3;hpb=cdb033817c0b30f0ff27b0f4aa67b7cf93c36b4d;p=cc1516.git diff --git a/src/parse.icl b/src/parse.icl index fc6e740..d64efcb 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 *> @@ -176,7 +177,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