1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File which contains all possible syntax constructs in order to fully test the JSON output from `nix-instantiate --parse`

# ExprWith
with {};
# ExprList
[
  # ExprInt
  0
  # ExprFloat
  0.0
  # ExprString
  ""
  "foo"
  "foo\nbar"
  # ExprPath
  /root
  # ExprVar
  var1
  # ExprSelect
  foo.bar or baz
  # ExprOpHasAttr
  (foo ? bar.baz)
  # ExprSet (ExprAttrs, ExprInheritFrom, ...)
  { }
  rec { }
  {
    attr1 = value1;
    attr2 = null;
    inherit foo;
    inherit (bar) baz;
    inherit (complicated [ expression ]) thing;
    inherit;
    "string attr" = "string value";
    ${"fake dynamic attr"} = 42;
    ${dynamicAttr}.${"anotherOne" + ""} = null;
    attr3.nested = { more = 0; };
    attr3.nested.merged = 1;
  }
  rec {
    attr1 = value1;
    attr2 = null;
    inherit foo;
    inherit (bar) baz;
    inherit (complicated [ expression ]) thing;
    inherit;
    "string attr" = "string value";
    ${"fake dynamic attr"} = 42;
    ${dynamicAttr}.${"anotherOne" + ""} = null;
    attr3.nested = { more = 0; };
    attr3.nested.merged = 1;
  }
  (
    # ExprLet
    let in
    let
      attr1 = value1;
      attr2 = null;
      inherit foo;
      inherit (bar) baz;
      inherit (complicated [ expression ]) thing;
      inherit;
      "string attr" = "string value";
      ${"fake dynamic attr"} = 42;
      attr3.nested = { more = 0; };
      attr3.nested.merged = 1;
    in
    # ExprAssert
    assert false;
    assert true;
    assert let in (myFunction {}.overrideStuff) == 4.2;
    [ ]
  )
  # ExprLambda
  (x: x)
  (x: y: z: z y x)
  ({}: null)
  ({...}: null)
  ({}@arg: null)
  ({foo ? null, bar, baz}@all: all)
  (all@{foo ? null, ...}: all)
  # ExprIf
  (if null then 0 else 1)
  # ExprOpNot
  (!true)
  # ExprOpEq, ExprOpNEq, ExprOpAnd, ExprOpOr, ExprOpImpl, and general arithmetic
  (7 + (-5) * 12 / 3 - 1)
  (0 + -10 + -(-11) + -x)
  (if 2 > 1 == 1 < 2 -> 2 >= 1 != 1 <= 2 && true || false then 1 else err)
  # ExprOpUpdate
  (foo // {} // bar.baz)
  # ExprOpConcatLists
  (foo ++ [] ++ optional cond value)
  # ExprConcatStrings
  (1 + 2 + 3)
  "${""}"
  "Foo ${3 + "2"}"
  # ExprPos
  __curPos
]