Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tools/exp445/arms/omegese.md # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tools / exp445 / arms / omegese.md` 100 lines ยท 5381 bytes Raw Blame History Source REPRESENTATION: omegese Write the program in Omegese: one statement per line, words separated by single spaces. No commas, no semicolons, no indentation, no comments. A checker reads it line by line and refuses the first invalid line with a reason; a valid program becomes the program. Types (Omegese name = type): bool = bool, uchar = u8, ushort = u16, uint = u32, ulong = u64, byte = i8, short = i16, int = i32, long = i64. The names u8 .. i64 are accepted too. Statements: ``` fn ... to (or: to void); end closes the function = write a value: a new name, or an existing name of the same type if ... else ... end (else is optional) while bound ... end N in 1..1000000; more than N iterations is trap 4 for ... end i = 0, 1, ..., count-1 (count is a number or a value) break leave the innermost while or for ret (ret alone in a void function) put free trap code 1..14; like ret, it ends the path call a void function ``` Values (each op takes a fixed number of values; each value may itself be an op): ``` or add sub mul div rem and or xor shl shr eq ne lt le gt ge (gives bool) neg (signed) not (bool: logical; number: bitwise) a typed number, e.g. uint 0 convert, e.g. ulong x (trap 5 if the value does not fit) get new only as a whole line: = new ... own edit view call a function written earlier in the program ``` Values nest in prefix order: `add mul a a 1` is (a*a)+1, `eq rem n 2 0` is n%2 == 0. Brackets are optional and change nothing: `add (mul a a) 1`. A ( must hold exactly one value. Rules: - Types are inferred: a new name takes the type of its value. A plain number takes the type of the other value of its op (`add x 1`); where there is none, write the type (`s = uint 0`). Both values of an op have one type; convert explicitly. Two plain numbers in one op are refused. - A condition is any value giving bool (`while ne b 0 bound 64`, `if or lt p 0 gt p 9`). - A name first written inside if/else/while/for exists only until that block's end. To use a value after the block, write it before the block, then overwrite it inside. - Every name you write must be read later. Parameters may be overwritten. A for counter may not. - Every path through a function that returns a value must end in ret or trap. - Parameters of array type: own|edit|view , e.g. `v view uint 4`. Word card: every fixed word and what it does. ``` fn start a function: fn ... to to in a fn line: the return type follows void in a fn line: the function returns nothing (to void) end close the innermost fn, if, else, while or for if if : run the lines up to else or end when cond is true else the lines run when the if condition is false while while bound : repeat while cond is true bound in a while line: the most passes allowed; one more is trap 4 for for : run with i = 0, 1, ..., count-1 break leave the innermost while or for ret return a value (ret alone in a void function) trap trap : stop the run with that trap code put put : store into an array free free : release an array made with new true the bool value true false the bool value false add add : a + b sub sub : a - b mul mul : a * b div div : a / b, truncated toward zero rem rem : remainder of a / b, sign of a and and : bitwise and; on bools, logical and or or : bitwise or; on bools, logical or xor xor : bitwise exclusive or shl shl : a shifted left by b bits shr shr : a shifted right by b bits eq eq : a == b (bool) ne ne : a != b (bool) lt lt : a < b (bool) le le : a <= b (bool) gt gt : a > b (bool) ge ge : a >= b (bool) neg neg : -a (signed) not not : logical not of a bool, bitwise not of a number get get : read an element new = new : a new array of len elements, all init bool type bool; bool converts or types a value uchar type u8 (unsigned 8-bit); uchar converts or types a value ushort type u16 (unsigned 16-bit) uint type u32 (unsigned 32-bit) ulong type u64 (unsigned 64-bit) byte type i8 (signed 8-bit) short type i16 (signed 16-bit) int type i32 (signed 32-bit) long type i64 (signed 64-bit) own own : move the array (a parameter: own ) edit edit : lend the array for writing (a parameter: edit ) view view : lend the array for reading (a parameter: view ) ```