Bee Syntax

Bee is not a curly bracket language. Its syntax is inspired from Ada, Ruby, Fortran and Julia. We have created an imperative programming language with original front-end.

Operators

Bee operators are ASCII or Unicode symbols. One operator can be created using one or two characters. This is why Bee language is considered experimental, esoteric & disruptive.

Delimiters

Symbol Description
+-...-+ Multi-line boxed comments
#(....) String interpolation (placeholder) for operator "?"
(_,_,_) Expression | List literal
[_,_,_] Index | Array literals | Parameterize types
{_,_,_} Enumeration type | Set of values | Hash map

Strings

symbol description
`x` Back quoted string: regular expression.
'x' Single quoted string literal or ASCII code point
"y" Double quoted string literal or UTF32 code point

Single Symbols

symbol description
! Logical NOT (unary prefix) — Decision 12. Prefix-negates any relation operator: x !∈ y ≡ !(x ∈ y)
? Template modifier. Associated with string templates
* String replication | Varargs prefix | Spread operator | Many something
@ Reference-of operator: @a yields the reference identity of a; use @a = @b to check whether a is b (same allocation)
$ System sigil | Dynamic end anchor: index of the last element in a collection (1-based, Decision 1)
& String concatenation | number concatenation
# Title | String interpolation
∈ Define variable/constant/result/parameter type
_ Anonymous variable | Constant value = one space (_ = ' ')
+ Maximum upper limit for a domain | Unicode notation U+
- Minimum lower limit in a domain | Unicode notation U-
: Start a block or define something
: Pair-up key-value in: objects, rule parameters, rule arguments, hash-map pairs
; End of statement | Statement separator
. Decimals for real numbers | Path string concatenation
. Membership dot notation | Prefix for public member/attribute
, Enumeration of elements | expressions
| Declarative collection builder: set := { x*2 | x ∈ (0..3)}
\ Escape character ( \n := New Line), ( \" = Double Quotes)

Numeric operators

Listed in the order of precedence top down.

symbol description
- Change sign, replace "y = -x" with "y = -1*x"
/ Rational number division
^ Power symbol used with fractions or expressions
²   ³   ⁿ Superscript power exponents: right-associative, bind tighter than radicals (D10)
√   ²√   ³√   ⁿ√ Radical (prefix, D10): ²√n is equivalent to n^(1/2), ³√n to n^(1/3). Power inside the operand resolves first, so ³√ 2³ = 2
* Multiplication alternative
\ Rational number division
/ Real number division
× Array multiplication | Matrix multiplication
% Modulo operator 5 % 2 = 2
+ Numeric addition | List append | Matrix addition
- Numeric subtraction | Collection difference
± Numeric tolerance (use with ≈)

Double Symbols

Double symbols is a group of two ASCII symbols considered as one. Some of these symbols have an Unicode equivalent, some do not. When available, Unicode equivalent is preferred choice.

symbol description
-- Single line, end of line comments
.. Range/domain/slice, both limits inclusive (n..m) | [n, m]
..< Range with excluded upper limit (n..<m) — left-inclusive, right-exclusive | [n, m)
>.. Range with excluded lower limit (n>..m) — left-exclusive, right-inclusive | (n, m]
>..< Range with both limits excluded (n>..<m) — fully exclusive | (n, m)
-. Minus infinite domain: instead of [-∞..0] write: [-..0]
.+ Plus infinite domain: instead of [0..+∞] write: [0..+]
=> Define: rule expression | rule result
<- Define and generate values in a loop from range or set
<: Define subset from set | Specify super-type for a new type
:> Data cast pipeline operator / Type conversion
<< Shift values of collection to right by removing first elements
>> Shift values of collection to left by removing first elements
:: Deep copy | Clone operator
++ Extend an array with one or more elements
-= Find and delete one element, from a collection
+= Append an element in a set or a map but not in a list
+> Append element to beginning of a list
<+ Append element to end of a list
~= Relation operator: regular expression match
>= Relation operator: greater then or equal to
<= Relation operator: less then or equal to

Modifiers

Each modifier is created with pattern "x=" where x is a single symbol:

symbol meaning
:= Modify | (value | reference)
+= Increment value
-= Decrement value
*= Multiplication modifier
/= Real division modifier
^= Power modifier
√= Radical modifier
%= Modulo modifier

Relation Operators

Relation operators are used to compare expressions.

symbol meaning
∈ check if element belong to collection
= equal { compare values or attributes}
¬ different { compare values or attributes}
≡ geometric congruence (same shape, any scale) — see Graphics
≈ approximating equal numbers, used with ± like: (x ≈ 4 ± 0.25)
> value is greater than: (2 > 1)
< value is less than: (1 < 2)
≥ greater than or equal to
≤ less than or equal to
÷ Exact divisor: 3 ÷ 15 = True

negation:

Operator: "!" can be used in combination with other operators:

 x ¬ y; -- equivalent to: !(x = y)
 x !∈ y; -- equivalent to: !(x ∈ y)
 x !≈ y; -- equivalent to: !(x ≈ y)
 x !~ y; -- equivalent to: !(x ~ y)

identity vs equality:

Operator "=" compares values. To compare references, use the reference-of operator "@" on both sides. A reference is never equal to a plain value.

 a = b;    -- value comparison: true when a and b hold the same value
 a ¬ b;    -- value inequality: true when a and b hold different values
 a is b;   -- pointer identity: true when a and b name the same allocation (same as @a = @b)
 @a = @b;  -- reference comparison: true only when a and b share one allocation
 @a ¬ @b;  -- reference inequality: true when a and b are distinct allocations
 @a = 1;   -- always false: @a is a reference, 1 is a constant value

Deprecated operator forms

Legacy spellings still lex but emit a non-fatal E0010 DeprecatedSymbol warning and map to their canonical equivalents (Decisions 12 & 13):

DeprecatedCanonicalMeaning
≠ <> !=¬value inequality (D12)
===value equality (D12)
.!..<range — exclude upper endpoint (D13)
!.>..range — exclude lower endpoint (D13)
!!>..<range — fully exclusive (D13)
(min..max : step)(min..max)(step)postfix step (D13)

Collection operators

symbol result meaning
∩ Set Intersection between two collections
∪ Set Union between two collections
⊂ Logic Set is included in superset: "⊂"
⊃ Logic Set contain subset: "⊃"
Δ Set Set symmetric difference
+ String Concatenation between two strings
+ List Concatenation between two lists
+ Array Concatenation between two arrays
∀ Element All: used in collection qualification
∃ Logic One: used in collection qualification

Logic Operators

Bee is using enumeration symbols: True = 1 and False = 0

symbol meaning notes
! NOT unary operator
∧ AND shortcut operator
∨ OR shortcut operator
⊕ XOR exclusive OR
↓ NOR p ↓ q = ¬ (p ∨ q)
↑ NAND p ↑ q = ¬ (p ∧ q)

The table of truth

p q ! p p ⊕ q p ∧ q p ∨ q
1 1 0 0 1 1
1 0 0 1 0 1
0 1 1 1 0 1
0 0 1 0 0 0

Bitwise operators

Bitwise operators are processing numbers not Boolean values.

symbol meaning notes
« bit SHIFTL shift bits to left
» bit SHIFTR shift bits to right
~ bit NOT negate all bits
& bit AND execute AND between each bits
| bit OR execute OR between each bits
⊕ bit XOR execute XOR between each bits

Arity = 1

a ~ a a « 1 a » 2
0000111100000000
1111000011100011
0111100011100001
0110100111000001

Arity = 2

aba & ba | ba ⊕ b
0000000000
0100000101
1101011110
1011101101

String operators

SymbolDescription
*string pattern repetition (right operator must be numeric)
/concatenate url or path using / not depending on OS
+concatenate two strings as they are preserving trial spaces.
-concatenate two strings and trim spaces to a single space.
.concatenate strings with "/" on Linux or "\" on Windows.
?string format operator, replace "#" with number.

Diagnostic error codes

Diagnostic codes raised by the operators module (spec/01 §6):

CodeViolationMitigation / diagnostic action
E0101UTF8BomMarker: Unexpected UTF-8 BOM marker at source start.Strip the BOM from the source header.
E0102UnterminatedBlockComment: Block comment (+-) without a closing -+.Ensure closing -+ exists.
E0103InvalidEscapeSequence: Invalid escape sequence in a string literal.Use valid \n, \t, \uXXXX escapes.
E0104SingleLetterUppercaseIdentifier: Single-letter uppercase variable identifier.Use a lowercase start or a multi-letter type identifier.
E0105UnterminatedStringOrMarkup: Unterminated string literal or markup block.Check closing quotes or the matching markup tag.
E0010DeprecatedSymbol/DeprecatedKeyword: Legacy form encountered: repeat (use next, D15); ≠/==/!=/<> (use ¬/=/¬, D12); .!/!./!! range glyphs (use ..</>../>..<, D13).Replace with the canonical form; non-fatal until Phase 7.2 hardens to E0009.
E0011DeprecatedSymbol 'using': Legacy using/using: postfix on io_stmt or rule call (D6).Use curried named-argument call form (sep: ...); non-fatal until hardened to E0009.