From 2548a2e5d8552cdf3f07a2108d56472d0b7553a7 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Sat, 16 Sep 2023 11:15:09 +0800 Subject: [PATCH] nixd/Syntax: add more derivation rules --- nixd/lib/Syntax/Parser.y | 48 +++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/nixd/lib/Syntax/Parser.y b/nixd/lib/Syntax/Parser.y index 7484ac03a..c75be916c 100644 --- a/nixd/lib/Syntax/Parser.y +++ b/nixd/lib/Syntax/Parser.y @@ -41,12 +41,6 @@ %token STR IND_STR %token PATH HPATH SPATH PATH_END %token URI -/* %token ID ATTRPATH -%token STR IND_STR -%token INT -%token FLOAT -%token PATH HPATH SPATH PATH_END -%token URI */ %token IF THEN ELSE ASSERT WITH LET IN REC INHERIT EQ NEQ AND OR IMPL OR_KW %token DOLLAR_CURLY /* == ${ */ %token IND_STRING_OPEN IND_STRING_CLOSE @@ -134,6 +128,43 @@ expr_select expr_simple : identifier + | INT + | FLOAT + | '"' string_parts '"' + | IND_STRING_OPEN ind_string_parts IND_STRING_CLOSE + | path_start PATH_END + | path_start string_parts_interpolated PATH_END + | SPATH + | URI + | '(' expr ')' + | LET '{' binds '}' + | REC '{' binds '}' + | '{' binds '}' + | '[' expr_list ']' + ; + +string_parts + : STR + | string_parts_interpolated + | + ; + +string_parts_interpolated + : string_parts_interpolated STR + | string_parts_interpolated DOLLAR_CURLY expr '}' + | DOLLAR_CURLY expr '}' + | STR DOLLAR_CURLY expr '}' + ; + +path_start + : PATH + | HPATH + ; + +ind_string_parts + : ind_string_parts IND_STR + | ind_string_parts DOLLAR_CURLY expr '}' + | ; identifier @@ -171,6 +202,11 @@ string_attr : DOLLAR_CURLY expr '}' ; +expr_list + : expr_list expr_select + | + ; + formals : formal ',' formals | formal