mirror of
https://github.com/Haskell-Things/ImplicitCAD.git
synced 2024-09-17 16:08:01 +03:00
do not try to match spaces before a pattern.
This commit is contained in:
parent
c2c5a7428c
commit
fd1ccd17d1
@ -97,10 +97,11 @@ suite = (fmap return computation <|> do
|
|||||||
stmts <- many (try computation)
|
stmts <- many (try computation)
|
||||||
_ <- whiteSpace
|
_ <- whiteSpace
|
||||||
_ <- char '}'
|
_ <- char '}'
|
||||||
|
_ <- whiteSpace
|
||||||
return stmts
|
return stmts
|
||||||
) <?> " suite"
|
) <?> " suite"
|
||||||
|
|
||||||
-- | commenting out a comuptation: use % or * before the statement, and it will not be run.
|
-- | commenting out a computation: use % or * before the statement, and it will not be run.
|
||||||
throwAway :: GenParser Char st StatementI
|
throwAway :: GenParser Char st StatementI
|
||||||
throwAway = do
|
throwAway = do
|
||||||
pos <- sourcePos
|
pos <- sourcePos
|
||||||
@ -146,8 +147,8 @@ echo :: GenParser Char st StatementI
|
|||||||
echo = do
|
echo = do
|
||||||
pos <- sourcePos
|
pos <- sourcePos
|
||||||
_ <- stringGS "echo ( "
|
_ <- stringGS "echo ( "
|
||||||
exprs <- expr0 `sepBy` stringGS " , "
|
exprs <- expr0 `sepBy` stringGS ", "
|
||||||
_ <- stringGS " ) "
|
_ <- stringGS ") "
|
||||||
return $ StatementI pos $ Echo exprs
|
return $ StatementI pos $ Echo exprs
|
||||||
|
|
||||||
ifStatementI :: GenParser Char st StatementI
|
ifStatementI :: GenParser Char st StatementI
|
||||||
@ -155,7 +156,7 @@ ifStatementI = "if " ?: do
|
|||||||
pos <- sourcePos
|
pos <- sourcePos
|
||||||
_ <- stringGS "if ( "
|
_ <- stringGS "if ( "
|
||||||
bexpr <- expr0
|
bexpr <- expr0
|
||||||
_ <- stringGS " ) "
|
_ <- stringGS ") "
|
||||||
sTrueCase <- suite
|
sTrueCase <- suite
|
||||||
_ <- whiteSpace
|
_ <- whiteSpace
|
||||||
sFalseCase <- (stringGS "else " >> suite ) *<|> return []
|
sFalseCase <- (stringGS "else " >> suite ) *<|> return []
|
||||||
@ -172,7 +173,7 @@ forStatementI = "for " ?: do
|
|||||||
lvalue <- patternMatcher
|
lvalue <- patternMatcher
|
||||||
_ <- stringGS " = "
|
_ <- stringGS " = "
|
||||||
vexpr <- expr0
|
vexpr <- expr0
|
||||||
_ <- stringGS " ) "
|
_ <- stringGS ") "
|
||||||
loopContent <- suite
|
loopContent <- suite
|
||||||
return $ StatementI pos $ For lvalue vexpr loopContent
|
return $ StatementI pos $ For lvalue vexpr loopContent
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user