From a0f9b197b5918ab4a3de8bbfcd8a128c85d63f05 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Sun, 17 Sep 2023 14:41:22 +0800 Subject: [PATCH] nixd/Syntax: actions for attr/string_attr --- nixd/lib/Syntax/Parser/Parser.y | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/nixd/lib/Syntax/Parser/Parser.y b/nixd/lib/Syntax/Parser/Parser.y index 340d409aa..5e8dd20c9 100644 --- a/nixd/lib/Syntax/Parser/Parser.y +++ b/nixd/lib/Syntax/Parser/Parser.y @@ -45,10 +45,11 @@ %type start expr expr_function expr_if expr_op expr_select expr_simple %type string_parts +%type string_attr %type string ind_string; %type string_parts_interpolated %type string_parts_interp_expr -%type identifier +%type identifier attr %type ind_string_parts %type formals %type formal @@ -393,14 +394,21 @@ attrpath attr - : identifier - | OR_KW + : identifier { + $$ = $1; + } + | OR_KW { + auto Or = Data->State.Symbols.create("or"); + $$ = decorateNode(new Identifier { + .Symbol = Or + }, yylloc, *Data); + } string_attr - : '"' string_parts '"' - | string_parts_interp_expr + : '"' string_parts '"' { $$ = $2; } + | string_parts_interp_expr { $$ = $1; } expr_list