june revisó este gist 2 weeks ago. Ir a la revisión
1 file changed, 24 insertions, 2 deletions
vita.nv
| @@ -1,4 +1,26 @@ | |||
| 1 | - | ||:: select | |
| 1 | + | ||:: dispatch | |
| 2 | + | ||
| 3 | + | |:: dispatch| :: evaluate :text: " | |
| 4 | + | initial state | |
| 5 | + | 01 11 11 11 | |
| 6 | + | rules | |
| 7 | + | rule | |
| 8 | + | and if | |
| 9 | + | 1 match | |
| 10 | + | else | |
| 11 | + | 0 fail | |
| 12 | + | end | |
| 13 | + | end rule | |
| 14 | + | end rules | |
| 15 | + | " | |
| 16 | + | ||
| 17 | + | |:: parse? :text: "rules" | :text: "<1[1" | |
| 18 | + | |:: parse? :text: "end rules" | :text: "not]" | |
| 19 | + | |:: parse? :text: "rule" | :text: "[>" | |
| 20 | + | |:: parse? :text: "end rule" | :text: "<0]" | |
| 21 | + | |:: parse? :text: "initial state"| :text: '>' | |
| 22 | + | |:: parse? :text: "match" | :text: "<0>" | |
| 23 | + | |:: parse? :text: "fail" | :text: "<1>" | |
| 2 | 24 | ||
| 3 | 25 | |:: select| :: evaluate :text: " | |
| 4 | 26 | 1111111 >0<[>1<]0>[0][>0<[>1<]1>] <[<] | |
| @@ -253,4 +275,4 @@ | |||
| 253 | 275 | ||
| 254 | 276 | |:: clean up? :executed: $x| | |
| 255 | 277 | |:: clean up? :code: $x| | |
| 256 | - | |:: clean up| | |
| 278 | + | |:: clean up| | |
june revisó este gist 2 weeks ago. Ir a la revisión
1 file changed, 5 insertions, 1 deletion
vita.nv
| @@ -1,5 +1,9 @@ | |||
| 1 | - | ||:: equality | |
| 1 | + | ||:: select | |
| 2 | 2 | ||
| 3 | + | |:: select| :: evaluate :text: " | |
| 4 | + | 1111111 >0<[>1<]0>[0][>0<[>1<]1>] <[<] | |
| 5 | + | " | |
| 6 | + | ||
| 3 | 7 | |:: equality| :: evaluate :text: " | |
| 4 | 8 | 111> 111< unary equal | |
| 5 | 9 | " | |
june revisó este gist 2 weeks ago. Ir a la revisión
1 file changed, 86 insertions, 5 deletions
vita.nv
| @@ -1,5 +1,37 @@ | |||
| 1 | - | ||:: evaluate :text: " | |
| 2 | - | 1 0 swap dup and not drop | |
| 1 | + | ||:: equality | |
| 2 | + | ||
| 3 | + | |:: equality| :: evaluate :text: " | |
| 4 | + | 111> 111< unary equal | |
| 5 | + | " | |
| 6 | + | ||
| 7 | + | |:: seek| :: evaluate :text: " | |
| 8 | + | 01111 seek right | |
| 9 | + | 011 seek left | |
| 10 | + | " | |
| 11 | + | ||
| 12 | + | |:: constant equality| :: evaluate :text: " | |
| 13 | + | 1001 if | |
| 14 | + | if | |
| 15 | + | 01 | |
| 16 | + | >0< | |
| 17 | + | else | |
| 18 | + | if | |
| 19 | + | 001 | |
| 20 | + | >0< | |
| 21 | + | else | |
| 22 | + | if | |
| 23 | + | 1001 | |
| 24 | + | >1< | |
| 25 | + | else | |
| 26 | + | 0001 | |
| 27 | + | >0< | |
| 28 | + | end | |
| 29 | + | end | |
| 30 | + | end | |
| 31 | + | else | |
| 32 | + | 0 | |
| 33 | + | >0< | |
| 34 | + | end | |
| 3 | 35 | " | |
| 4 | 36 | ||
| 5 | 37 | ||
| @@ -9,6 +41,14 @@ | |||
| 9 | 41 | |# Here be dragons of the friendliest kind. #| | |
| 10 | 42 | |############################################| | |
| 11 | 43 | ||
| 44 | + | ||
| 45 | + | |:step: :@math: $x| | |
| 46 | + | :steps: $x | |
| 47 | + | |:step:? :steps: $x| | |
| 48 | + | :@math: add $x 1 | |
| 49 | + | |:step:| | |
| 50 | + | :steps: 1 | |
| 51 | + | ||
| 12 | 52 | |:: evaluate| | |
| 13 | 53 | :: parse | |
| 14 | 54 | :: run :stack: 1 | |
| @@ -50,12 +90,14 @@ | |||
| 50 | 90 | drop 0 | |
| 51 | 91 | end | |
| 52 | 92 | " | |
| 93 | + | ||
| 53 | 94 | |:: parse? :text: "or"| :text: " | |
| 54 | 95 | if | |
| 55 | 96 | drop 1 | |
| 56 | 97 | else | |
| 57 | 98 | end | |
| 58 | 99 | " | |
| 100 | + | ||
| 59 | 101 | |:: parse? :text: "not"| :text: " | |
| 60 | 102 | if | |
| 61 | 103 | 0 | |
| @@ -64,6 +106,44 @@ | |||
| 64 | 106 | end | |
| 65 | 107 | " | |
| 66 | 108 | ||
| 109 | + | |:: parse? :text: "move unary value left"| :text: " | |
| 110 | + | <0> begin | |
| 111 | + | <1> | |
| 112 | + | loop | |
| 113 | + | " | |
| 114 | + | ||
| 115 | + | |:: parse? :text: "move unary value right"| :text: " | |
| 116 | + | >0< begin | |
| 117 | + | >1< | |
| 118 | + | loop | |
| 119 | + | " | |
| 120 | + | ||
| 121 | + | |:: parse? :text: "seek left"| :text: "[move unary value left<]" | |
| 122 | + | |:: parse? :text: "seek right"| :text: "[move unary value right>]" | |
| 123 | + | ||
| 124 | + | |:: parse? :text: "unary equal"| :text: " | |
| 125 | + | >>1<<1[ | |
| 126 | + | if | |
| 127 | + | > if | |
| 128 | + | <1 | |
| 129 | + | else | |
| 130 | + | <[]>> drop 0<<0 | |
| 131 | + | end | |
| 132 | + | else | |
| 133 | + | > if | |
| 134 | + | []> drop 0<<0 | |
| 135 | + | else | |
| 136 | + | <0 | |
| 137 | + | end | |
| 138 | + | end | |
| 139 | + | ] | |
| 140 | + | >> if | |
| 141 | + | << 1 | |
| 142 | + | else | |
| 143 | + | << 0 | |
| 144 | + | end | |
| 145 | + | " | |
| 146 | + | ||
| 67 | 147 | |:: parse? :text: '<'| :parsed: < | |
| 68 | 148 | |:: parse? :text: '>'| :parsed: > | |
| 69 | 149 | |:: parse? :text: '0'| :parsed: 0 | |
| @@ -92,7 +172,8 @@ | |||
| 92 | 172 | :value: $y | |
| 93 | 173 | :: reset stacks | |
| 94 | 174 | |:: pop from $x| | |
| 95 | - | :: stop execution :error: pop from an empty or nonexistent stack $x | |
| 175 | + | :value: 0 | |
| 176 | + | :: reset stacks | |
| 96 | 177 | ||
| 97 | 178 | |:: reset stacks? :seen: $x $y| | |
| 98 | 179 | :stacks: $x $y | |
| @@ -164,8 +245,8 @@ | |||
| 164 | 245 | |:: run :halt:| | |
| 165 | 246 | :: clean up | |
| 166 | 247 | |:: run?| | |
| 167 | - | :: step | |
| 248 | + | :: step :step: | |
| 168 | 249 | ||
| 169 | 250 | |:: clean up? :executed: $x| | |
| 170 | 251 | |:: clean up? :code: $x| | |
| 171 | - | |:: clean up| | |
| 252 | + | |:: clean up| | |
june revisó este gist 2 weeks ago. Ir a la revisión
1 file changed, 2 deletions
vita.nv
| @@ -50,14 +50,12 @@ | |||
| 50 | 50 | drop 0 | |
| 51 | 51 | end | |
| 52 | 52 | " | |
| 53 | - | ||
| 54 | 53 | |:: parse? :text: "or"| :text: " | |
| 55 | 54 | if | |
| 56 | 55 | drop 1 | |
| 57 | 56 | else | |
| 58 | 57 | end | |
| 59 | 58 | " | |
| 60 | - | ||
| 61 | 59 | |:: parse? :text: "not"| :text: " | |
| 62 | 60 | if | |
| 63 | 61 | 0 | |
june revisó este gist 2 weeks ago. Ir a la revisión
1 file changed, 173 insertions
vita.nv(archivo creado)
| @@ -0,0 +1,173 @@ | |||
| 1 | + | ||:: evaluate :text: " | |
| 2 | + | 1 0 swap dup and not drop | |
| 3 | + | " | |
| 4 | + | ||
| 5 | + | ||
| 6 | + | ||
| 7 | + | ||
| 8 | + | |############################################| | |
| 9 | + | |# Here be dragons of the friendliest kind. #| | |
| 10 | + | |############################################| | |
| 11 | + | ||
| 12 | + | |:: evaluate| | |
| 13 | + | :: parse | |
| 14 | + | :: run :stack: 1 | |
| 15 | + | :number of stacks: 10 | |
| 16 | + | ||
| 17 | + | |:: parse? :text: "halt" | :text: '@' | |
| 18 | + | |:: parse? :text: "begin" | :text: '[' | |
| 19 | + | |:: parse? :text: "loop" | :text: ']' | |
| 20 | + | |:: parse? :text: "end" | :text: ">0]<" | |
| 21 | + | |:: parse? :text: "if" | :text: ">1<[>[0]<" | |
| 22 | + | |:: parse? :text: "else" | :text: ">0<0]>[<" | |
| 23 | + | ||
| 24 | + | |:: parse? :text: "drop" | :text: "[0]" | |
| 25 | + | |:: parse? :text: "dup" | :text: " | |
| 26 | + | if | |
| 27 | + | 1 1 | |
| 28 | + | else | |
| 29 | + | 0 0 | |
| 30 | + | end | |
| 31 | + | " | |
| 32 | + | |:: parse? :text: "swap"| :text: " | |
| 33 | + | if | |
| 34 | + | if | |
| 35 | + | 1 1 | |
| 36 | + | else | |
| 37 | + | 1 0 | |
| 38 | + | end | |
| 39 | + | else | |
| 40 | + | if | |
| 41 | + | 0 1 | |
| 42 | + | else | |
| 43 | + | 0 0 | |
| 44 | + | end | |
| 45 | + | end | |
| 46 | + | " | |
| 47 | + | |:: parse? :text: "and"| :text: " | |
| 48 | + | if | |
| 49 | + | else | |
| 50 | + | drop 0 | |
| 51 | + | end | |
| 52 | + | " | |
| 53 | + | ||
| 54 | + | |:: parse? :text: "or"| :text: " | |
| 55 | + | if | |
| 56 | + | drop 1 | |
| 57 | + | else | |
| 58 | + | end | |
| 59 | + | " | |
| 60 | + | ||
| 61 | + | |:: parse? :text: "not"| :text: " | |
| 62 | + | if | |
| 63 | + | 0 | |
| 64 | + | else | |
| 65 | + | 1 | |
| 66 | + | end | |
| 67 | + | " | |
| 68 | + | ||
| 69 | + | |:: parse? :text: '<'| :parsed: < | |
| 70 | + | |:: parse? :text: '>'| :parsed: > | |
| 71 | + | |:: parse? :text: '0'| :parsed: 0 | |
| 72 | + | |:: parse? :text: '1'| :parsed: 1 | |
| 73 | + | |:: parse? :text: '['| :parsed: [ | |
| 74 | + | |:: parse? :text: ']'| :parsed: ] | |
| 75 | + | |:: parse? :text: '@'| :parsed: @ | |
| 76 | + | |:: parse? :text: $x | | |
| 77 | + | |:: parse? :parsed: $x| :code: $x | |
| 78 | + | |:: parse| | |
| 79 | + | ||
| 80 | + | |:: push to $x :value: $y| :stacks: $x $y | |
| 81 | + | |:: push $x to $y| :stacks: $y $x | |
| 82 | + | ||
| 83 | + | |:: peek at $x :value: $y?| | |
| 84 | + | :: push $y to $x | |
| 85 | + | |:: peek at $x?| | |
| 86 | + | :: pop from $x | |
| 87 | + | ||
| 88 | + | |:: pop from $x :stacks: $x $y| | |
| 89 | + | :value: $y | |
| 90 | + | :: reset stacks | |
| 91 | + | |:: pop from $x? :stacks: $z $y| | |
| 92 | + | :seen: $z $y | |
| 93 | + | |:: pop from $x :default symbol: $y?| | |
| 94 | + | :value: $y | |
| 95 | + | :: reset stacks | |
| 96 | + | |:: pop from $x| | |
| 97 | + | :: stop execution :error: pop from an empty or nonexistent stack $x | |
| 98 | + | ||
| 99 | + | |:: reset stacks? :seen: $x $y| | |
| 100 | + | :stacks: $x $y | |
| 101 | + | |:: reset stacks| | |
| 102 | + | ||
| 103 | + | |:: move $direction :@math: $x| | |
| 104 | + | :stack: $x | |
| 105 | + | |:: move left :stack: 1 :number of stacks: $x?| | |
| 106 | + | :stack: $x | |
| 107 | + | |:: move left? :stack: $x| | |
| 108 | + | :@math: subtract $x 1 | |
| 109 | + | |:: move right :stack: $x :number of stacks: $x?| | |
| 110 | + | :stack: 1 | |
| 111 | + | |:: move right? :stack: $x| | |
| 112 | + | :@math: add $x 1 | |
| 113 | + | |:: move $direction?| | |
| 114 | + | :stack: 1 | |
| 115 | + | ||
| 116 | + | |:: compare and branch :value: 0| | |
| 117 | + | :: seek forward :depth: | |
| 118 | + | |:: compare and branch :value: $x| | |
| 119 | + | ||
| 120 | + | |:: seek forward? :code: [| | |
| 121 | + | :executed: [ | |
| 122 | + | :depth: | |
| 123 | + | |:: seek forward? :code: ] :depth:? :depth:| | |
| 124 | + | :executed: ] | |
| 125 | + | |:: seek forward :code: ] :depth:| | |
| 126 | + | :executed: ] | |
| 127 | + | |:: seek forward? :code: $x| | |
| 128 | + | :executed: $x | |
| 129 | + | |:: seek forward| | |
| 130 | + | :: stop execution :error: unbalanced loops | |
| 131 | + | ||
| 132 | + | |:: seek backward? :executed: ]| | |
| 133 | + | :code: ] | |
| 134 | + | :depth: | |
| 135 | + | |:: seek backward? :executed: [ :depth:? :depth:| | |
| 136 | + | :code: [ | |
| 137 | + | |:: seek backward :executed: [ :depth:| | |
| 138 | + | :code: [ | |
| 139 | + | |:: seek backward? :executed: $x| | |
| 140 | + | :code: $x | |
| 141 | + | |:: seek backward| | |
| 142 | + | :: stop execution :error: unbalanced loops | |
| 143 | + | ||
| 144 | + | |:: step :code: <| | |
| 145 | + | :executed: < | |
| 146 | + | :: move left | |
| 147 | + | |:: step :code: >| | |
| 148 | + | :executed: > | |
| 149 | + | :: move right | |
| 150 | + | |:: step :code: 0 :stack: $x?| | |
| 151 | + | :executed: 0 | |
| 152 | + | :: push 0 to $x | |
| 153 | + | |:: step :code: 1 :stack: $x?| | |
| 154 | + | :executed: 1 | |
| 155 | + | :: push 1 to $x | |
| 156 | + | |:: step :code: [ :stack: $x?| | |
| 157 | + | :executed: [ | |
| 158 | + | :: pop from $x | |
| 159 | + | :: compare and branch | |
| 160 | + | |:: step :code: ]?| | |
| 161 | + | :: seek backward :depth: | |
| 162 | + | |:: step :code: @| :halt: | |
| 163 | + | |:: step :code: $x| | |
| 164 | + | |:: step| :halt: | |
| 165 | + | ||
| 166 | + | |:: run :halt:| | |
| 167 | + | :: clean up | |
| 168 | + | |:: run?| | |
| 169 | + | :: step | |
| 170 | + | ||
| 171 | + | |:: clean up? :executed: $x| | |
| 172 | + | |:: clean up? :code: $x| | |
| 173 | + | |:: clean up| | |