Lynxer

Documentation

Operators

Every operator Lynxer has, with the canonical keyword spelling and the deprecated symbolic spellings that still parse.

Symbolic spellings are deprecated: they compile and run, but each use prints

Warning: line N, column M: operator 'X' is deprecated; use 'Y' instead.

Use the keyword forms in new code. A bare ! is not a spelling of anything — it is a syntax error.

Arithmetic and text

OperatorMeaning
+Addition, or str / char concatenation
-Subtraction
*Multiplication
/Division — always returns a float
%Modulo (integers only)
/%Floor division (integers only)
**Exponentiation, right-associative
unary -Negation

// is a line comment, never division. Integer division without a fraction is /%.

Comparison and equality

OperatorMeaningDeprecated spellings
isEqual==
isntNot equal!=, not is
< <= > >=Ordering (numbers, or two strings)—

is / isnt compare any two values, including sentinels and enum variants, which compare by identity. Ordering applies to numbers and to two strings.

Boolean logic

OperatorMeaningDeprecated spellings
andShort-circuit AND&&
orShort-circuit OR||
notUnary NOT!!
nandLogical NAND!&&
norLogical NOR!||
xorLogical XOR—
xnorLogical XNOR—

and / or short-circuit. nand, nor, xor and xnor evaluate both sides.

Bitwise and shifts

These require int64 operands.

OperatorMeaningDeprecated spellings
bitandBitwise AND&
bitorBitwise OR|
bitxorBitwise XOR^
bitnotBitwise NOT~
bitnandBitwise NAND!&
bitnorBitwise NOR!|
bitxnorBitwise XNOR!^
bitleftShift left<<
bitrightShift right>>

Compound assignment

+=, -=, *=, /=, %=, **= and /%= are accepted. The result is validated against the variable's declared type, so int x = 5; x /= 2; is an error rather than a silent truncation.

Precedence

Lowest to highest:

  1. or / nor
  2. xor / xnor
  3. and / nand
  4. not
  5. equality (is / isnt) and ordering (< <= > >=)
  6. bitor
  7. bitxor
  8. bitand
  9. shifts (bitleft / bitright)
  10. + -
  11. * / % /%
  12. ** (right-associative)
  13. unary (not, unary -, bitnot)
  14. postfix and primary

Parenthesise when in doubt: the parser follows this chain exactly.

Deprecated spellings at a glance

DeprecatedUse instead
==is
!=isnt
not isisnt
&&and
||or
!!not
!&&nand
!||nor
&bitand
|bitor
^bitxor
~bitnot
!&bitnand
!|bitnor
!^bitxnor
<<bitleft
>>bitright

See language for the surrounding language and limitations for behaviour that is not implemented at all.