commit
d5d77cd84f
|
@ -18,7 +18,7 @@ import Prelude hiding (elem)
|
||||||
nixApp :: Parser NExpr
|
nixApp :: Parser NExpr
|
||||||
nixApp = go <$>
|
nixApp = go <$>
|
||||||
someTill (whiteSpace *> nixExpr True)
|
someTill (whiteSpace *> nixExpr True)
|
||||||
(try (lookAhead (() <$ oneOf "=,;])}" <|> eof)))
|
(try (lookAhead (() <$ oneOf "=,;])}" <|> reserved "then" <|> reserved "else" <|> eof)))
|
||||||
where
|
where
|
||||||
go [] = error "some has failed us"
|
go [] = error "some has failed us"
|
||||||
go [x] = x
|
go [x] = x
|
||||||
|
@ -57,6 +57,7 @@ nixTerm allowLambdas = choice
|
||||||
, nixList
|
, nixList
|
||||||
, nixPath
|
, nixPath
|
||||||
, nixLet
|
, nixLet
|
||||||
|
, nixIf
|
||||||
, setLambdaStringOrSym allowLambdas
|
, setLambdaStringOrSym allowLambdas
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -83,6 +84,12 @@ nixLet = (Fix .) . NLet
|
||||||
<$> (reserved "let" *> nixBinders)
|
<$> (reserved "let" *> nixBinders)
|
||||||
<*> (whiteSpace *> reserved "in" *> nixApp)
|
<*> (whiteSpace *> reserved "in" *> nixApp)
|
||||||
|
|
||||||
|
nixIf :: Parser NExpr
|
||||||
|
nixIf = Fix <$> (NIf
|
||||||
|
<$> (reserved "if" *> nixApp)
|
||||||
|
<*> (reserved "then" *> nixApp)
|
||||||
|
<*> (reserved "else" *> nixApp))
|
||||||
|
|
||||||
-- | This is a bit tricky because we don't know whether we're looking at a set
|
-- | This is a bit tricky because we don't know whether we're looking at a set
|
||||||
-- or a lambda until we've looked ahead a bit. And then it may be neither,
|
-- or a lambda until we've looked ahead a bit. And then it may be neither,
|
||||||
-- in which case we fall back to expected a plain string or identifier.
|
-- in which case we fall back to expected a plain string or identifier.
|
||||||
|
|
Loading…
Reference in New Issue