aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/parser.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-02-04 17:23:26 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-02-04 17:23:26 +0000
commitd445da7a7b3cbb4822bcad3904a36f0d914917d3 (patch)
treea44ad1a7ba4679dc49ff9d2197c13e27ae00a3b0 /src/libexpr/parser.cc
parent9d25466b34a5f7c1c8b1c273976cf59c33961a6c (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.cc')
-rw-r--r--src/libexpr/parser.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/libexpr/parser.cc b/src/libexpr/parser.cc
index 68b367340..c300a0d07 100644
--- a/src/libexpr/parser.cc
+++ b/src/libexpr/parser.cc
@@ -50,11 +50,16 @@ ATerm fixAttrs(int recursive, ATermList as)
ATermList * is = recursive ? &cs : &bs;
for (ATermIterator i(as); i; ++i) {
ATermList names;
- if (atMatch(m, *i) >> "Inherit" >> names)
- for (ATermIterator j(names); j; ++j)
- *is = ATinsert(*is,
- ATmake("Bind(<term>, Var(<term>))", *j, *j));
- else bs = ATinsert(bs, *i);
+ Expr src;
+ if (atMatch(m, *i) >> "Inherit" >> src >> names) {
+ bool fromScope = atMatch(m, src) >> "Scope";
+ for (ATermIterator j(names); j; ++j) {
+ Expr rhs = fromScope
+ ? ATmake("Var(<term>)", *j)
+ : ATmake("Select(<term>, <term>)", src, *j);
+ *is = ATinsert(*is, ATmake("Bind(<term>, <term>)", *j, rhs));
+ }
+ } else bs = ATinsert(bs, *i);
}
if (recursive)
return ATmake("Rec(<term>, <term>)", bs, cs);