|
|
==============================
|
|
|
assignment operators
|
|
|
==============================
|
|
|
|
|
|
a = b
|
|
|
a .. b = a * b
|
|
|
c &= d ÷= e
|
|
|
tup = 1, 2, 3
|
|
|
car, cdr... = list
|
|
|
|
|
|
---
|
|
|
(source_file
|
|
|
(assignment_expression
|
|
|
(identifier)
|
|
|
(operator)
|
|
|
(identifier))
|
|
|
|
|
|
(assignment_expression
|
|
|
(binary_expression (identifier) (operator) (identifier))
|
|
|
(operator)
|
|
|
(binary_expression (identifier) (operator) (identifier)))
|
|
|
|
|
|
(assignment_expression
|
|
|
(identifier)
|
|
|
(operator)
|
|
|
(assignment_expression
|
|
|
(identifier)
|
|
|
(operator)
|
|
|
(identifier)))
|
|
|
|
|
|
(assignment_expression
|
|
|
(identifier)
|
|
|
(operator)
|
|
|
(bare_tuple_expression
|
|
|
(integer_literal)
|
|
|
(integer_literal)
|
|
|
(integer_literal)))
|
|
|
|
|
|
(assignment_expression
|
|
|
(bare_tuple_expression
|
|
|
(identifier)
|
|
|
(spread_expression (identifier)))
|
|
|
(operator)
|
|
|
(identifier)))
|
|
|
|
|
|
|
|
|
==============================
|
|
|
binary operators
|
|
|
==============================
|
|
|
|
|
|
a + b
|
|
|
a ++ 1 × b ⥌ 2 → c
|
|
|
a:(a // b)
|
|
|
|
|
|
x = A \ (v × w)
|
|
|
|
|
|
a & b | c
|
|
|
(x >>> 16, x >>> 8, x) .& 0xff
|
|
|
|
|
|
|
|
|
---
|
|
|
(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))
|
|
|
|
|
|
; range/rational
|
|
|
(range_expression
|
|
|
(identifier)
|
|
|
(parenthesized_expression
|
|
|
(binary_expression
|
|
|
(identifier)
|
|
|
(operator)
|
|
|
(identifier))))
|
|
|
|
|
|
; LA
|
|
|
(assignment_expression
|
|
|
(identifier)
|
|
|
(operator)
|
|
|
(binary_expression
|
|
|
(identifier)
|
|
|
(operator)
|
|
|
(parenthesized_expression
|
|
|
(binary_expression
|
|
|
(identifier)
|
|
|
(operator)
|
|
|
(identifier)))))
|
|
|
|
|
|
; 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)))
|
|
|
|
|
|
|
|
|
==============================
|
|
|
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)))
|
|
|
|
|
|
==============================
|
|
|
pair operator
|
|
|
==============================
|
|
|
|
|
|
Dict(b => c, d => e)
|
|
|
|
|
|
---
|
|
|
(source_file
|
|
|
(call_expression
|
|
|
(identifier)
|
|
|
(argument_list
|
|
|
(pair_expression (identifier) (identifier))
|
|
|
(pair_expression (identifier) (identifier)))))
|
|
|
|
|
|
|
|
|
==============================
|
|
|
unary operators
|
|
|
==============================
|
|
|
|
|
|
+a
|
|
|
-b
|
|
|
√9
|
|
|
[a, b]'
|
|
|
!p === !(p)
|
|
|
1 ++ +2
|
|
|
|
|
|
---
|
|
|
(source_file
|
|
|
(unary_expression (operator) (identifier))
|
|
|
(unary_expression (operator) (identifier))
|
|
|
(unary_expression (operator) (integer_literal))
|
|
|
(unary_expression (array_expression (identifier) (identifier)) (operator))
|
|
|
(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)
|
|
|
(array_expression (identifier))))
|
|
|
|
|
|
|
|
|
==============================
|
|
|
ternary operator
|
|
|
==============================
|
|
|
|
|
|
x = batch_size == 1 ?
|
|
|
rand(10) :
|
|
|
rand(10, batch_size)
|
|
|
|
|
|
---
|
|
|
|
|
|
(source_file
|
|
|
(assignment_expression
|
|
|
(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_expression
|
|
|
(identifier)
|
|
|
(operator)
|
|
|
(operator))
|
|
|
(assignment_expression
|
|
|
(operator)
|
|
|
(operator)
|
|
|
(operator))
|
|
|
(call_expression
|
|
|
(identifier)
|
|
|
(argument_list (operator)))
|
|
|
(call_expression
|
|
|
(identifier)
|
|
|
(argument_list (operator) (operator) (operator))))
|
|
|
|