Skip to content

Commit

Permalink
improve handling of EVENTUALLY; add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mengwong committed Oct 19, 2021
1 parent 5489bb8 commit b3c6732
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mengwong/mp/src/Lib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,11 @@ mergePBRS xs =
toreturn

pTemporal :: Parser (Maybe (TemporalConstraint Text.Text))
pTemporal = do
t1 <- pToken Before <|> pToken After <|> pToken By <|> pToken Eventually
pTemporal = ( do
t0 <- pToken Eventually <* dnl
return (mkTC t0 "")
) <|> do
t1 <- pToken Before <|> pToken After <|> pToken By
t2 <- pOtherVal <* dnl
return $ mkTC t1 t2

Expand Down
5 changes: 5 additions & 0 deletions mengwong/mp/test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ r `shouldParse` v = case r of
++ errorBundlePrettyCustom e
Right x -> x `shouldBe` v

defaultReg :: Rule
defaultReg = Regulative
{ every = "person"
, who = Nothing
Expand Down Expand Up @@ -72,6 +73,10 @@ main = do
parseR (pRule <* eof) "" (exampleStream ",,,,\n,EVERY,person,,\n,WHO,walks,,\n,MUST,,,\n,->,sing,,\n")
`shouldParse` [ defaultReg { who = Just (Leaf "walks") } ]

it "should parse the null temporal EVENTUALLY" $ do
parseR (pRule <* eof) "" (exampleStream ",,,,\n,EVERY,person,,\n,WHO,walks,,\n,MUST,EVENTUALLY,,\n,->,sing,,\n")
`shouldParse` [ defaultReg { who = Just (Leaf "walks") } ]

it "should parse dummySing" $ do
parseR (pRule <* eof) "" (exampleStream ",,,,\n,EVERY,person,,\n,WHO,walks,// comment,continued comment should be ignored\n,AND,runs,,\n,AND,eats,,\n,OR,drinks,,\n,MUST,,,\n,->,sing,,\n")
`shouldParse` [ defaultReg {
Expand Down

0 comments on commit b3c6732

Please sign in to comment.