hello-world.nils.nv
· 4.5 KiB · Text
Raw
Playground
|:: documentation for NILS Form|
:@doc string:
"Nova In-Language Static Form is a possible structure for lowering
Nova code into a bytecode language describable in Nova. This is not
intended to be written by hand."
|:: match $stack $arity :failed:?|
|:: match @stdio.arity $arity :@stdio.arity: $arity| :@stdio.arity (r): $arity
|:: match @stdio.1 $1 :@stdio.1: $1| :@stdio.1 (r): $1
|:: match @stdio.2 $2 :@stdio.2: $2| :@stdio.2 (r): $2
|:: match .arity $arity :.arity: $arity| :.arity (r): $arity
|:: match .1 $1 :.1: $1| :.1 (r): $1
|:: match .2 $2 :.2: $2| :.2 (r): $2
|:: match message.arity $arity :message.arity: $arity| :message.arity (r): $arity
|:: match message.1 $1 :message.1: $1| :message.1 (r): $1
|:: match $stack $arity| :failed:
|:: bind $stack $symbol :failed:?|
|:: bind @stdio.2 1 :@stdio.2: $2| :@stdio.2 (r): $2 :1: $2
|:: bind message.1 1 :message.1: $1| :message.1 (r): $1 :1: $1
|:: bind $stack $symbol| :failed:
|:: consume @stdio.arity :@stdio.arity (r): $symbol :failed:?| :@stdio.arity: $symbol
|:: consume @stdio.1 :@stdio.1 (r): $symbol :failed:?| :@stdio.1: $symbol
|:: consume @stdio.2 :@stdio.2 (r): $symbol :failed:?| :@stdio.2: $symbol
|:: consume .arity :.arity (r): $symbol :failed:?| :.arity: $symbol
|:: consume .1 :.1 (r): $symbol :failed:?| :.1: $symbol
|:: consume .2 :.2 (r): $symbol :failed:?| :.2: $symbol
|:: consume message.arity :message.arity (r): $symbol :failed:?| :message.arity: $symbol
|:: consume message.1 :message.1 (r): $symbol :failed:?| :message.1: $symbol
|:: consume $stack :failed:?|
|:: consume @stdio.arity :@stdio.arity (r): $symbol|
|:: consume @stdio.1 :@stdio.1 (r): $symbol|
|:: consume @stdio.2 :@stdio.2 (r): $symbol|
|:: consume .arity :.arity (r): $symbol|
|:: consume .1 :.1 (r): $symbol|
|:: consume .2 :.2 (r): $symbol|
|:: consume message.arity :message.arity (r): $symbol|
|:: consume message.1 :message.1 (r): $symbol|
|:: jet @stdio write/1 :failed:?|
|:: jet @stdio write/1|
:@jet: "io.write(string.char(tonumber(stacks["1"][1][1])))"
|:: push $stack $symbol :failed:?|
|:: push @stdio.arity $arity| :@stdio.arity: $arity
|:: push @stdio.1 $symbol| :@stdio.1: $symbol
|:: push @stdio.2 $symbol| :@stdio.2: $symbol
|:: push .arity $arity| :.arity: $arity
|:: push .1 $symbol| :.1: $symbol
|:: push .2 $symbol| :.2: $symbol
|:: push message.arity $arity| :message.arity: $arity
|:: push message.1 $symbol| :message.1: $symbol
|:: pushvar $stack $reg :failed:?|
|:: pushvar @stdio.2 1 :1: $1?| :@stdio.2: $1
|:: unbind 1 :1: $1|
|:: unbind $reg|
|:: rule 1 succeeded :failed:| :: rule 2
|:: rule 2 succeeded :failed:| :: rule 3
|:: rule 3 succeeded :failed:| :: rule 4
|:: rule $x succeeded :failed:?|
|:: rule $x succeeded| :: rule 1
|:/:| :: print message :message: "Hello, World!"
|:: rule 0|
:: push .arity 2 :: push .1 print :: push .2 message
:: push message.arity 1 :: push message.1 33
:: push message.arity 1 :: push message.1 100
:: push message.arity 1 :: push message.1 108
:: push message.arity 1 :: push message.1 114
:: push message.arity 1 :: push message.1 111
:: push message.arity 1 :: push message.1 87
:: push message.arity 1 :: push message.1 32
:: push message.arity 1 :: push message.1 44
:: push message.arity 1 :: push message.1 111
:: push message.arity 1 :: push message.1 108
:: push message.arity 1 :: push message.1 108
:: push message.arity 1 :: push message.1 101
:: push message.arity 1 :: push message.1 72
:: rule 0 succeeded
|:@stdio: write $char|
:@jet: "io.write(string.char(tonumber($char)))"
|:: rule 1|
:: match @stdio.arity 2 :: match @stdio.1 write :: bind @stdio.2 1
:: consume @stdio.arity
:: consume @stdio.1
:: consume @stdio.2
:: jet @stdio write/1
:: unbind 1
:: rule 1 succeeded
|:: print message? :message: $char|
:@stdio: write $char
|:: rule 2|
:: match .arity 2 :: match .1 print :: match .2 message
:: match message.arity 1 :: bind message.1 1
:: consume .arity :: consume .1 :: consume .2
:: consume message.arity :: consume message.1
:: push @stdio.arity 2 :: push @stdio.1 write :: pushvar @stdio.2 1
:: push .arity 2 :: push .1 print :: push .2 message
:: unbind 1
:: rule 2 succeeded
|:: print message|
:@stdio: write 10
|:: rule 3|
:: match .arity 2 :: match .1 print :: match .2 message
:: consume .arity :: consume .1 :: consume .2
:: push @stdio.arity 2 :: push @stdio.1 write :: push @stdio.2 10
:: unbind 1
:: rule 3 succeeded
|| :: rule 0
| 1 | |:: documentation for NILS Form| |
| 2 | :@doc string: |
| 3 | "Nova In-Language Static Form is a possible structure for lowering |
| 4 | Nova code into a bytecode language describable in Nova. This is not |
| 5 | intended to be written by hand." |
| 6 | |
| 7 | |:: match $stack $arity :failed:?| |
| 8 | |:: match @stdio.arity $arity :@stdio.arity: $arity| :@stdio.arity (r): $arity |
| 9 | |:: match @stdio.1 $1 :@stdio.1: $1| :@stdio.1 (r): $1 |
| 10 | |:: match @stdio.2 $2 :@stdio.2: $2| :@stdio.2 (r): $2 |
| 11 | |:: match .arity $arity :.arity: $arity| :.arity (r): $arity |
| 12 | |:: match .1 $1 :.1: $1| :.1 (r): $1 |
| 13 | |:: match .2 $2 :.2: $2| :.2 (r): $2 |
| 14 | |:: match message.arity $arity :message.arity: $arity| :message.arity (r): $arity |
| 15 | |:: match message.1 $1 :message.1: $1| :message.1 (r): $1 |
| 16 | |:: match $stack $arity| :failed: |
| 17 | |
| 18 | |:: bind $stack $symbol :failed:?| |
| 19 | |:: bind @stdio.2 1 :@stdio.2: $2| :@stdio.2 (r): $2 :1: $2 |
| 20 | |:: bind message.1 1 :message.1: $1| :message.1 (r): $1 :1: $1 |
| 21 | |:: bind $stack $symbol| :failed: |
| 22 | |
| 23 | |:: consume @stdio.arity :@stdio.arity (r): $symbol :failed:?| :@stdio.arity: $symbol |
| 24 | |:: consume @stdio.1 :@stdio.1 (r): $symbol :failed:?| :@stdio.1: $symbol |
| 25 | |:: consume @stdio.2 :@stdio.2 (r): $symbol :failed:?| :@stdio.2: $symbol |
| 26 | |:: consume .arity :.arity (r): $symbol :failed:?| :.arity: $symbol |
| 27 | |:: consume .1 :.1 (r): $symbol :failed:?| :.1: $symbol |
| 28 | |:: consume .2 :.2 (r): $symbol :failed:?| :.2: $symbol |
| 29 | |:: consume message.arity :message.arity (r): $symbol :failed:?| :message.arity: $symbol |
| 30 | |:: consume message.1 :message.1 (r): $symbol :failed:?| :message.1: $symbol |
| 31 | |:: consume $stack :failed:?| |
| 32 | |
| 33 | |:: consume @stdio.arity :@stdio.arity (r): $symbol| |
| 34 | |:: consume @stdio.1 :@stdio.1 (r): $symbol| |
| 35 | |:: consume @stdio.2 :@stdio.2 (r): $symbol| |
| 36 | |:: consume .arity :.arity (r): $symbol| |
| 37 | |:: consume .1 :.1 (r): $symbol| |
| 38 | |:: consume .2 :.2 (r): $symbol| |
| 39 | |:: consume message.arity :message.arity (r): $symbol| |
| 40 | |:: consume message.1 :message.1 (r): $symbol| |
| 41 | |
| 42 | |
| 43 | |:: jet @stdio write/1 :failed:?| |
| 44 | |:: jet @stdio write/1| |
| 45 | :@jet: "io.write(string.char(tonumber(stacks["1"][1][1])))" |
| 46 | |
| 47 | |:: push $stack $symbol :failed:?| |
| 48 | |:: push @stdio.arity $arity| :@stdio.arity: $arity |
| 49 | |:: push @stdio.1 $symbol| :@stdio.1: $symbol |
| 50 | |:: push @stdio.2 $symbol| :@stdio.2: $symbol |
| 51 | |:: push .arity $arity| :.arity: $arity |
| 52 | |:: push .1 $symbol| :.1: $symbol |
| 53 | |:: push .2 $symbol| :.2: $symbol |
| 54 | |:: push message.arity $arity| :message.arity: $arity |
| 55 | |:: push message.1 $symbol| :message.1: $symbol |
| 56 | |
| 57 | |:: pushvar $stack $reg :failed:?| |
| 58 | |:: pushvar @stdio.2 1 :1: $1?| :@stdio.2: $1 |
| 59 | |
| 60 | |
| 61 | |:: unbind 1 :1: $1| |
| 62 | |:: unbind $reg| |
| 63 | |
| 64 | |
| 65 | |:: rule 1 succeeded :failed:| :: rule 2 |
| 66 | |:: rule 2 succeeded :failed:| :: rule 3 |
| 67 | |:: rule 3 succeeded :failed:| :: rule 4 |
| 68 | |:: rule $x succeeded :failed:?| |
| 69 | |:: rule $x succeeded| :: rule 1 |
| 70 | |
| 71 | |
| 72 | |:/:| :: print message :message: "Hello, World!" |
| 73 | |:: rule 0| |
| 74 | :: push .arity 2 :: push .1 print :: push .2 message |
| 75 | :: push message.arity 1 :: push message.1 33 |
| 76 | :: push message.arity 1 :: push message.1 100 |
| 77 | :: push message.arity 1 :: push message.1 108 |
| 78 | :: push message.arity 1 :: push message.1 114 |
| 79 | :: push message.arity 1 :: push message.1 111 |
| 80 | :: push message.arity 1 :: push message.1 87 |
| 81 | :: push message.arity 1 :: push message.1 32 |
| 82 | :: push message.arity 1 :: push message.1 44 |
| 83 | :: push message.arity 1 :: push message.1 111 |
| 84 | :: push message.arity 1 :: push message.1 108 |
| 85 | :: push message.arity 1 :: push message.1 108 |
| 86 | :: push message.arity 1 :: push message.1 101 |
| 87 | :: push message.arity 1 :: push message.1 72 |
| 88 | :: rule 0 succeeded |
| 89 | |
| 90 | |:@stdio: write $char| |
| 91 | :@jet: "io.write(string.char(tonumber($char)))" |
| 92 | |:: rule 1| |
| 93 | :: match @stdio.arity 2 :: match @stdio.1 write :: bind @stdio.2 1 |
| 94 | :: consume @stdio.arity |
| 95 | :: consume @stdio.1 |
| 96 | :: consume @stdio.2 |
| 97 | :: jet @stdio write/1 |
| 98 | :: unbind 1 |
| 99 | :: rule 1 succeeded |
| 100 | |
| 101 | |:: print message? :message: $char| |
| 102 | :@stdio: write $char |
| 103 | |:: rule 2| |
| 104 | :: match .arity 2 :: match .1 print :: match .2 message |
| 105 | :: match message.arity 1 :: bind message.1 1 |
| 106 | :: consume .arity :: consume .1 :: consume .2 |
| 107 | :: consume message.arity :: consume message.1 |
| 108 | :: push @stdio.arity 2 :: push @stdio.1 write :: pushvar @stdio.2 1 |
| 109 | :: push .arity 2 :: push .1 print :: push .2 message |
| 110 | :: unbind 1 |
| 111 | :: rule 2 succeeded |
| 112 | |
| 113 | |
| 114 | |:: print message| |
| 115 | :@stdio: write 10 |
| 116 | |:: rule 3| |
| 117 | :: match .arity 2 :: match .1 print :: match .2 message |
| 118 | :: consume .arity :: consume .1 :: consume .2 |
| 119 | :: push @stdio.arity 2 :: push @stdio.1 write :: push @stdio.2 10 |
| 120 | :: unbind 1 |
| 121 | :: rule 3 succeeded |
| 122 | |
| 123 | |
| 124 | || :: rule 0 |