Skip to content

Aron-Magg/fratmscript

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

39 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

JavaScript ma comme si deve

FratmScript 🀌🏻

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))

Monorepo Structure

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

Quick Start

# 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 repl

Per una guida completa a esempi, giochi e script: Run Guide.


CLI Commands

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 AST

Complete Syntax

Variables

chist Γ¨ costante = 42        // const
tien variabile = "ciao"      // let

Functions

facc somma(a, b) {
    piglie a + b
}

mo vir facc caricaDati() {   // async
    chist Γ¨ dati = aspett fetch(url)
    piglie dati
}

Control Flow

si (cond) { } sinnΓ² { }       // if/else
mentre che (cond) { }         // while
pe (init; cond; upd) { }      // for (ogni is optional)
rompe                         // break
salta                         // continue

Values

overo / sfΓ²ls                // true/false
nisciun                      // null
boh                          // undefined
stu cos                      // this

Operators

e / o / no                   // && / || / !
pure                         // && (alias for "e")
manco                        // ! (alias for "no")
!                            // ! (direct)

Classes

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"
    }
}

Try/Catch

pruvamm {
    // ...
} e si schiatta (err) {
    // ...
}
iett nu bell Error("message")

Modules

chiamm { x } da "module"     // import
mann for facc fn() { }       // export
mann for predefinit App      // export default

Console Methods

stamm a dì(msg)              // console.log
avvis a dì(msg)              // console.warn
scrive a dì(msg)             // console.error

New Features

leva oggetto.prop            // delete
fermete                      // debugger

Keyword Reference

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"

Development

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 wasm

Playground

The 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:8080

The playground also works in demo mode without WASM using a regex-based transpiler.


Examples

Check the examples/ folder for complete programs:

  1. 01_salutatore.fratm - Hello World
  2. 02_variabili_matematica.fratm - Variables and operations
  3. 03_condizionali.fratm - If/else
  4. 04_loop.fratm - While and for
  5. 05_array_oggetti.fratm - Data structures
  6. 06_funzioni.fratm - Advanced functions
  7. 07_async.fratm - Async/await
  8. 08_classi.fratm - OOP
  9. 09_moduli.fratm - Import/export without external deps
  10. 10_nuove_feature.fratm - New features
  11. 11_oop_avanzato.fratm - Inheritance, super and static methods
  12. 12_trycatch_validazione.fratm - Try/catch and validation

Script Launcher

You can launch extra scripts from one entrypoint:

fratm lancia PersonalScripts/run_personal_scripts.fratm

Contributing

  1. Fork it
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

MIT


Made with Claude and coffee

About

JavaScript ma comme si deve 🀌🏻

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 51.0%
  • TypeScript 40.0%
  • JavaScript 4.3%
  • CSS 2.5%
  • Just 1.3%
  • HTML 0.9%