diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2004-02-04T17·23+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2004-02-04T17·23+0000 |
commit | d445da7a7b3cbb4822bcad3904a36f0d914917d3 (patch) | |
tree | a44ad1a7ba4679dc49ff9d2197c13e27ae00a3b0 /src/libexpr/parser.y | |
parent | 9d25466b34a5f7c1c8b1c273976cf59c33961a6c (diff) |
* Extended the `inherit' syntax to optionally select attributes from
other attribute sets, rather than the current scope. E.g., {inherit (pkgs) gcc binutils;} is equivalent to {gcc = pkgs.gcc; binutils = pkgs.binutils;} I am not so happy about the syntax.
Diffstat (limited to 'src/libexpr/parser.y')
-rw-r--r-- | src/libexpr/parser.y | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index 6c0fdbda25f3..257c0cd38ab2 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -33,7 +33,7 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, void * data, char * s) } %type <t> start expr expr_function expr_assert expr_op -%type <t> expr_app expr_select expr_simple bind formal +%type <t> expr_app expr_select expr_simple bind inheritsrc formal %type <ts> binds ids expr_list formals %token <t> ID INT STR PATH URI %token IF THEN ELSE ASSERT LET REC INHERIT EQ NEQ AND OR IMPL @@ -114,8 +114,13 @@ binds bind : ID '=' expr ';' { $$ = ATmake("Bind(<term>, <term>)", $1, $3); } - | INHERIT ids ';' - { $$ = ATmake("Inherit(<term>)", $2); } + | INHERIT inheritsrc ids ';' + { $$ = ATmake("Inherit(<term>, <term>)", $2, $3); } + ; + +inheritsrc + : '(' expr ')' { $$ = $2; } + | { $$ = ATmake("Scope"); } ; ids: ids ID { $$ = ATinsert($1, $2); } | { $$ = ATempty; }; |