Created
January 3, 2015 18:32
-
-
Save doivosevic/8fdd01ff8917a34ba2bd 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