Salam for Visual Studio Code
Language support for the Salam programming language - a beginner-friendly language with first-class English and Persian keywords.
Salam means hello. 👋
Features
- Syntax highlighting for the full language, in both keyword packs:
- Keywords, control flow, declarations, and storage modifiers (
func / تابع, if / اگر, struct / ساختار, …)
- Primitive types in English and Persian (
i32, f64, str, bool / صحیح۳۲, اعشاری۶۴, رشته, منطقی)
- Built-in I/O (
print / println / _ / __, 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 / @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
salamc fmt (Format Document / format-on-save).
- Run & build the current file with the integrated
salamc toolchain.
- Inspect the token stream or decorated AST as XML.
Requirements
The run, build, format, and inspect commands shell out to the salamc 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 (salamc 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 (salamc exec) |
| Salam: Format Document |
Format the current file with salamc 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 (salamc new) |
Settings
| Setting |
Default |
Description |
salam.compilerPath |
salamc |
Path to the salamc executable |
salam.languagePack |
auto |
Keyword pack passed as --lang (auto / en / fa) |
salam.run.command |
exec |
exec (interpreter) or run (C backend) for Run File |
salam.format.enable |
true |
Enable the document formatter |
salam.format.indent |
4 |
Indent for salamc 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 when a file
contains a LANG: fa / @fa directive or enough Persian-script content, and
en otherwise.
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.
| |