A toy language for the purporse of experimenting with sea-of-nodes compiler arch
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: start describing the language

+41 -3
+1
Cargo.toml
··· 1 1 #schema="https://www.schemastore.org/cargo.json 2 2 [workspace] 3 3 members = ["./megatonc"] 4 + resolver = "3" 4 5 default-members = ["megatonc"] 5 6 6 7 [workspace.package]
+10
DESIGN.md
··· 1 + # Megaton - a language to blow minds 2 + with how boring it is. 3 + 4 + ## Ideas 5 + 6 + ### Uniformity 7 + 8 + * Polymorphism expressed as functions from types to types 9 + * Comptime code generation instead of derives 10 +
+1 -1
examples/fib_iterative.mt
··· 3 3 } 4 4 5 5 fn fib(n: i32) { 6 - let a = 6 + let a = n? <2 : 7 7 }
+29 -2
megatonc/src/main.rs
··· 1 - fn main() { 2 - println!("Hello, world!"); 1 + use std::fs::read_to_string; 2 + 3 + enum Operation { 4 + Compile { file: String }, 5 + Exit, 6 + } 7 + 8 + fn args() -> Operation { 9 + let mut args = std::env::args().skip(1); 10 + if let Some(file) = args.next() { 11 + Operation::Compile { file } 12 + } else { 13 + Operation::Exit 14 + } 15 + } 16 + fn main() -> std::io::Result<()> { 17 + match args() { 18 + Operation::Compile { file } => { 19 + println!("Compiling {file:?}"); 20 + compile(&file) 21 + } 22 + Operation::Exit => Ok(()), 23 + } 24 + } 25 + 26 + fn compile(file: &str) -> std::io::Result<()> { 27 + let src = read_to_string(file)?; 28 + 29 + Ok(()) 3 30 }