mighty

The mighty programming language, compiler and tools (WIP)
Log | Files | Refs

commit 5ad660308555fa5341d9a7a64a75b74638010b65
parent 15338ce99edbd81afbf1bab6cc96c12be9314816
Author: citbl <citbl@citbl.org>
Date:   Sun, 24 May 2026 21:09:00 +1000

doco wip

Diffstat:
Amtcl/doco.md | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+), 0 deletions(-)

diff --git a/mtcl/doco.md b/mtcl/doco.md @@ -0,0 +1,54 @@ +# Mighty Language Draft + +```mty +use std + +fx main(int a, int b) int { + print("hello") + ret 0 +} +``` + +## Current Shape + +- `use` imports a library/module name. +- `fx` and `fn` introduce a function. `fx` is exported, `fn` is internal. +- Functions take a name, a parameter list, an optional return type, and a block. +- `ret` is a reserved keyword for returning a value. +- Identifiers are plain alphabetic names with digits allowed after the first character. + +## Draft EBNF + +```ebnf +program = { declaration } ; +declaration = use_decl | function_decl ; +use_decl = "use" ident ; +function_decl = ("fx" | "fn") ident "(" [ param_list ] ")" [ return_type ] block ; +param_list = param { "," param } ; +param = type ident ; +return_type = type ; +block = "{" { statement } "}" ; +statement = return_stmt | expr_stmt ; +return_stmt = "ret" expression ; +expr_stmt = expression ; +expression = ident | literal | call ; +call = ident "(" [ arg_list ] ")" ; +arg_list = expression { "," expression } ; +type = ident ; +literal = int_lit | float_lit | string_lit ; +ident = letter { letter | digit } ; +``` + +## Reserved Keywords + + +`ns`, `in`, `from`, `use`, `ffi`, `drop`, `as`, `of`, `and`, `or`, `ref`, `struct`, `enum`, `pre`, `post`, `inv`, `if`, `else`, `pub`, `fx`, `fn`, `ret` + +## Notes + +- This is a draft, not a frozen spec. +- The parser is still incomplete +- String handling, expression parsing, and statement parsing WIP +- The sample uses a string literal, but string tokenization WIP + +