L1VM - Compiler
Ich erweiterte den Brackets Compiler um eine alternative Syntax:
{c + d * e f =}
Das weist der Variablen “f” den Rechenausdruck: “c + d * e” zu. Es wird von links nach rechts gerechnet, ohne Punkt vor Strich Regelung!
Die Berechnung muss in den geschweiften Klammern stehen: “{ }”. Hier ist ein komplettes Beispiel mit alter und neuer Syntax:
// hello-4.l1com - brackets - Hello world! // (main func) (set int64 1 zero 0) (set int64 1 x 23) (set int64 1 y 42) (set int64 1 z 13) (set int64 1 a 0) (set int16 1 c 23) (set int16 1 d 42) (set int16 1 e 13) (set int16 1 f 0) (set string 13 hello "Hello world!") // print string (6 hello 0 0 intr0) (7 0 0 0 intr0) ((x y *) a =) (4 a 0 0 intr0) (7 0 0 0 intr0) {x + y * z * x a =} (4 a 0 0 intr0) (7 0 0 0 intr0) (((x y *)(z x *) *) a =) (4 a 0 0 intr0) (7 0 0 0 intr0) {c + d * e f =} (4 f 0 0 intr0) (7 0 0 0 intr0) (255 zero 0 0 intr0) (funcend)
Die Ausgabe ist:
$ l1vm prog/hello-4 -q Hello world! 966 19435 288834 845