Salam for Visual Studio Code
Language support for the Salam programming language - a beginner-friendly language with first-class English, Persian, and Arabic keywords.
Salam means hello. 👋
Features
- Syntax highlighting for the full language, in all three keyword packs:
- Keywords, control flow, declarations, and storage modifiers (
func / تابع / دالة, if / اگر / إذا, struct / ساختار / بنية, …)
- Primitive types in English, Persian, and Arabic (
i32, f64, str, bool / صحیح۳۲, اعشار۶۴, رشته, منطقی / صحيح٣٢, عشري٦٤, نص, منطقي)
- Built-in I/O (
print / println / _ / __, and چاپ / بنویس / بخوان, and اطبع / اكتب / اقرأ)
- Numbers (decimal, hex
0x, binary 0b, octal 0o, floats, _ digit separators)
- Strings: double-quoted, triple-quoted
"""…""", raw `…`, and char / UTF-8 char literals
- Comments, the
//! file directive, and @en / @fa / @ar / @link localization annotations
- Layout DSL element headers, function/type definitions, calls, and member access
- Editor smarts:
end / پایان-aware auto-indentation, bracket matching, auto-closing pairs, and Persian-aware word selection.
- Snippets for
main, func, if, for, repeat, struct, enum, interface, impl, layout, extern, and more.
- Formatting via
salam fmt (Format Document / format-on-save).
- Run & build the current file with the integrated
salam toolchain.
- Inspect the token stream or decorated AST as XML.
Requirements
The run, build, format, and inspect commands shell out to the salam compiler.
Make sure it is on your PATH, or set salam.compilerPath to its absolute location.
Syntax highlighting and snippets work without the compiler installed.
Commands
Available from the Command Palette and the editor title/context menus:
| Command |
Description |
| Salam: Run File |
Run the current file (salam exec or run, per setting) |
| Salam: Build Executable |
Compile the current file to a native executable |
| Salam: Run with Interpreter |
Run with the tree-walking interpreter (salam exec) |
| Salam: Format Document |
Format the current file with salam fmt |
| Salam: Show Token Stream (XML) |
Open the lexer's token stream |
| Salam: Show AST (XML) |
Open the analyzed AST |
| Salam: New Project… |
Scaffold a new project (salam new) |
Settings
| Setting |
Default |
Description |
salam.compilerPath |
salam |
Path to the salam executable |
salam.languagePack |
auto |
Keyword pack passed as --lang (auto / en / fa / ar) |
salam.run.command |
exec |
exec (interpreter) or run (C backend) for Run File |
salam.build.target |
(empty) |
Optional LLVM target triple for --target cross-compilation (e.g. x86_64-pc-windows-msvc) |
salam.format.enable |
true |
Enable the document formatter |
salam.format.indent |
4 |
Indent for salam fmt: tab or a number of spaces |
salam.stdlibPath |
(empty) |
Optional --stdlib-path root for std/... imports |
With salam.languagePack set to auto, the extension picks fa for
Persian-specific script, ar for other Arabic-script content, and en
otherwise; a lang:/زبان: directive or @fa / @ar annotation overrides the
guess.
Set salam.build.target to cross-compile Build Executable through the LLVM
backend (needs the LLVM toolchain, plus lld for Windows targets); leave it
empty for a host-native C-backend build.
Example
func main:
for mut i = 1; i <= 15; i = i + 1:
if i % 15 == 0: println "FizzBuzz"
else if i % 3 == 0: println "Fizz"
else if i % 5 == 0: println "Buzz"
else: println i
end
end
end
// LANG: fa
تابع اصلی:
چاپ("سلام دنیا")
پایان
License
MIT - see the Salam repository.
| |