Skip to content

Commit

Permalink
nixd/Syntax: allow expr_app -> expr_simple passthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc committed Sep 17, 2023
1 parent 6a7dbaa commit 5f5127d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions nixd/lib/Syntax/Parser/Parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
%type <Binds> binds
%type <AttrPath> attrpath
%type <Attrs> attrs
%type <Call> expr_app
%type <Node> expr_app
%type <Node> path_start
%type <SPath> spath
%type <Uri> uri
Expand Down Expand Up @@ -192,14 +192,18 @@ expr_op

expr_app
: expr_app expr_select {
$$->Args.emplace_back($1);
if (auto F = dynamic_cast<Call *>($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
Expand Down
2 changes: 1 addition & 1 deletion nixd/test/Syntax/Basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down

0 comments on commit 5f5127d

Please sign in to comment.