Skip to content

Commit

Permalink
Require rules to end the line or the file.
Browse files Browse the repository at this point in the history
This has the effect of forcing the maximum possible parse for a rule.
  • Loading branch information
nc6 committed Mar 5, 2024
1 parent f6ef857 commit 80ba29c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Codec/CBOR/Cuddle/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import Text.Megaparsec.Char.Lexer qualified as L
type Parser = Parsec Void Text

pCDDL :: Parser CDDL
pCDDL = CDDL . fmap noComment <$> (space *> NE.some (pRule <* space) <* eof)
pCDDL =
CDDL . fmap noComment
<$> (space *> NE.some pRule)

pRule :: Parser Rule
pRule =
Expand All @@ -31,12 +33,14 @@ pRule =
<$> pName
<*> optcomp pGenericParam
<*> (space *> pAssignT <* space)
<*> (TOGType <$> pType0),
<*> (TOGType <$> pType0)
<* (space <* choice [void eol, eof]),
Rule
<$> pName
<*> optcomp pGenericParam
<*> (space *> pAssignG <* space)
<*> (TOGGroup <$> pGrpEntry)
<* (space <* choice [void eol, eof])
]

pName :: Parser Name
Expand Down

0 comments on commit 80ba29c

Please sign in to comment.