Skip to content

Commit

Permalink
add support for rule labels in constitutive rules too. issue #27
Browse files Browse the repository at this point in the history
  • Loading branch information
mengwong committed Oct 19, 2021
1 parent b3c6732 commit 58b13c4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mengwong/mp/src/Lib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ pConstitutiveRule = debugName "pConstitutiveRule" $ do
myTraceM $ "pConstitutiveRule: matched defWord " ++ show defWord
myTraceM $ "pConstitutiveRule: \"" ++ Text.unpack term ++ "\" " ++ show defWord ++ "..."
(ands,rs) <- withDepth leftX dBoolRules -- (foo AND (bar OR baz), [constitutive and regulative sub-rules])
return $ Constitutive term ands : rs
return $ Constitutive term ands Nothing : rs

pRegRule :: Parser [Rule]
pRegRule = debugName "pRegRule" $ try pRegRuleSugary <|> pRegRuleNormal
Expand Down
1 change: 1 addition & 0 deletions mengwong/mp/src/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ data Rule = Regulative
| Constitutive
{ term :: ConstitutiveTerm
, cond :: Maybe BoolStruct
, rlabel :: Maybe Text.Text
}
| RegAlias Text.Text -- softlink to a regulative rule label
| ConAlias Text.Text -- softlink to a constitutive rule label
Expand Down
6 changes: 2 additions & 4 deletions mengwong/mp/test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ main = do
let degustates = Constitutive
{ term = "degustates"
, cond = Just $ Any ( Pre "any of:" ) [ Leaf "eats", Leaf "drinks" ]
, rlabel = Nothing
}

it "should parse a simple constitutive rule" $ do
Expand All @@ -141,6 +142,7 @@ main = do
, Constitutive
{ term = "degustates"
, cond = Just $ Any ( Pre "any of:" ) [ Leaf "eats", Leaf "drinks" ]
, rlabel = Nothing
}
]

Expand Down Expand Up @@ -209,10 +211,6 @@ main = do
mycsv <- BS.readFile "test/chained-regulatives.csv"
parseR (pRule <* eof) "" (exampleStream mycsv) `shouldParse` singer_chain

it "should render a box" $ do
asBoxes <$> asCSV indentedDummySing
`shouldBe` Right "abc\n"

-- upgrade single OR group to bypass the top level AND group


0 comments on commit 58b13c4

Please sign in to comment.