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 دالة/وظيفة.
| Concept | Source-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,
0xprefixes, underscores inside numbers, decimals, ande/Eexponents. - Strings may use single quotes, double quotes, or «…».
- Escapes include
\n,\t,\r,\0, quotes, backslash and$, plus\uwith up to four hex digits and\xwith 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.
خل اسم = "عالم"
اطبع("مرحبا يا ${اسم}")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.
intchecks 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.
دالة جمع(أ: 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.