====================
empty source
====================

---

(source_code)

====================
comments
====================

# This is a comment.

/*
This is also a comment.
*/

/*This as well, even with two asterisks.**/

"This is a string."

---

(source_code (comment) (comment) (comment) (string_expression (string_fragment)))

====================
identifier
====================

abc

---

(source_code (variable_expression (identifier)))

====================
integer_expression
====================

123

---

(source_code (integer_expression))

====================
float_expression
====================

123.456

---

(source_code (float_expression))

====================
uri
====================

http://foobar.com:80?baz=quux&blarg=etc

---

(source_code (uri_expression))

====================
list (empty)
====================

[ ]

---

(source_code (list_expression))

====================
list
====================

[ a 1 2.0 ]

---

(source_code (list_expression (variable_expression (identifier)) (integer_expression) (float_expression)))

====================
if
====================

if a then b else c

---

(source_code (if_expression (variable_expression (identifier)) (variable_expression (identifier)) (variable_expression (identifier))))

====================
assert
====================

assert a; b

---

(source_code (assert_expression (variable_expression (identifier)) (variable_expression (identifier))))

====================
with
====================

with a; b

---

(source_code (with_expression (variable_expression (identifier)) (variable_expression (identifier))))

====================
let (empty)
====================

let in a

---

(source_code (let_expression (variable_expression (identifier))))

====================
let (binding)
====================

let a = b; in c

---

(source_code
    (let_expression
        (binding_set
            (binding
                (attrpath (identifier))
                (variable_expression (identifier))))
        (variable_expression (identifier))))

====================
let (binding, comments)
====================

let
  # foo
  a = b;
  # bar
  x = y;
  in
    # baz
    c

---

(source_code
    (let_expression
        (comment)
        (binding_set
            (binding (attrpath (identifier)) (variable_expression (identifier)))
            (comment)
            (binding (attrpath (identifier)) (variable_expression (identifier))))
        (comment)
        (variable_expression (identifier))))

====================
let (inherit)
====================

let inherit a; in c

---

(source_code
    (let_expression
        (binding_set
            (inherit
                (inherited_attrs
                    (identifier))))
        (variable_expression (identifier))))

====================
let (inherit from)
====================

let inherit (a) b "c" ${d}; in 123

---

(source_code
    (let_expression
        (binding_set
            (inherit_from
                (variable_expression (identifier))
                (inherited_attrs
                    (identifier) (string_expression (string_fragment)) (interpolation (variable_expression (identifier))))))
        (integer_expression)))

====================
function_expression
====================

a: b

---

(source_code (function_expression (identifier) (variable_expression (identifier))))

====================
function_expression (with_expression formals)
====================

a@{ /*1*/ b, /*2*/ c ? 123, /*3*/ ... }: 1.234

---

(source_code
    (function_expression
        (identifier)
        (formals
            (comment)
            (formal (identifier))
            (comment)
            (formal (identifier) (integer_expression))
            (comment)
            (ellipses))
        (float_expression)))

====================
rec. attrset (empty)
====================

rec { }

---

(source_code (rec_attrset_expression))

====================
let attrset (empty)
====================

let { }

---

(source_code (let_attrset_expression))

====================
attrset (empty)
====================

{ }

---

(source_code (attrset_expression))

====================
attr set
====================

{ a = 1; ${b} = "quux"; "c" = 3.14; x.y.z = <foo>; }

---

(source_code
    (attrset_expression
        (binding_set
            (binding (attrpath (identifier)) (integer_expression))
            (binding (attrpath (interpolation (variable_expression (identifier)))) (string_expression (string_fragment)))
            (binding (attrpath (string_expression (string_fragment))) (float_expression))
            (binding (attrpath (identifier) (identifier) (identifier)) (spath_expression)))))

====================
select_expression
====================

u.v.${w}."x${y}z"

---

(source_code
    (select_expression
        (variable_expression (identifier))
        (attrpath
            (identifier)
            (interpolation (variable_expression (identifier)))
            (string_expression
                (string_fragment)
                (interpolation (variable_expression (identifier)))
                (string_fragment)))))



====================
hasAttr operator
====================

a ? ${b}.c."d"

---

(source_code
    (has_attr_expression
        (variable_expression (identifier))
        (attrpath
            (interpolation (variable_expression (identifier)))
            (identifier)
            (string_expression (string_fragment)))))

====================
apply_expressionlication
====================

a 1 2.0

---

(source_code
    (apply_expression
        (apply_expression
            (variable_expression (identifier))
            (integer_expression))
        (float_expression)))

====================
path_expression test
====================

a/c${x}c

---

(source_code
    (path_expression
        (path_fragment)
        (interpolation
            (variable_expression (identifier)))
        (path_fragment)))


====================
path_expression1
====================

x/a${x}a.a${123}

---

(source_code
    (path_expression
        (path_fragment)
        (interpolation
            (variable_expression (identifier)))
        (path_fragment)
        (interpolation
            (integer_expression))))

====================
path_expression2
====================

x/a${x}a/a${123}

---

(source_code
    (path_expression
        (path_fragment)
        (interpolation
            (variable_expression (identifier)))
        (path_fragment)
        (interpolation
            (integer_expression))))


====================
path_expression3
====================

/abc

---

(source_code
    (path_expression
        (path_fragment)))

====================
path_expression4
====================

-123/abc

---

(source_code
    (path_expression
        (path_fragment)))

====================
path_expression5
====================

dir/${name}.${extension}

---

(source_code
    (path_expression
        (path_fragment)
        (interpolation
            (variable_expression (identifier)))
        (path_fragment)
        (interpolation
            (variable_expression (identifier)))))

====================
path_expression6
====================


a/b${c} d/e${f}

---

(source_code
    (apply_expression
        (path_expression
            (path_fragment)
            (interpolation
            (variable_expression (identifier))))
        (path_expression
            (path_fragment)
            (interpolation
            (variable_expression (identifier))))))

====================
hpath_expression1
====================

~/.

---

(source_code
    (hpath_expression
        (path_fragment)))


====================
hpath_expression2
====================

~/a${x}a/a${123}

---

(source_code
    (hpath_expression
        (path_fragment)
        (interpolation
            (variable_expression (identifier)))
        (path_fragment)
        (interpolation
            (integer_expression))))

====================
division not mistaken for path_expressions (1)
====================

a/ b

---

(source_code
    (binary_expression
        (variable_expression (identifier))
        (variable_expression (identifier))))

====================
path_expression craziness - see https://github.com/NixOS/nix/pull/5066#issuecomment-1071918251
====================

a.${foo}/b.${bar}

---

(source_code
    (apply_expression
        (select_expression
            (variable_expression (identifier))
            (attrpath
            (interpolation
                (variable_expression (identifier)))))
        (path_expression
            (path_fragment)
            (interpolation
                (variable_expression (identifier))))))

====================
operators
====================

square 2 + -pi - 42.0

---

(source_code
    (binary_expression
        (binary_expression
            (apply_expression (variable_expression (identifier)) (integer_expression))
            (unary_expression (variable_expression (identifier))))
        (float_expression)))

====================
parens
====================

(123)

---

(source_code
    (parenthesized_expression (integer_expression)))
