JavaScript ma comme si deve (JavaScript, the way it should be)
A transpiler that converts Neapolitan code to JavaScript. Written in Rust.
chist Γ¨ nome = "Gennaro"
facc saluta(chi) {
si (chi == nisciun) {
piglie "E chi si tu?"
}
piglie "Uè " + chi + "!"
}
stamm a dì(saluta(nome))
fratmscript/
βββ crates/
β βββ fratm-core/ # Core compiler (lexer, parser, codegen)
β βββ fratm-cli/ # CLI tool
β βββ fratm-wasm/ # WebAssembly bindings
βββ packages/
β βββ vscode-extension/ # Syntax highlighting
β βββ playground/ # Online editor
βββ examples/ # Example programs
βββ docs/ # Documentation
# Clone
git clone https://github.com/kkratterf/fratmscript
cd fratmscript
# Build
cargo build --release
# Run
./target/release/fratm run examples/01_salutatore.fratm
# REPL
./target/release/fratm replfratm run <file.fratm> # Compile and run
fratm build <file.fratm> # Compile to JavaScript
fratm build <file> --sourcemap # With source map
fratm repl # Interactive REPL
fratm tokens <file> # Debug: show tokens
fratm ast <file> # Debug: show ASTchist Γ¨ costante = 42 // const
tien variabile = "ciao" // let
facc somma(a, b) {
piglie a + b
}
mo vir facc caricaDati() { // async
chist Γ¨ dati = aspett fetch(url)
piglie dati
}
si (cond) { } sinnΓ² { } // if/else
mentre che (cond) { } // while
pe (init; cond; upd) { } // for (ogni is optional)
rompe // break
salta // continue
overo / sfΓ²ls // true/false
nisciun // null
boh // undefined
stu cos // this
e / o / no // && / || / !
pure // && (alias for "e")
manco // ! (alias for "no")
! // ! (direct)
na famiglie Persona {
facc costruttore(nome) {
stu cos.nome = nome
}
}
chist Γ¨ p = nu bell Persona("Gennaro")
pruvamm {
// ...
} e si schiatta (err) {
// ...
}
iett nu bell Error("message")
chiamm { x } da "module" // import
mann for facc fn() { } // export
mann for predefinit App // export default
stamm a dì(msg) // console.log
avvis a dì(msg) // console.warn
scrive a dì(msg) // console.error
leva oggetto.prop // delete
fermete // debugger
| FratmScript | JavaScript | Neapolitan |
|---|---|---|
chist Γ¨ |
const |
"this is" |
tien |
let |
"hold" |
facc |
function |
"I do" |
piglie |
return |
"take" |
si |
if |
"if" |
sinnΓ² |
else |
"otherwise" |
mentre che |
while |
"while" |
pe |
for |
"for" |
overo |
true |
"true" |
sfΓ²ls |
false |
"false" |
nisciun |
null |
"nobody" |
boh |
undefined |
"dunno" |
stamm a dì |
console.log |
"we say" |
avvis a dì |
console.warn |
"warn" |
scrive a dì |
console.error |
"write" |
mo vir |
async |
"now see" |
aspett |
await |
"wait" |
pruvamm |
try |
"let's try" |
e si schiatta |
catch |
"if it breaks" |
iett |
throw |
"throw" |
nu bell |
new |
"a nice" |
na famiglie |
class |
"a family" |
stu cos |
this |
"this thing" |
chiamm |
import |
"call" |
da |
from |
"from" |
mann for |
export |
"send out" |
e / pure |
&& |
"and" / "also" |
o |
|| |
"or" |
no / manco / ! |
! |
"no" / "not even" |
leva |
delete |
"remove" |
fermete |
debugger |
"stop" |
# Build all crates
cargo build
# Run tests
cargo test
# Build WASM
cd crates/fratm-wasm
wasm-pack build --target web
# Package VSCode extension
cd packages/vscode-extension
vsce packageThe playground is a web-based editor to try FratmScript in your browser.
# Build WASM module
cd crates/fratm-wasm
wasm-pack build --target web --out-dir ../../packages/playground/pkg
# Serve the playground
cd ../../packages/playground
python3 -m http.server 8080
# Open http://localhost:8080The playground also works in demo mode without WASM using a regex-based transpiler.
Check the examples/ folder for complete programs:
01_salutatore.fratm- Hello World02_variabili_matematica.fratm- Variables and operations03_condizionali.fratm- If/else04_loop.fratm- While and for05_array_oggetti.fratm- Data structures06_funzioni.fratm- Advanced functions07_async.fratm- Async/await08_classi.fratm- OOP09_moduli.fratm- Import/export10_nuove_feature.fratm- New features
- Fork it
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
MIT
Made with Claude and coffee