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
βββ Games/ # Games written in FratmScript
βββ PersonalScripts/ # Utility scripts + launcher
# Clone
git clone https://github.com/kkratterf/fratmscript
cd fratmscript
# Build
cargo build --release
# Launch
./target/release/fratm lancia examples/01_salutatore.fratm
# REPL
./target/release/fratm replPer una guida completa a esempi, giochi e script: Run Guide.
fratm lancia <file.fratm> # Compile and launch
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 {
costruttore(nome) {
stu cos.nome = nome
}
}
na famiglie Pizzaiolo figlio 'e Persona {
costruttore(nome) {
'o pate(nome)
}
fisso specie() {
piglie "Essere umano"
}
}
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" |
figlio 'e |
extends |
"child of" |
'o pate |
super |
"the father" |
fisso |
static |
"fixed/static" |
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" |
Install just (Linux/macOS/Windows) and official guide:
# Recommended task runner
just --list
# Build and test
just build
just test
# Build/launch all examples
just examples-build
just examples-lancia
# Build release CLI
just release
# Build WASM for playground
just wasmThe 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/public/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/export without external deps10_nuove_feature.fratm- New features11_oop_avanzato.fratm- Inheritance, super and static methods12_trycatch_validazione.fratm- Try/catch and validation
You can launch extra scripts from one entrypoint:
fratm lancia PersonalScripts/run_personal_scripts.fratm- Fork it
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
MIT
Made with Claude and coffee