Skip to content

Commit 208bf64

Browse files
committed
Parser: add getExprAfterSymbol
1 parent 8bb95c4 commit 208bf64

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Nix/Parser.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ reserved n =
142142
getExprAfterP :: Parser a -> Parser NExprLoc
143143
getExprAfterP p = p *> nixToplevelForm
144144

145+
getExprAfterSymbol :: Char -> Parser NExprLoc
146+
getExprAfterSymbol p = getExprAfterP $ symbol p
147+
145148
getExprAfterReservedWord :: Text -> Parser NExprLoc
146149
getExprAfterReservedWord word = getExprAfterP $ reserved word
147150

@@ -380,7 +383,7 @@ nixBinders = (inherit <|> namedVar) `endBy` symbol ';' where
380383
label "variable binding" $
381384
liftA3 NamedVar
382385
(annotated <$> nixSelector)
383-
(symbol '=' *> nixToplevelForm)
386+
(getExprAfterSymbol '=')
384387
(pure p)
385388
scope = label "inherit scope" nixParens
386389

@@ -687,7 +690,7 @@ argExpr =
687690
pair <-
688691
liftA2 (,)
689692
identifier
690-
(optional $ symbol '?' *> nixToplevelForm)
693+
(optional $ getExprAfterSymbol '?')
691694

692695
let args = acc <> [pair]
693696

@@ -734,7 +737,7 @@ nixWith =
734737
annotateNamedLocation "with" $
735738
liftA2 NWith
736739
(getExprAfterReservedWord "with")
737-
(symbol ';' *> nixToplevelForm)
740+
(getExprAfterSymbol ';' )
738741

739742

740743
-- ** assert
@@ -744,7 +747,7 @@ nixAssert =
744747
annotateNamedLocation "assert" $
745748
liftA2 NAssert
746749
(getExprAfterReservedWord "assert")
747-
(symbol ';' *> nixToplevelForm)
750+
(getExprAfterSymbol ';' )
748751

749752
-- ** . - reference (selector) into attr
750753

0 commit comments

Comments
 (0)