pd-vm keeps the built-in frontend surface focused on RustScript (.rss). Additional source languages are provided by crates that implement the SourcePlugin trait and pass themselves through CompileSourceFileOptions.
The compatibility JavaScript and Lua frontends live outside this repository in:
pd-vm-compat-frontends
Supported syntax and features:
- Statements:
use,fn,pub fn,let, assignment, indexed/member assignment,if/else,while, C-stylefor,break,continue. - Expressions: literals (
int,float,bool,string,null), arithmetic (+ - * / %), logical (! && ||), comparison (== != < >), function calls, closures (|...| expr), if-expression form (if cond => { ... } else => { ... }), match expressions. - Match patterns: int/string/null literals, wildcard
_,None, non-null binding patternsSome(name), and type constructorsSome(TypeName)/Option::Some(TypeName). - Collections: array literal
[], brace literals for arrays/maps,obj.member,obj[key], optional chaining (?.and?.[key]), slice syntax ([a:b],[:b],[a:]), map key literals includingnull. - Host/runtime calls:
- builtins via namespaces:
io::...,re::...,json::...,jit::...,math::... - host namespaces via
use <namespace>;,use <namespace> as <alias>;, oruse <namespace>::{name as local};
- builtins via namespaces:
- RustScript rewrites:
Option::None->nullOption::Some(expr)->(expr)print("...", ...)andprintln("...", ...)support Rust-stylestd::fmtformatting
- RustScript compile-time type rules:
- unresolved
unknownstates are compile errors on the RustScript path +is inferred as string concatenation when either side is knownstring- known mixed numeric arithmetic widens to
float - incompatible known
if/elseexpression results and branch-local merges are compile errors
- unresolved
A source plugin supplies three things:
parse_source(...) -> FrontendIrparse_imports(...) -> Vec<ModuleImport>strip_imports(...) -> String
Register the plugin on compile options:
use pd_vm::{compile_source_file_with_options, CompileSourceFileOptions};
let options = CompileSourceFileOptions::new()
.with_source_plugin(pd_vm_compat_frontends::plugin());
let compiled = compile_source_file_with_options("examples/example.js", options)?;compile_source_file() without options only handles built-in .rss files. .js and .lua paths need a plugin registered for their SourceFlavor.
- All accepted sources lower into
FrontendIr, then use the same linker, type metadata pass, bytecode backend, debugger metadata, and VM runtime. - Plugin frontends can reuse the shared expression parser through
parse_source_with_dialect(...), or buildFrontendIrdirectly. - Plugins own compatibility-language import parsing and import stripping so core module loading does not encode language-specific import syntax.