||:: dispatch |:: dispatch| :: evaluate :text: " initial state 01 11 11 11 rules rule and if 1 match else 0 fail end end rule end rules " |:: parse? :text: "rules" | :text: "<1[1" |:: parse? :text: "end rules" | :text: "not]" |:: parse? :text: "rule" | :text: "[>" |:: parse? :text: "end rule" | :text: "<0]" |:: parse? :text: "initial state"| :text: '>' |:: parse? :text: "match" | :text: "<0>" |:: parse? :text: "fail" | :text: "<1>" |:: select| :: evaluate :text: " 1111111 >0<[>1<]0>[0][>0<[>1<]1>] <[<] " |:: equality| :: evaluate :text: " 111> 111< unary equal " |:: seek| :: evaluate :text: " 01111 seek right 011 seek left " |:: constant equality| :: evaluate :text: " 1001 if if 01 >0< else if 001 >0< else if 1001 >1< else 0001 >0< end end end else 0 >0< end " |############################################| |# Here be dragons of the friendliest kind. #| |############################################| |:step: :@math: $x| :steps: $x |:step:? :steps: $x| :@math: add $x 1 |:step:| :steps: 1 |:: evaluate| :: parse :: run :stack: 1 :number of stacks: 10 |:: parse? :text: "halt" | :text: '@' |:: parse? :text: "begin" | :text: '[' |:: parse? :text: "loop" | :text: ']' |:: parse? :text: "end" | :text: ">0]<" |:: parse? :text: "if" | :text: ">1<[>[0]<" |:: parse? :text: "else" | :text: ">0<0]>[<" |:: parse? :text: "drop" | :text: "[0]" |:: parse? :text: "dup" | :text: " if 1 1 else 0 0 end " |:: parse? :text: "swap"| :text: " if if 1 1 else 1 0 end else if 0 1 else 0 0 end end " |:: parse? :text: "and"| :text: " if else drop 0 end " |:: parse? :text: "or"| :text: " if drop 1 else end " |:: parse? :text: "not"| :text: " if 0 else 1 end " |:: parse? :text: "move unary value left"| :text: " <0> begin <1> loop " |:: parse? :text: "move unary value right"| :text: " >0< begin >1< loop " |:: parse? :text: "seek left"| :text: "[move unary value left<]" |:: parse? :text: "seek right"| :text: "[move unary value right>]" |:: parse? :text: "unary equal"| :text: " >>1<<1[ if > if <1 else <[]>> drop 0<<0 end else > if []> drop 0<<0 else <0 end end ] >> if << 1 else << 0 end " |:: parse? :text: '<'| :parsed: < |:: parse? :text: '>'| :parsed: > |:: parse? :text: '0'| :parsed: 0 |:: parse? :text: '1'| :parsed: 1 |:: parse? :text: '['| :parsed: [ |:: parse? :text: ']'| :parsed: ] |:: parse? :text: '@'| :parsed: @ |:: parse? :text: $x | |:: parse? :parsed: $x| :code: $x |:: parse| |:: push to $x :value: $y| :stacks: $x $y |:: push $x to $y| :stacks: $y $x |:: peek at $x :value: $y?| :: push $y to $x |:: peek at $x?| :: pop from $x |:: pop from $x :stacks: $x $y| :value: $y :: reset stacks |:: pop from $x? :stacks: $z $y| :seen: $z $y |:: pop from $x :default symbol: $y?| :value: $y :: reset stacks |:: pop from $x| :value: 0 :: reset stacks |:: reset stacks? :seen: $x $y| :stacks: $x $y |:: reset stacks| |:: move $direction :@math: $x| :stack: $x |:: move left :stack: 1 :number of stacks: $x?| :stack: $x |:: move left? :stack: $x| :@math: subtract $x 1 |:: move right :stack: $x :number of stacks: $x?| :stack: 1 |:: move right? :stack: $x| :@math: add $x 1 |:: move $direction?| :stack: 1 |:: compare and branch :value: 0| :: seek forward :depth: |:: compare and branch :value: $x| |:: seek forward? :code: [| :executed: [ :depth: |:: seek forward? :code: ] :depth:? :depth:| :executed: ] |:: seek forward :code: ] :depth:| :executed: ] |:: seek forward? :code: $x| :executed: $x |:: seek forward| :: stop execution :error: unbalanced loops |:: seek backward? :executed: ]| :code: ] :depth: |:: seek backward? :executed: [ :depth:? :depth:| :code: [ |:: seek backward :executed: [ :depth:| :code: [ |:: seek backward? :executed: $x| :code: $x |:: seek backward| :: stop execution :error: unbalanced loops |:: step :code: <| :executed: < :: move left |:: step :code: >| :executed: > :: move right |:: step :code: 0 :stack: $x?| :executed: 0 :: push 0 to $x |:: step :code: 1 :stack: $x?| :executed: 1 :: push 1 to $x |:: step :code: [ :stack: $x?| :executed: [ :: pop from $x :: compare and branch |:: step :code: ]?| :: seek backward :depth: |:: step :code: @| :halt: |:: step :code: $x| |:: step| :halt: |:: run :halt:| :: clean up |:: run?| :: step :step: |:: clean up? :executed: $x| |:: clean up? :code: $x| |:: clean up|