Skip to content

Commit

Permalink
A field needs not end with a new line
Browse files Browse the repository at this point in the history
Added a function `skipToNextLineOrEOI` and changed `field` to call
the function instead. This function may consume no inputs, and hence
`many skipToNextLineOrEOI` can go to infinite loop.
  • Loading branch information
kztk-m committed Feb 21, 2024
1 parent a88f561 commit 2a32135
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Hie/Cabal/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ parseList i = many (nl <|> sl)
skipToNextLine :: Parser ()
skipToNextLine = skipWhile (not . isEndOfLine) >> endOfLine

-- This function may consume no inputs; so 'many skipToNextLineOrEOI' may go into infinite loop.
skipToNextLineOrEOI :: Parser ()
skipToNextLineOrEOI = skipWhile (not . isEndOfLine) >> (endOfInput <|> endOfLine)

comment :: Parser ()
comment = skipMany tabOrSpace >> "--" >> skipToNextLine

Expand All @@ -133,7 +137,7 @@ field i f p =
_ <- char ':'
skipMany tabOrSpace
p' <- p $ i' + 1
skipToNextLine
skipToNextLineOrEOI
pure p'

-- | Skip at least n spaces
Expand Down

0 comments on commit 2a32135

Please sign in to comment.