Flaris Language Support for Visual Studio Code
Syntax highlighting, code snippets, analyzer diagnostics and a full debugger
for Flaris (.fls) files - breakpoints, stepping, variable inspection and
fiber-aware call stacks, with no separate debug adapter to install.
Features
Syntax Highlighting
Complete syntax highlighting for all Flaris language features:
- Keywords:
fn, class, async, await, yield, if, for, foreach, iter, while, guard, enum, etc.
- Built-in Modules:
Console, Debug, Math, File, Array, Fiber, VM, and more
- Type annotations: every type the compiler knows -
int, string, fn (any callable), instance, fiber, stream, block and the sized-int aliases - including array element types ([int]), unions (object|nil) and a class name in return position
- Comments: Line (
//) and block (/* */) comments
- Strings & Characters: Double-quoted and triple-quoted (
"""…""") strings, full escape sequence support including \uXXXX
- Numbers: Decimal, hexadecimal (
0xFF), binary (0b101), octal (0o755), floats (including 1e5), and underscore separators (1_000_000)
- Operators: All arithmetic, logical, bitwise, assignment operators, the
^^ power operator, and the ≈ approximate equality operator
Code Snippets
Quick snippets for common patterns (type prefix and press Tab):
| Prefix |
Description |
fn |
Function declaration |
fna |
Async function |
fns |
Static function |
fni |
Inline function |
fnjit |
Typed function (eligible for JIT compilation) |
class |
Class declaration |
classm |
Class with methods |
if, ife |
If / If-else statements |
for, foreach, while, do |
Loop statements (do expands a do-while) |
foreachi |
Foreach with index |
iter |
Iter loop (iter i from 0 to n) |
switch |
Switch statement |
try |
Try-catch block |
log |
Console.WriteLine |
logw |
Console.Write |
assert |
Debug.Assert |
dbgv |
Debug.Value |
guard |
Debug.GuardAddress |
bp |
Breakpoint |
fiber |
Fiber.New |
fresume |
Fiber.Resume |
await |
Await async call |
import |
Import statement |
let, const |
Variable / constant declaration |
arr |
Array literal |
obj |
Object literal |
main |
Main function |
Language Features
- Auto-closing: Brackets, parentheses, quotes
- Comment toggling: Quick line/block comment with
Ctrl+/ (or Cmd+/)
- Bracket matching: Highlight matching brackets
- Code folding: Fold functions, classes, and blocks
- Smart indentation: Auto-indent based on context
- Problem matcher: Inline error and warning squiggles from the analyzer
- Auto tasks.json: When a workspace containing
.fls files is opened for the first time, the extension automatically creates .vscode/tasks.json with run tasks (Ctrl+Shift+B to run the current file)
Code Intelligence
Hover a function, method, class, field, enum or constant to see its
declaration, the comment written above it, and its parameter and return types:
// Persist the cache to disk as JSON. Returns false when the write fails.
fn Save(path: string): bool { ... }
Hovering Save shows that signature, that sentence, path: string, and
Returns bool. Optional parameters (ttl?) are marked as optional, and
hovering an imported name resolves through to the declaration it binds to rather
than stopping at the import line. Any contiguous run of // comments directly
above a declaration is used as its documentation - no special marker is needed.
Go to Definition (F12 / Ctrl+Click) jumps to the declaration of
functions, methods, classes, enums, fields, constants and variables anywhere in
the workspace. It is served from an index built once at startup and kept current
as you type, so it also resolves declarations you have not saved yet.
Analyzer diagnostics run automatically: flarisvm --check analyses a file
when it is opened and each time it is saved, and its warnings and syntax errors
appear as squiggles with the analyzer's warning code attached. Problems reported
inside an imported library are shown against that library's file. Run Flaris:
Analyse Current File from the command palette to check on demand.
| Setting |
Purpose |
flaris.vmPath |
Path to flarisvm for analysis and debugging. Empty prefers a flarisvm in the workspace root, otherwise the one on PATH |
flaris.check.run |
onSave (default) or off |
flaris.check.args |
Extra flags for analysis runs, e.g. ["--libs=./libs"] |
Debugging
Press F5 on a .fls file to debug it - no launch.json needed. Set
breakpoints in the gutter, step with F10/F11, and inspect locals, object
fields and array elements in the Variables pane.
Breakpoints can be added and removed while the program runs, the pause button
interrupts a running program at the next source line, and Open Disassembly
View shows the bytecode around the selected frame.
The VM speaks the Debug Adapter Protocol itself (flarisvm --dap=<port>), over a
loopback socket. Each fiber appears as a thread, so the thread picker lets
you look at any fiber's stack while the program is paused.
A launch.json is only needed to change the defaults:
{
"type": "flaris",
"request": "launch",
"name": "Debug current Flaris file",
"program": "${file}",
"cwd": "${workspaceFolder}",
"vmArgs": ["--libs=./libs"]
}
| Setting |
Purpose |
program |
The .fls file to debug (defaults to the active editor) |
vmPath |
Path to flarisvm. Defaults to a flarisvm in the workspace root if there is one, otherwise the one on PATH |
vmArgs |
Extra VM flags, e.g. ["--libs=./libs"] |
cwd |
Working directory for the VM |
port |
Fixed adapter port; omit to pick one per session |
Notes:
- Debugging disables the JIT. A JIT-compiled function runs natively and never
reports its source lines, so breakpoints inside one could not be reached; the
VM says so on the Debug Console when it starts.
- A file compiled with
--strip carries no line information and cannot be
stopped in.
- Requires a
flarisvm new enough to support --dap; older builds will report
an unknown argument on the Debug Console.
Installation
Open Extensions (Ctrl+Shift+X / Cmd+Shift+X), search for Flaris, and click
Install - or from a terminal:
code --install-extension flaris-lang.flaris
You also need the Flaris VM itself, which the extension runs and debugs:
curl -fsSL https://www.flaris-lang.org/install.sh | sh
See flaris-lang.org for Windows and manual installs.
Examples
Basic Example
// Fibonacci with recursion
fn fib(n) {
if (n <= 1) {
return n;
}
return fib(n - 1) + fib(n - 2);
}
fn Main() {
Console.WriteLine(fib(10));
}
Classes and Inheritance
class Animal {
fn Constructor(name) {
this.name = name;
}
fn speak() {
Console.WriteLine(this.name, "makes a sound.");
}
}
class Dog : Animal {
fn Constructor(name) {
super.Constructor(name);
}
fn speak() {
Console.WriteLine(this.name, "barks.");
}
}
fn Main() {
let d = new Dog("Rex");
d.speak();
}
Async / Await
import { Http } from library("Http", "1.0");
fn async fetchData(url) {
let response = await Http.GetAsync(url);
return Json.Parse(response);
}
Fibers and Concurrency
fn Main() {
let worker = Fiber.New(fn() {
for (let i = 0; i < 5; i++) {
Console.WriteLine("Work", i);
yield i;
}
});
Fiber.Resume(worker);
}
Error Handling
try {
let data = Json.Parse(rawInput);
} catch (e) {
Console.WriteLine("Parse failed:", e.Error, "code:", e.Code);
} finally {
Console.WriteLine("Done.");
}
Approximate Equality
let x = 1.0 / 3.0;
if (x ≈ 0.333333) {
Console.WriteLine("Close enough!");
}
JIT-compiled Functions
Eligible functions are JIT-compiled automatically - no keyword needed. Use typed parameters and return types; only arithmetic, comparisons, loops, array access, and Math.*/Char.* builtins are supported inside JIT-compiled functions - general calls are not. Run flarisvm --check <file> to see which functions can be JIT-compiled and why others cannot.
// Iterative inner loop compiled to native ARM64
fn sum(arr: [int], n: int) : int {
let s: int = 0;
iter (i from 0 to n - 1) {
s = s + arr[i];
}
return s;
}
Keyboard Shortcuts
Ctrl+/ (Mac: Cmd+/) - Toggle line comment
Shift+Alt+A (Mac: Shift+Opt+A) - Toggle block comment
Ctrl+Space - Trigger IntelliSense/snippets
Tab - Expand snippet
F12 / Ctrl+Click - Go to Definition
Language Reference
Keywords
Control Flow: if, else, while, do, for, foreach, iter, from, to, in, is
switch, case, default, break, continue, return, guard
Functions: fn, async, yield, await, inline, static
Variables: let, var, const, global
OOP: class, new, this, super, enum
Modules: import, export, as, library
Error Handling: try, catch, finally, throw
Constants: nil, true, false
Word Operators: and, or
Debug: breakpoint
Built-in Modules
Array Buffer Char Class Collections Console
Convert Crypto Debug Directory Event Ffi
Fiber File FileWatch Hash Json Math
Memory Net Object Os Path Random
Regex Scheduler Stream String Time Timers
Type Util VM
Operators
Arithmetic: + - * / % ^^ ++ --
Assignment: = += -= *= /= %= ^^= <<= >>= &= |= ^= ??=
Comparison: == != < > <= >= ≈
Logical: && || ! and or
Bitwise: & | ^ ~ << >>
Other: ?? =>
Issues & Feedback
Bug reports and feature requests are welcome on the
Flaris Discord, or via the contact address at
flaris-lang.org.
For a bug, please include the Flaris version (flarisvm --version), your OS, and
a minimal .fls script that reproduces it.
License
MIT