about summary refs log tree commit diff
path: root/src/libexpr/nixexpr.cc (follow)
AgeCommit message (Collapse)AuthorFilesLines
2017-07-30 Replace Unicode quotes in user-facing strings by ASCIIJörg Thalheim1-2/+2
Relevant RFC: NixOS/rfcs#4 $ ag -l | xargs sed -i -e "/\"/s/’/'/g;/\"/s/‘/'/g"
2016-11-26 Revert "Get rid of unicode quotes (#1140)"Eelco Dolstra1-2/+2
This reverts commit f78126bfd6b6c8477fcdbc09b2f98772dbe9a1e7. There really is no need for such a massive change...
2016-11-25 Get rid of unicode quotes (#1140)Guillaume Maudoux1-2/+2
2016-01-05 First hit at providing support for floats in the language.Christian Theune1-0/+9
2015-12-17 showId: Handle empty attribute namesEelco Dolstra1-2/+3
We should probably disallow these, but until then, we shouldn't barf with an assertion failure. Fixes #738.
2015-07-17 OCD: foreach -> C++11 ranged forEelco Dolstra1-46/+46
2015-03-06 Improve error messageEelco Dolstra1-8/+5
2015-01-07 Remove quotes around filenames in position infoEelco Dolstra1-1/+1
2014-10-20 Improve printing of ASTsEelco Dolstra1-9/+57
2014-08-20 Use proper quotes everywhereEelco Dolstra1-2/+2
2014-08-20 Add some colorEelco Dolstra1-1/+1
2014-05-26 Remove ExprBuiltinEelco Dolstra1-9/+0
It's slower than ExprVar since it doesn't compute a static displacement. Since we're not using the throw primop in the implementation of <...> anymore, it's also not really needed.
2014-04-04 forceString: Show position infoEelco Dolstra1-1/+1
2014-04-04 Remove unnecessary quotes around file namesEelco Dolstra1-1/+1
2014-04-04 Include position info in function applicationEelco Dolstra1-1/+1
This allows error messages like: error: the anonymous function at `/etc/nixos/configuration.nix:1:1' called without required argument `foo', at `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix:77:59'
2014-04-01 Fix potential segfaultEelco Dolstra1-2/+3
The newEnv variable was accessed (via the dynamicEnv) pointer after it had gone out of scope. Fixes #234.
2013-12-31 Don't use any syntactic sugar for dynamic attrsShea Levy1-4/+17
This doesn't change any functionality but moves some behavior out of the parser and into the evaluator in order to simplify the code. Signed-off-by: Shea Levy <shea@shealevy.com>
2013-12-31 Dynamic attrsShea Levy1-0/+9
This adds new syntax for attribute names: * attrs."${name}" => getAttr name attrs * attrs ? "${name}" => isAttrs attrs && hasAttr attrs name * attrs."${name}" or def => if attrs ? "${name}" then attrs."${name}" else def * { "${name}" = value; } => listToAttrs [{ inherit name value; }] Of course, it's a bit more complicated than that. The attribute chains can be arbitrarily long and contain combinations of static and dynamic parts (e.g. attrs."${foo}".bar."${baz}" or qux), which is relatively straightforward for the getAttrs/hasAttrs cases but is more complex for the listToAttrs case due to rules about duplicate attribute definitions. For attribute sets with dynamic attribute names, duplicate static attributes are detected at parse time while duplicate dynamic attributes are detected when the attribute set is forced. So, for example, { a = null; a.b = null; "${"c"}" = true; } will be a parse-time error, while { a = {}; "${"a"}".b = null; c = true; } will be an eval-time error (technically that case could theoretically be detected at parse time, but the general case would require full evaluation). Moreover, duplicate dynamic attributes are not allowed even in cases where they would be with static attributes ({ a.b.d = true; a.b.c = false; } is legal, but { a."${"b"}".d = true; a."${"b"}".c = false; } is not). This restriction might be relaxed in the future in cases where the static variant would not be an error, but it is not obvious that that is desirable. Finally, recursive attribute sets with dynamic attributes have the static attributes in scope but not the dynamic ones. So rec { a = true; "${"b"}" = a; } is equivalent to { a = true; b = true; } but rec { "${"a"}" = true; b = a; } would be an error or use a from the surrounding scope if it exists. Note that the getAttr, getAttr or default, and hasAttr are all implemented purely in the parser as syntactic sugar, while attribute sets with dynamic attribute names required changes to the AST to be implemented cleanly. This is an alternative solution to and closes #167 Signed-off-by: Shea Levy <shea@shealevy.com>
2013-12-31 Add the ExprBuiltin Expr type to the ASTShea Levy1-0/+9
Certain desugaring schemes may require the parser to use some builtin function to do some of the work (e.g. currently `throw` is used to lazily cause an error if a `<>`-style path is not in the search path) Unfortunately, these names are not reserved keywords, so an expression that uses such a syntactic sugar will not see the expected behavior (see tests/lang/eval-okay-redefine-builtin.nix for an example). This adds the ExprBuiltin AST type, which when evaluated uses the value from the rootmost variable scope (which of course is initialized internally and can't shadow any of the builtins). Signed-off-by: Shea Levy <shea@shealevy.com>
2013-11-18 Add a symbol __curPos that expands to the current source locationEelco Dolstra1-0/+9
I.e. an attribute set { file = <string>; line = <int>; column = <int>; }.
2013-11-12 Make function calls tail-recursiveEelco Dolstra1-1/+1
2013-10-08 printStats(): Print the size of the symbol table in bytesEelco Dolstra1-0/+12
2013-10-08 Treat undefined variable errors consistentlyEelco Dolstra1-1/+1
Previously, a undefined variable inside a "with" caused an EvalError (which can be caught), while outside, it caused a ParseError (which cannot be caught). Now both cause an UndefinedVarError (which cannot be caught).
2013-10-08 Show the exact position of undefined variablesEelco Dolstra1-1/+1
In particular, undefined variable errors in a "with" previously didn't show *any* position information, so this should help a lot in those cases.
2013-10-08 Merge VarRef into ExprVarEelco Dolstra1-7/+2
2013-09-02 Fix whitespaceEelco Dolstra1-9/+9
2013-08-26 Simplify inherited attribute handlingShea Levy1-6/+3
This reduces the difference between inherited and non-inherited attribute handling to the choice of which env to use (in recs and lets) by setting the AttrDef::e to a new ExprVar in the parser rather than carrying a separate AttrDef::v VarRef member. As an added bonus, this allows inherited attributes that inherit from a with to delay forcing evaluation of the with's attributes. Signed-off-by: Shea Levy <shea@shealevy.com>
2013-05-16 Show function names in error messagesEelco Dolstra1-0/+20
Functions in Nix are anonymous, but if they're assigned to a variable/attribute, we can use the variable/attribute name in error messages, e.g. while evaluating `concatMapStrings' at `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/lib/strings.nix:18:25': ...
2011-07-13 * Allow a default value in attribute selection by writingEelco Dolstra1-0/+2
x.y.z or default (as originally proposed in https://mail.cs.uu.nl/pipermail/nix-dev/2009-September/002989.html). For instance, an expression like stdenv.lib.attrByPath ["features" "ckSched"] false args can now be written as args.features.ckSched or false
2011-07-06 * Change the right-hand side of the ‘.’ operator from an attribute toEelco Dolstra1-1/+1
an attribute path. This is a refactoring to support default values.
2011-07-06 * In the ‘?’ operator, allow attribute paths. For instance, you canEelco Dolstra1-1/+12
write ‘attrs ? a.b’ to test whether ‘attrs’ has an attribute ‘a’ containing an attribute ‘b’. This is more convenient than ‘attrs ? a && attrs.a ? b’. Slight change in the semantics: it's no longer an error if the left-hand side of ‘?’ is not an attribute set. In that case it just returns false. So, ‘null ? foo’ no longer throws an error.
2010-10-24 * Keep attribute sets in sorted order to speed up attribute lookups.Eelco Dolstra1-37/+26
* Simplify the representation of attributes in the AST. * Change the behaviour of listToAttrs() in case of duplicate names.
2010-10-22 * Store Value nodes outside of attribute sets. I.e., Attr now storesEelco Dolstra1-2/+2
a pointer to a Value, rather than the Value directly. This improves the effectiveness of garbage collection a lot: if the Value is stored inside the set directly, then any live pointer to the Value causes all other attributes in the set to be live as well.
2010-05-07 * Store position info for inherited attributes.Eelco Dolstra1-12/+12
2010-05-06 * Store attribute positions in the AST and report duplicate attributeEelco Dolstra1-5/+8
errors with position info. * For all positions, use the position of the first character of the first token, rather than the last character of the first token plus one.
2010-04-22 * Simplify the implementation of `with'. This gives a 7% speedup inEelco Dolstra1-4/+4
evaluating the NixOS system configuration.
2010-04-14 * Implemented inherit.Eelco Dolstra1-9/+17
2010-04-14 * Refactoring: move variable uses to a separate class.Eelco Dolstra1-2/+7
2010-04-14 * Implemented withs.Eelco Dolstra1-0/+12
2010-04-14 * After parsing, compute level/displacement pairs for each variableEelco Dolstra1-79/+139
use site, allowing environments to be stores as vectors of values rather than maps. This should speed up evaluation and reduce the number of allocations.
2010-04-14 * Remove more obsolete code.Eelco Dolstra1-29/+0
2010-04-13 * Evaluate lets directly (i.e. without desugaring to `rec { attrs...;Eelco Dolstra1-0/+10
<let-body> = e; }.<let-body>). This prevents the unnecessary allocation of an attribute set.
2010-04-13 * Use a symbol table to represent identifiers and attribute namesEelco Dolstra1-3/+3
efficiently. The symbol table ensures that there is only one copy of each symbol, thus allowing symbols to be compared efficiently using a pointer equality test.
2010-04-12 * Finished the ATerm-less parser.Eelco Dolstra1-1/+1
2010-04-12 * Indented strings.Eelco Dolstra1-14/+5
2010-04-12 * More missing constructs.Eelco Dolstra1-8/+31
2010-04-12 * Don't use ATerms for the abstract syntax trees anymore. NotEelco Dolstra1-27/+83
finished yet.
2010-04-08 * Remove a lot of dead code.Eelco Dolstra1-217/+0
2010-03-25 * Simplify @-patterns: only `{attrs}@name' or `name@{attrs}' are nowEelco Dolstra1-6/+2
allowed. So `name1@name2', `{attrs1}@{attrs2}' and so on are now no longer legal. This is no big loss because they were not useful anyway. This also changes the output of builtins.toXML for @-patterns slightly.
2009-05-15 * Some syntactic sugar for attribute sets: allow {x.y.z = ...;} as aEelco Dolstra1-1/+1
shorthand for {x = {y = {z = ...;};};}. This is especially useful for NixOS configuration files, e.g. { services = { sshd = { enable = true; port = 2022; }; }; } can now be written as { services.sshd.enable = true; services.sshd.port = 2022; } However, it is currently not permitted to write { services.sshd = {enable = true;}; services.sshd.port = 2022; } as this is considered a duplicate definition of `services.sshd'.