Closed yu-re-ka closed 2 years ago
seems like associate priority problem in the parser. hnix parser does not expect nested keywords expresion
nixExpr :: Parser NExprLoc
nixExpr = keywords <|> nixLambda <|> nixExprAlgebra
where
keywords = nixLet <|> nixIf <|> nixAssert <|> nixWith
nixIf :: Parser NExprLoc
nixIf =
annotateNamedLocation "if" $
liftA3 NIf
(reserved "if" *> nixExprAlgebra)
(exprAfterReservedWord "then")
(exprAfterReservedWord "else")
nixExprAlgebra :: Parser NExprLoc
nixExprAlgebra =
makeExprParser
nixTerm
nixOperators
while nix parser
expr: expr_function;
expr_function
: ID ':' expr_function
{ $$ = new ExprLambda(CUR_POS, data->symbols.create($1), 0, $3); }
| '{' formals '}' ':' expr_function
{ $$ = new ExprLambda(CUR_POS, toFormals(*data, $2), $5); }
| '{' formals '}' '@' ID ':' expr_function
{
auto arg = data->symbols.create($5);
$$ = new ExprLambda(CUR_POS, arg, toFormals(*data, $2, CUR_POS, arg), $7);
}
| ID '@' '{' formals '}' ':' expr_function
{
auto arg = data->symbols.create($1);
$$ = new ExprLambda(CUR_POS, arg, toFormals(*data, $4, CUR_POS, arg), $7);
}
| ASSERT expr ';' expr_function
{ $$ = new ExprAssert(CUR_POS, $2, $4); }
| WITH expr ';' expr_function
{ $$ = new ExprWith(CUR_POS, $2, $4); }
| LET binds IN expr_function
{ if (!$2->dynamicAttrs.empty())
throw ParseError({
.msg = hintfmt("dynamic attributes not allowed in let"),
.errPos = data->state.positions[CUR_POS]
});
$$ = new ExprLet($2, $4);
}
| expr_if
;
expr_if
: IF expr THEN expr ELSE expr { $$ = new ExprIf(CUR_POS, $2, $4, $6); }
| expr_op
;
following nix should be an expression rather than arith expr
I am fixing it
it shoudl be fixed by now @yu-re-ka
The bug should be fixed but there is problem in your command since you are not providing enough arg to the function(alll-pckages.nix). @yu-re-ka
> cabal v2-run hnix -- --eval ~/proj/nixpkgs/pkgs/top-level/all-packages.nix
hnix: Missing value for parameter: ''VarName "lib"