==============================
identifiers
==============================

abc_123_ABC
_fn!
ρ; φ; z
ℝ
x′
θ̄
logŷ
ϵ
ŷ

---

(source_file
  (identifier)
  (identifier)
  (identifier)
  (identifier)
  (identifier)
  (identifier)
  (identifier)
  (identifier)
  (identifier)
  (identifier)
  (identifier))


=================
Functions
=================

function test(x, y)
end

---

(source_file
  (function_definition
    (identifier)
    (parameter_list (identifier) (identifier))))

=================
Function calls
=================

a()
b("hi", 2)
c(d...)
d(e; f = g)
new{typeof(xs)}(xs)

---

(source_file
  (call_expression (identifier) (argument_list))
  (call_expression (identifier) (argument_list (string_literal) (integer_literal)))
  (call_expression (identifier) (argument_list (spread_expression (identifier))))
  (call_expression (identifier) (argument_list (identifier) (named_argument (identifier) (identifier))))
  (call_expression
    (parameterized_identifier
      (identifier)
      (type_argument_list
        (call_expression (identifier) (argument_list (identifier)))))
    (argument_list (identifier))))

=============================
Function calls with do blocks
=============================

a(b) do
  print(c)
end

---

(source_file
  (call_expression
    (identifier)
    (argument_list (identifier))
    (do_clause
      (call_expression (identifier) (argument_list (identifier))))))

=====================
Fields and subscripts
=====================

(a[1].b().c).d

---

(source_file
  (field_expression
    (parenthesized_expression (field_expression
      (call_expression
        (field_expression
          (subscript_expression (identifier) (integer_literal))
          (identifier))
        (argument_list))
      (identifier)))
    (identifier)))

=================
Macro calls
=================

@assert x == y
@assert x == y "a message"

@. a

@testset "a" begin
  b = c
end

---

(source_file
  (macro_expression
    (macro_identifier (identifier))
    (macro_argument_list
      (binary_expression (identifier) (operator) (identifier))))
  (macro_expression
    (macro_identifier (identifier))
    (macro_argument_list
      (binary_expression (identifier) (operator) (identifier))
      (string_literal)))
  (macro_expression (macro_identifier (operator)) (macro_argument_list (identifier)))
  (macro_expression
    (macro_identifier (identifier))
    (macro_argument_list
      (string_literal)
      (compound_expression (assignment_expression (identifier) (operator) (identifier))))))


===========================
Coefficient expressions
===========================

2x^2 - 3x + 1
1.5x^2 - .5x + 1
2^2x
2(x-1)^2 - 3(x-1) + 1

---

(source_file
  (binary_expression
    (binary_expression
      (binary_expression
        (coefficient_expression (integer_literal) (identifier))
        (operator)
        (integer_literal))
      (operator)
      (coefficient_expression (integer_literal) (identifier)))
    (operator)
    (integer_literal))
  (binary_expression
    (binary_expression
      (binary_expression
        (coefficient_expression (float_literal) (identifier))
        (operator)
        (integer_literal))
      (operator)
      (coefficient_expression (float_literal) (identifier)))
    (operator)
    (integer_literal))
  (binary_expression
    (integer_literal)
    (operator)
    (coefficient_expression (integer_literal) (identifier)))
  (binary_expression
    (binary_expression
      (binary_expression
        (coefficient_expression
          (integer_literal)
          (parenthesized_expression (binary_expression (identifier) (operator) (integer_literal))))
        (operator)
        (integer_literal))
      (operator)
      (coefficient_expression
        (integer_literal)
        (parenthesized_expression (binary_expression (identifier) (operator) (integer_literal)))))
    (operator)
    (integer_literal)))

=================
Tuples
=================

()
(1)
(1,)
(2,3,4,)

---

(source_file
  (tuple_expression)
  (parenthesized_expression (integer_literal))
  (tuple_expression (integer_literal))
  (tuple_expression (integer_literal) (integer_literal) (integer_literal)))

=================
Named tuples
=================

(a = 1)
(a = 1,)
(a = 1, b = 2)

---

(source_file
  (parenthesized_expression
    (assignment_expression (identifier) (operator) (integer_literal)))
  (tuple_expression
    (named_field (identifier) (integer_literal)))
  (tuple_expression
    (named_field (identifier) (integer_literal))
    (named_field (identifier) (integer_literal))))

=================
Arrays
=================

[]
[1, 2,]

---

(source_file
  (array_expression)
  (array_expression (integer_literal) (integer_literal)))

=================
Matrices
=================

[1 2]
[1 2; 3 4]
[1 2; 3 4;]

---

(source_file
  (matrix_expression
    (matrix_row (integer_literal) (integer_literal)))
  (matrix_expression
    (matrix_row (integer_literal) (integer_literal))
    (matrix_row (integer_literal) (integer_literal)))
  (matrix_expression
    (matrix_row (integer_literal) (integer_literal))
    (matrix_row (integer_literal) (integer_literal))))


====================
Function expressions
====================

x -> x^2
(x,y,z)->2x+y-z
()->3
function () 3 end
() -> (sleep(0.1); i += 1; l)

---

(source_file
  (function_expression
    (identifier)
    (binary_expression (identifier) (operator) (integer_literal)))
  (function_expression
    (parameter_list (identifier) (identifier) (identifier))
    (binary_expression
      (binary_expression
        (coefficient_expression (integer_literal) (identifier))
        (operator)
        (identifier))
      (operator)
      (identifier)))
  (function_expression
    (parameter_list)
    (integer_literal))
  (function_expression
    (parameter_list)
    (integer_literal))
  (function_expression
    (parameter_list)
    (parenthesized_expression
      (call_expression (identifier) (argument_list (float_literal)))
      (assignment_expression (identifier) (operator) (integer_literal))
      (identifier))))

============================
Generator expressions
============================

(b(c, e) for c in d, e = 5 if e)
[b(c, e) for c in d for e in f]

---

(source_file
  (generator_expression
    (call_expression (identifier) (argument_list (identifier) (identifier)))
    (for_clause
      (for_binding (identifier) (identifier))
      (for_binding (identifier) (integer_literal)))
    (if_clause (identifier)))
  (array_comprehension_expression
    (call_expression (identifier) (argument_list (identifier) (identifier)))
    (for_clause (for_binding (identifier) (identifier)))
    (for_clause (for_binding (identifier) (identifier)))))
