I felt like writing Rust, so I hand-rolled a lexer, parser, and interpreter in Rust (no LLVM shortcuts) for a Turing-complete Arabic programming language.
I then compiled this Rust program into WebAssembly (WASM) so that people could play around with the language and run programs directly in their browser (completely client-side).
You can skip ahead to the playground section if you're eager to see the language in action.
This project was purely for educational and entertainment purposes. An excuse to write more Rust to be frank, and an excuse to experiment with WASM.
Turing-Completeness
One way of proving that a programming language is Turing-complete is to implement a Universal Turing Machine (UTM) simulator in that language.
Because the language has the capabilities of conditional branching, iteration, and variables, writing a UTM simulator is possible. I'll keep this exercise for a subsequent post.
Language Reference
As it stands today, the language is procedural, dynamically-typed, and has a C-style syntax.
Keywords
The language uses Arabic keywords for control flow and declarations.
| Keyword | Description |
|---|---|
ليكن | Declares a new variable |
دالة | Defines a function |
إذا | Starts a conditional if statement |
وإلا | Specifies the else branch |
طالما | Creates a while loop |
أرجع | Returns a value from a function |
صادق | Boolean literal for true |
كاذب | Boolean literal for false |
عدم | Represents the absence of a value (null) |
و | Logical AND operator |
أو | Logical OR operator |
Symbols
| Symbol | Description |
|---|---|
؛ | Statement Terminator (Arabic Semicolon) |
، | Separator (Arabic Comma) |
\ | Division (Backslash, differs from standard /) |
\\ | Line Comments |
( ) | Grouping |
{ } | Scope Blocks |
Standard Library
Currently the language only supports a native function for printing (i.e., طبع).
Playground
You can try the language yourself in the editor below.