Onecode (Fergusq)

Onecode is a programming language created by User:Fergusq as a part of his Twocode programming language.

Statements
Onecode (one-dimensional code) is used as the one-dimensional part of Twocode. Pure onecode doesn't have any control structures as they must be implemented by the parent language. The "stand-alone" version of Onecode uses GOTO statements.

Grammar
stmt := {";" } expr := logic := {("&"|"|"|"^") } cond := {("="|"<"|">") } add := {("+"|"-") } mul := {("*"|"/") } prim := "*"  ["~" ] | &lt;var> ["~" ] |  prim_t := "(" ")" | "*"  | "!" |  | function_call := "getc" "(" ")" | "getn" "(" ")" | "putc" "(" ")" | "putn" "(" ")" value := | &lt;var> | "'" "'" | | "[" [ {"," }] "]"

Assigments
In addition to a normal expression, rvalue may be a list or a string.

Lists are groups of expressions. They are used to change many memory slots at the same time.

i~2;       // Memory : [0,0,0,0,0,0,0,...] *i~[1,2,3]; // Memory : [0,0,1,2,3,0,0,...]

Strings are similar to list, but contain the null terminator automatically:

s~2; *s~"Hi!";  // Memory: [0,0,'H','i','!',0,0,...]

Statements
The only statement in Onecode is the expression statement. In addition to that the stand-alone version provides following statements:


 * 1) Label statement:
 * 2) Goto statement:
 * 3) If statement:

Sometimes else-keyword is used after the if statement, but it is not required.

Computational class
Computational class depends on the parent language. The stand-alone version and Twocode are Turing complete.

Hello world
s~0; *s~"Hello, world\n"; print: putc(*s); s~s+1; if (*s) goto print;

Truth-machine
i~getc; if (i='1') goto truth; if (i='0') goto lie; goto other; truth: putc(i); goto truth; lie: putc(i); other: