💾 Archived View for thingvellir.net › bearing.gmi captured on 2023-04-19 at 22:31:48. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
This is super unfinished and as-of-yet unimplemented.
use std_io; fn main() { fwrite(stdout, "Hello, world!"); }
fn fib_recur(n: i32) -> i32 { if n <= 1 { return 1; } else { return fib_recursive(n - 1) + fib_recursive(n - 2); } } fn fib_iter(n: i32) -> i32 { var accum: i32 = 0; var last: i32 = 0; var i: usize = 0; while i < n { var tmp = accum; accum = last; last = tmp + last; } return accum; } fn main() { use std_io; use std_str; let args: [u8;32;2] = 0; strlen_i32(fib_recur(5), &args[0]); strlen_i32(fib_iter(5), &args[1]); }
# Minimum required, implementations may allow more characters Identifier <- [a-zA-Z_] [0-9a-zA-Z_]* # These ASCII definitions are only informative NewLine <- ('\0D' '\0A') / '\0A' Whitespace <- '\09' / '\0C' / '\0D' / '\20' BlockComment <- '/*' (!'*/' .)* '*/' LineComment <- '//' (!NewLine .)* Ignore <- BlockComment / LineComment / NewLine / Whitespace
BinDigit <- [0-1] HexDigit <- [0-9a-fA-F] DecDigit <- [0-9] BinLiteral <- '0b' BinDigit+ ('_' BinDigit+)* HexLiteral <- '0x' HexDigit+ ('_' HexDigit+)* DecLiteral <- DecDigit+ ('_' DecDigit+)* IntegerLiteral <- BinLiteral / HexLiteral / DecLiteral StringEscape <- '\n' / ([\] HexDigit HexDigit) StringLiteral <- ["] (StringEscape / [^"])* ["] UnitLiteral <- '()' Literal <- IntegerLiteral / StringLiteral / UnitLiteral
UnsignedType <- 'u8' / 'u16' / 'u32' / 'u64' / 'uptr' / 'usize' SignedType <- 'i8' / 'i16' / 'i32' / 'i64' / 'iptr' / 'isize' UnitType <- '()' FieldBinding <- Identifier ':' Type ('=' Literal)? FieldList <- '(' FieldBinding (',' FieldBinding)* ','? ')' StructType <- 'struct' FieldList ArrayType <- '[' Type (';' IntegerLiteral)+ ']' # See the 'Functions' section below for the definition of ParameterList FunctionType <- 'fn' ParameterList ('->' Type)? PointerType <- '&' Type Type <- UnsignedType / SignedType / UnitType / StructType / ArrayType / PointerType / Identifier TypeBinding <- 'type' Identifier '=' Type ';'
ParamBinding <- Identifier ':' Type ('=' Literal)? ParamList <- '()' / '(' ParamBinding (',' ParamBinding)* ','? ')' FuncSignature <- 'fn' Identifier ParameterList ('->' Type)? FuncPrototype <- FunctionSignature ';' FuncDefinition <- FunctionSignature '{' '}'