Created
January 3, 2015 18:31
-
-
Save doivosevic/ac3c068211bf2f424619 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parseIf :: Parser Statement | |
parseIf = do | |
spaces | |
string "if " | |
spaces | |
expr <- expression | |
spaces | |
string "then " | |
st <- statement | |
return $ If expr st Nothing | |
parseIfElse :: Parser Statement | |
parseIfElse = do | |
spaces | |
string "if " | |
spaces | |
expr <- expression | |
spaces | |
string "then " | |
st <- statement | |
spaces | |
string "else " | |
mst <- statement | |
return $ If expr st $ Just mst | |
statement :: Parser Statement | |
statement = try parseIfElse <|> parseIf <|> assignment |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment