mowascript
Version:
MowaScript language implementation
110 lines (83 loc) β’ 2.58 kB
Markdown
[[π Interslavic](../../04_compiler.md) Β· [π² East Slavic](../east/04_compiler.md)]
# π οΈ MowaJS Compiler Architecture
The MowaJS compiler (or transpiler) converts code written in clear, Slavic-based syntax into valid JavaScript. It supports multilingual keywords, flexible configuration, syntax transformation, and can be run as a CLI tool or library.
## βοΈ Compiler Workflow
```text
ββββββββββββββ
β Input β (.mowa source code)
β Code β
ββββββ¬ββββββββ
β
βΌ
ββββββββββββββ
β Lexer β (tokenizes input)
ββββββ¬ββββββββ
β
βΌ
ββββββββββββββ
β Parser β (builds AST)
ββββββ¬ββββββββ
β
βΌ
ββββββββββββββββββββββ
β Translator/Transformer β (transforms AST to JS AST)
ββββββ¬ββββββββββββββββ
β
βΌ
ββββββββββββββ
β Generator β (outputs .js file)
ββββββββββββββ
```
The compiler is based on language-specific dictionaries:
- Ukrainian (`ua.js`)
- Belarusian (`by.js`)
- Russian (`ru.js`)
- Interslavic (`isv.js`)
- ... and more
During parsing, it compares words from the code against these dictionaries and automatically maps them to JS keywords or methods.
```json
{
"ΡΠΊΡΠΎ": "if",
"ΠΏΠΎΠΊΠΈ": "while",
"Π΄ΠΎΠ΄Π°ΠΉΠΠΎΠ ΡΠ΄ΠΊΠ°": {
"target": "concat",
"type": "string"
}
}
```
## π² Abstract Syntax Tree (AST)
MowaJS builds an abstract syntax tree while respecting translations:
```js
ΡΠΊΡΠΎ (Π²ΡΠΊ >= 18) {
ΠΊΠ°ΠΆΠΈ("ΠΠΎΡΠΎΡΠ»ΠΈΠΉ");
}
```
Transforms to:
```js
if (Π²ΡΠΊ >= 18) {
console.log("ΠΠΎΡΠΎΡΠ»ΠΈΠΉ");
}
```
## π Transformation Steps
Key stages:
- Aliases β JS keywords: `ΡΡΠ½ΠΊΡΡΡ` β `function`
- Methods β APIs: `govori()` β `console.log()`
- Logic β Symbols: `Ρ` β `&&`, `Π°Π±ΠΎ` β `||`
- Dialect support: handled automatically via dictionary
## π‘ Features
- β
Multi-syntax support
- β
Custom dictionaries
- β
CLI support: `mowa build`, `mowa run`
- β³ Linting + syntax highlighting (planned)
- β³ Web playground (in development)
## π Future Plans
- AST-based linting and autocomplete
- Live in-browser editor
- Integration with editors (VSCode, WebStorm)
- Template preprocessor
- Full TypeScript type support in Mowa