Skip to content

Commit

Permalink
nixd/Syntax: actions for attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc committed Sep 17, 2023
1 parent bfb6159 commit dcbb181
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
7 changes: 7 additions & 0 deletions nixd/include/nixd/Syntax/Nodes.inc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ NODE(OpNegate, { Node *Body; })

NODE(Braced, { Node *Body; })

NODE(AttrSet, {
Binds *Binds;
bool Recursive;
})

NODE(LegacyLet, { Binds *Binds; })

// Binary Operators
#define BIN_OP(NAME, _) \
NODE(NAME, { \
Expand Down
20 changes: 17 additions & 3 deletions nixd/lib/Syntax/Parser/Parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,23 @@ expr_simple
.Body = $2
}, yylloc, *Data);
}
| LET '{' binds '}'
| REC '{' binds '}'
| '{' binds '}'
| LET '{' binds '}' {
$$ = decorateNode(new LegacyLet {
.Binds = $3
}, yylloc, *Data);
}
| REC '{' binds '}' {
$$ = decorateNode(new AttrSet {
.Binds = $3,
.Recursive = true
}, yylloc, *Data);
}
| '{' binds '}' {
$$ = decorateNode(new AttrSet {
.Binds = $2,
.Recursive = false
}, yylloc, *Data);
}
| '[' expr_list ']'

string_parts
Expand Down

0 comments on commit dcbb181

Please sign in to comment.