Solan reference

Solan Syntax, Control Flow, and Expressions

A source-linked reference to Solan’s lexer, parser, and VM: Arabic keyword aliases, optional types, functions, control flow, indexing, and runtime semantics.

Lexicon and tokens

Keywords and aliases

The lexer reads an identifier and then matches reserved words; a keyword can have several Arabic aliases. Confirmed groups include خل/متغير/ليكن/اجعل, ثابت/دائم, and دالة/وظيفة.

ConceptSource-confirmed spellings
Mutable bindingخل, متغير, ليكن, اجعل
Constant bindingثابت, دائم
Functionدالة, وظيفة
Literalsصح, غلط, عدم
Control flowاذا, والا, طالما, لكل, كرر, ارجع, توقف, استمر

These are examples of lexer/opcode keyword groups, not translations of every library API.

Lexicon and tokens

Numbers, strings, and interpolation

  • The lexer accepts ASCII and Arabic-Indic digits, 0x prefixes, underscores inside numbers, decimals, and e/E exponents.
  • Strings may use single quotes, double quotes, or «…».
  • Escapes include \n, \t, \r, \0, quotes, backslash and $, plus \u with up to four hex digits and \x with up to two.
  • ${...} embeds an expression. Concatenating a string with another type does not implicitly convert it; the VM error points to interpolation or نص() as appropriate.
README example (not rerun)
خل اسم = "عالم"
اطبع("مرحبا يا ${اسم}")

Numeric boundaries and conversion behavior are summarized from the inspected source; code samples were not executed in this task.

Expressions and data

Operators and expressions

The source confirms arithmetic + - * / % **, comparisons == != < <= > >=, integer division with a backslash, and bitwise & | ^ << >>. Membership and logical words include في/ضمن and و/أو/ليس.

  • Conditional forms include ?:, ??, and safe access ?..
  • ?? and ?. handle عدم; && and || short-circuit.
  • Operator precedence is intentionally not asserted here; inspect the lexer/parser when exact precedence is required.

Expressions and data

Lists, maps, and types

  • Lists use [] and maps use {}; the source supports ... spreading in lists, maps, and call arguments.
  • Indexing and slices [start:end] are available; the end is exclusive. Negative indexes count from the end for strings/lists when in range.
  • Map property access exists, and طول is supported for strings, lists, and maps.
  • Mutable and constant bindings support type annotations and destructuring; a constant requires an initializer. int checks for an integer within the source-defined limit.
  • The parser supports optional and union types (|) as well as class names.

Methods are receiver-type-specific; a name in the method file does not imply support on every type. See the built-in methods page.

Functions and control flow

Functions, control flow, and exceptions

  • Optional parameters must be trailing; a variadic ... parameter comes last.
  • Functions support return annotations and expression bodies after =>.
  • The parser supports if/else, while, for-in, repeat, switch, try/catch/finally, throw, classes, and inheritance.
  • Imports are restricted to file top level in the inspected compiler files.
Source-derived syntax examples — not executed
دالة جمع(أ: int, ب: int): int => أ + ب

خل أرقام = [1, 2]
اطبع(أرقام[-1])

These examples are synthesized from parser rules and were not run with the Solan interpreter. After installation, verify examples with solan --check before relying on them.

Source files

Direct links pinned to the source snapshot used by this reference; the main branch may change later.