diff --git a/nixd/lib/Syntax/Parser/Parser.y b/nixd/lib/Syntax/Parser/Parser.y index 1529d0992..d62e07146 100644 --- a/nixd/lib/Syntax/Parser/Parser.y +++ b/nixd/lib/Syntax/Parser/Parser.y @@ -63,7 +63,7 @@ %type binds %type attrpath %type attrs -%type expr_app +%type expr_app %type path_start %type spath %type uri @@ -192,14 +192,18 @@ expr_op expr_app : expr_app expr_select { - $$->Args.emplace_back($1); + if (auto F = dynamic_cast($1)) { + // If $1 is already a function call, then we insert the arg list + F->Args.emplace_back($2); + } else { + // Otherwise, create a new function + auto N = decorateNode(new Call, yylloc, *Data); + N->Fn = $1; + N->Args = {$2}; + } $$->Range = mkRange(yylloc, *Data); } - | expr_select { - auto N = decorateNode(new Call, yylloc, *Data); - N->Fn = $1; - $$ = N; - } + | expr_select expr_select diff --git a/nixd/test/Syntax/Basic.cpp b/nixd/test/Syntax/Basic.cpp index f51e09c4d..9b6cf058d 100644 --- a/nixd/test/Syntax/Basic.cpp +++ b/nixd/test/Syntax/Basic.cpp @@ -20,7 +20,7 @@ TEST(NixdSyntax, Case1) { .Origin = nix::Pos::Origin(nix::Pos::none_tag())}); Data->Result = nullptr; - char Test[] = "let { x = 1; y = 2; } in x\n\0\0"; + char Test[] = "let x = 1; y = 2; in x\n\0\0"; parse(Test, strlen(Test) + 2, Data.get()); }