==============================
assignment operators
==============================

a = b
a .. b = a * b
tup = 1, 2, 3
car, cdr... = list
c &= d ÷= e

---
(source_file
  (assignment
    (identifier)
    (operator)
    (identifier))

  (assignment
    (binary_expression (identifier) (operator) (identifier))
    (operator)
    (binary_expression (identifier) (operator) (identifier)))

  (assignment
    (identifier)
    (operator)
    (open_tuple
      (integer_literal)
      (integer_literal)
      (integer_literal)))

  (assignment
    (open_tuple
      (identifier)
      (splat_expression (identifier)))
    (operator)
    (identifier))

  (compound_assignment_expression
    (identifier)
    (operator)
    (compound_assignment_expression
      (identifier)
      (operator)
      (identifier))))

==============================
binary arithmetic operators
==============================

a + b
a ++ 1 × b ⥌ 2 → c
a // b
x = A \ (v × w)

---
(source_file
  ; Sanity check
  (binary_expression (identifier) (operator) (identifier))

  ; plus/times/power/arrow
  ; (→ (++ a (× 1 (⥌ b 2))) c)
  (binary_expression
    (binary_expression
      (identifier)
      (operator)
      (binary_expression
        (integer_literal)
        (operator)
        (binary_expression
          (identifier)
          (operator)
          (integer_literal))))
    (operator)
    (identifier))

  ; Rational
  (binary_expression
    (identifier)
    (operator)
    (identifier))

  ; Linear algebra
  (assignment
    (identifier)
    (operator)
    (binary_expression
      (identifier)
      (operator)
      (parenthesized_expression
        (binary_expression
          (identifier)
          (operator)
          (identifier))))))


==============================
other binary operators
==============================

a & b | c
(x >>> 16, x >>> 8, x) .& 0xff

Dict(b => c, d => e)

x |>
  f |>
  g

1..10
(1:10...,)

---
(source_file
  ; Bitwise
  (binary_expression
    (binary_expression (identifier) (operator) (identifier))
    (operator)
    (identifier))
  (binary_expression
    (tuple_expression
      (binary_expression (identifier) (operator) (integer_literal))
      (binary_expression (identifier) (operator) (integer_literal))
      (identifier))
    (operator)
    (integer_literal))

  ; Pairs
  (call_expression
    (identifier)
    (argument_list
      (binary_expression (identifier) (operator) (identifier))
      (binary_expression (identifier) (operator) (identifier))))

  ; Pipes (and newline)
  (binary_expression
    (binary_expression
      (identifier)
      (operator)
      (identifier))
      (operator)
      (identifier))

  ; Ellipses
  (binary_expression
    (integer_literal)
    (operator)
    (integer_literal))
  (tuple_expression
    (splat_expression
      (range_expression
        (integer_literal)
        (integer_literal)))))


==============================
binary comparison operators
==============================

a === 1
a! != 0

A ⊆ B ⊆ C
x ≥ 0 ≥ z

---
(source_file
  (binary_expression (identifier) (operator) (integer_literal))
  (binary_expression (identifier) (operator) (integer_literal))

  ; Chained comparisons are parsed as a single expression in Julia.
  ; So this isn't 100% correct.
  (binary_expression
    (binary_expression
      (identifier)
      (operator)
      (identifier))
    (operator)
    (identifier))
  (binary_expression
    (binary_expression
      (identifier)
      (operator)
      (integer_literal))
    (operator)
    (identifier)))


==============================
unary operators
==============================

-A'
+a
-b
√9
!p === !(p)
1 ++ +2

---
(source_file
  (unary_expression (operator) (adjoint_expression (identifier)))
  (unary_expression (operator) (identifier))
  (unary_expression (operator) (identifier))
  (unary_expression (operator) (integer_literal))
  (binary_expression
    (unary_expression (operator) (identifier))
    (operator)
    (call_expression (operator) (argument_list (identifier))))
  (binary_expression
    (integer_literal)
    (operator)
    (unary_expression (operator) (integer_literal))))


=============================
operator broadcasting
=============================

a .* b .+ c
.~[x]

---
(source_file
  (binary_expression
    (binary_expression (identifier) (operator) (identifier))
    (operator)
    (identifier))
  (unary_expression
    (operator)
    (vector_expression (identifier))))


==============================
ternary operator
==============================

x = batch_size == 1 ?
  rand(10) :
  rand(10, batch_size)

---

(source_file
  (assignment
    (identifier)
    (operator)
    (ternary_expression
      (binary_expression (identifier) (operator) (integer_literal))
      (call_expression (identifier) (argument_list (integer_literal)))
      (call_expression (identifier) (argument_list (integer_literal) (identifier))))))


==============================
operators as values
==============================

x = +
⪯ = .≤
print(:)
foo(^, ÷, -)

---
(source_file
  (assignment
    (identifier)
    (operator)
    (operator))
  (assignment
    (operator)
    (operator)
    (operator))
  (call_expression
    (identifier)
    (argument_list (operator)))
  (call_expression
  (identifier)
  (argument_list (operator) (operator) (operator))))

