From dcbb181c5dbc0793cfe07f3307ae40eade6ca869 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Sun, 17 Sep 2023 10:49:59 +0800 Subject: [PATCH] nixd/Syntax: actions for attrs --- nixd/include/nixd/Syntax/Nodes.inc | 7 +++++++ nixd/lib/Syntax/Parser/Parser.y | 20 +++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/nixd/include/nixd/Syntax/Nodes.inc b/nixd/include/nixd/Syntax/Nodes.inc index 12daf0fb6..2e1a97f3a 100644 --- a/nixd/include/nixd/Syntax/Nodes.inc +++ b/nixd/include/nixd/Syntax/Nodes.inc @@ -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, { \ diff --git a/nixd/lib/Syntax/Parser/Parser.y b/nixd/lib/Syntax/Parser/Parser.y index 074b1b28b..5c399718f 100644 --- a/nixd/lib/Syntax/Parser/Parser.y +++ b/nixd/lib/Syntax/Parser/Parser.y @@ -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