├── .github └── workflows │ └── rust.yml ├── .gitignore ├── .vscode └── launch.json ├── Cargo.lock ├── Cargo.toml ├── LICENSE.Apache ├── LICENSE.MIT ├── README.md ├── examples ├── bench.bf ├── factor.bf ├── hanoi.bf ├── long.bf ├── mandelbrot.bf ├── oobrain.bf └── prime └── src ├── brainfuck.pest ├── codegen.rs ├── main.rs └── parser.rs /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: Rust 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v1 10 | - name: Install LLVM@10 11 | run: sudo apt install -y llvm-10-dev 12 | - name: Build 13 | run: cargo build --verbose 14 | - name: Run tests 15 | run: cargo test --verbose 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // IntelliSense を使用して利用可能な属性を学べます。 3 | // 既存の属性の説明をホバーして表示します。 4 | // 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "lldb", 9 | "request": "launch", 10 | "name": "Debug executable 'bf-rs'", 11 | "cargo": { 12 | "args": [ 13 | "build", 14 | "--bin=bf-rs", 15 | "--package=bf-rs" 16 | ], 17 | "filter": { 18 | "name": "bf-rs", 19 | "kind": "bin" 20 | } 21 | }, 22 | "args": [], 23 | "cwd": "${workspaceFolder}" 24 | }, 25 | { 26 | "type": "lldb", 27 | "request": "launch", 28 | "name": "Debug unit tests in executable 'bf-rs'", 29 | "cargo": { 30 | "args": [ 31 | "test", 32 | "--no-run", 33 | "--bin=bf-rs", 34 | "--package=bf-rs" 35 | ], 36 | "filter": { 37 | "name": "bf-rs", 38 | "kind": "bin" 39 | } 40 | }, 41 | "args": [], 42 | "cwd": "${workspaceFolder}" 43 | } 44 | ] 45 | } -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "aho-corasick" 5 | version = "0.7.13" 6 | source = "registry+https://github.com/rust-lang/crates.io-index" 7 | checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" 8 | dependencies = [ 9 | "memchr", 10 | ] 11 | 12 | [[package]] 13 | name = "bf-rs" 14 | version = "1.0.2" 15 | dependencies = [ 16 | "inkwell", 17 | "pest", 18 | "pest_derive", 19 | "thiserror", 20 | ] 21 | 22 | [[package]] 23 | name = "bitflags" 24 | version = "1.2.1" 25 | source = "registry+https://github.com/rust-lang/crates.io-index" 26 | checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" 27 | 28 | [[package]] 29 | name = "block-buffer" 30 | version = "0.7.3" 31 | source = "registry+https://github.com/rust-lang/crates.io-index" 32 | checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" 33 | dependencies = [ 34 | "block-padding", 35 | "byte-tools", 36 | "byteorder", 37 | "generic-array", 38 | ] 39 | 40 | [[package]] 41 | name = "block-padding" 42 | version = "0.1.5" 43 | source = "registry+https://github.com/rust-lang/crates.io-index" 44 | checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" 45 | dependencies = [ 46 | "byte-tools", 47 | ] 48 | 49 | [[package]] 50 | name = "byte-tools" 51 | version = "0.3.1" 52 | source = "registry+https://github.com/rust-lang/crates.io-index" 53 | checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" 54 | 55 | [[package]] 56 | name = "byteorder" 57 | version = "1.3.4" 58 | source = "registry+https://github.com/rust-lang/crates.io-index" 59 | checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" 60 | 61 | [[package]] 62 | name = "cc" 63 | version = "1.0.59" 64 | source = "registry+https://github.com/rust-lang/crates.io-index" 65 | checksum = "66120af515773fb005778dc07c261bd201ec8ce50bd6e7144c927753fe013381" 66 | 67 | [[package]] 68 | name = "cfg-if" 69 | version = "0.1.10" 70 | source = "registry+https://github.com/rust-lang/crates.io-index" 71 | checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" 72 | 73 | [[package]] 74 | name = "cloudabi" 75 | version = "0.1.0" 76 | source = "registry+https://github.com/rust-lang/crates.io-index" 77 | checksum = "4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467" 78 | dependencies = [ 79 | "bitflags", 80 | ] 81 | 82 | [[package]] 83 | name = "digest" 84 | version = "0.8.1" 85 | source = "registry+https://github.com/rust-lang/crates.io-index" 86 | checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" 87 | dependencies = [ 88 | "generic-array", 89 | ] 90 | 91 | [[package]] 92 | name = "either" 93 | version = "1.6.0" 94 | source = "registry+https://github.com/rust-lang/crates.io-index" 95 | checksum = "cd56b59865bce947ac5958779cfa508f6c3b9497cc762b7e24a12d11ccde2c4f" 96 | 97 | [[package]] 98 | name = "fake-simd" 99 | version = "0.1.2" 100 | source = "registry+https://github.com/rust-lang/crates.io-index" 101 | checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" 102 | 103 | [[package]] 104 | name = "generic-array" 105 | version = "0.12.3" 106 | source = "registry+https://github.com/rust-lang/crates.io-index" 107 | checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" 108 | dependencies = [ 109 | "typenum", 110 | ] 111 | 112 | [[package]] 113 | name = "inkwell" 114 | version = "0.1.0" 115 | source = "git+https://github.com/TheDan64/inkwell#3617ed3e64378cdbcb1dce026ece201246fec15c" 116 | dependencies = [ 117 | "either", 118 | "inkwell_internals", 119 | "libc", 120 | "llvm-sys", 121 | "once_cell", 122 | "parking_lot", 123 | "regex", 124 | ] 125 | 126 | [[package]] 127 | name = "inkwell_internals" 128 | version = "0.2.0" 129 | source = "git+https://github.com/TheDan64/inkwell#3617ed3e64378cdbcb1dce026ece201246fec15c" 130 | dependencies = [ 131 | "proc-macro2", 132 | "quote", 133 | "syn", 134 | ] 135 | 136 | [[package]] 137 | name = "instant" 138 | version = "0.1.6" 139 | source = "registry+https://github.com/rust-lang/crates.io-index" 140 | checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485" 141 | 142 | [[package]] 143 | name = "lazy_static" 144 | version = "1.4.0" 145 | source = "registry+https://github.com/rust-lang/crates.io-index" 146 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 147 | 148 | [[package]] 149 | name = "libc" 150 | version = "0.2.77" 151 | source = "registry+https://github.com/rust-lang/crates.io-index" 152 | checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235" 153 | 154 | [[package]] 155 | name = "llvm-sys" 156 | version = "100.2.0" 157 | source = "registry+https://github.com/rust-lang/crates.io-index" 158 | checksum = "9109e19fbfac3458f2970189719fa19f1007c6fd4e08c44fdebf4be0ddbe261d" 159 | dependencies = [ 160 | "cc", 161 | "lazy_static", 162 | "libc", 163 | "regex", 164 | "semver", 165 | ] 166 | 167 | [[package]] 168 | name = "lock_api" 169 | version = "0.4.1" 170 | source = "registry+https://github.com/rust-lang/crates.io-index" 171 | checksum = "28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c" 172 | dependencies = [ 173 | "scopeguard", 174 | ] 175 | 176 | [[package]] 177 | name = "maplit" 178 | version = "1.0.2" 179 | source = "registry+https://github.com/rust-lang/crates.io-index" 180 | checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" 181 | 182 | [[package]] 183 | name = "memchr" 184 | version = "2.3.3" 185 | source = "registry+https://github.com/rust-lang/crates.io-index" 186 | checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" 187 | 188 | [[package]] 189 | name = "once_cell" 190 | version = "1.4.1" 191 | source = "registry+https://github.com/rust-lang/crates.io-index" 192 | checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" 193 | 194 | [[package]] 195 | name = "opaque-debug" 196 | version = "0.2.3" 197 | source = "registry+https://github.com/rust-lang/crates.io-index" 198 | checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" 199 | 200 | [[package]] 201 | name = "parking_lot" 202 | version = "0.11.0" 203 | source = "registry+https://github.com/rust-lang/crates.io-index" 204 | checksum = "a4893845fa2ca272e647da5d0e46660a314ead9c2fdd9a883aabc32e481a8733" 205 | dependencies = [ 206 | "instant", 207 | "lock_api", 208 | "parking_lot_core", 209 | ] 210 | 211 | [[package]] 212 | name = "parking_lot_core" 213 | version = "0.8.0" 214 | source = "registry+https://github.com/rust-lang/crates.io-index" 215 | checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" 216 | dependencies = [ 217 | "cfg-if", 218 | "cloudabi", 219 | "instant", 220 | "libc", 221 | "redox_syscall", 222 | "smallvec", 223 | "winapi", 224 | ] 225 | 226 | [[package]] 227 | name = "pest" 228 | version = "2.1.3" 229 | source = "registry+https://github.com/rust-lang/crates.io-index" 230 | checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" 231 | dependencies = [ 232 | "ucd-trie", 233 | ] 234 | 235 | [[package]] 236 | name = "pest_derive" 237 | version = "2.1.0" 238 | source = "registry+https://github.com/rust-lang/crates.io-index" 239 | checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" 240 | dependencies = [ 241 | "pest", 242 | "pest_generator", 243 | ] 244 | 245 | [[package]] 246 | name = "pest_generator" 247 | version = "2.1.3" 248 | source = "registry+https://github.com/rust-lang/crates.io-index" 249 | checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" 250 | dependencies = [ 251 | "pest", 252 | "pest_meta", 253 | "proc-macro2", 254 | "quote", 255 | "syn", 256 | ] 257 | 258 | [[package]] 259 | name = "pest_meta" 260 | version = "2.1.3" 261 | source = "registry+https://github.com/rust-lang/crates.io-index" 262 | checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" 263 | dependencies = [ 264 | "maplit", 265 | "pest", 266 | "sha-1", 267 | ] 268 | 269 | [[package]] 270 | name = "proc-macro2" 271 | version = "1.0.21" 272 | source = "registry+https://github.com/rust-lang/crates.io-index" 273 | checksum = "36e28516df94f3dd551a587da5357459d9b36d945a7c37c3557928c1c2ff2a2c" 274 | dependencies = [ 275 | "unicode-xid", 276 | ] 277 | 278 | [[package]] 279 | name = "quote" 280 | version = "1.0.7" 281 | source = "registry+https://github.com/rust-lang/crates.io-index" 282 | checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" 283 | dependencies = [ 284 | "proc-macro2", 285 | ] 286 | 287 | [[package]] 288 | name = "redox_syscall" 289 | version = "0.1.57" 290 | source = "registry+https://github.com/rust-lang/crates.io-index" 291 | checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" 292 | 293 | [[package]] 294 | name = "regex" 295 | version = "1.3.9" 296 | source = "registry+https://github.com/rust-lang/crates.io-index" 297 | checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" 298 | dependencies = [ 299 | "aho-corasick", 300 | "memchr", 301 | "regex-syntax", 302 | "thread_local", 303 | ] 304 | 305 | [[package]] 306 | name = "regex-syntax" 307 | version = "0.6.18" 308 | source = "registry+https://github.com/rust-lang/crates.io-index" 309 | checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" 310 | 311 | [[package]] 312 | name = "scopeguard" 313 | version = "1.1.0" 314 | source = "registry+https://github.com/rust-lang/crates.io-index" 315 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 316 | 317 | [[package]] 318 | name = "semver" 319 | version = "0.9.0" 320 | source = "registry+https://github.com/rust-lang/crates.io-index" 321 | checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 322 | dependencies = [ 323 | "semver-parser", 324 | ] 325 | 326 | [[package]] 327 | name = "semver-parser" 328 | version = "0.7.0" 329 | source = "registry+https://github.com/rust-lang/crates.io-index" 330 | checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 331 | 332 | [[package]] 333 | name = "sha-1" 334 | version = "0.8.2" 335 | source = "registry+https://github.com/rust-lang/crates.io-index" 336 | checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" 337 | dependencies = [ 338 | "block-buffer", 339 | "digest", 340 | "fake-simd", 341 | "opaque-debug", 342 | ] 343 | 344 | [[package]] 345 | name = "smallvec" 346 | version = "1.4.2" 347 | source = "registry+https://github.com/rust-lang/crates.io-index" 348 | checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" 349 | 350 | [[package]] 351 | name = "syn" 352 | version = "1.0.41" 353 | source = "registry+https://github.com/rust-lang/crates.io-index" 354 | checksum = "6690e3e9f692504b941dc6c3b188fd28df054f7fb8469ab40680df52fdcc842b" 355 | dependencies = [ 356 | "proc-macro2", 357 | "quote", 358 | "unicode-xid", 359 | ] 360 | 361 | [[package]] 362 | name = "thiserror" 363 | version = "1.0.20" 364 | source = "registry+https://github.com/rust-lang/crates.io-index" 365 | checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" 366 | dependencies = [ 367 | "thiserror-impl", 368 | ] 369 | 370 | [[package]] 371 | name = "thiserror-impl" 372 | version = "1.0.20" 373 | source = "registry+https://github.com/rust-lang/crates.io-index" 374 | checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" 375 | dependencies = [ 376 | "proc-macro2", 377 | "quote", 378 | "syn", 379 | ] 380 | 381 | [[package]] 382 | name = "thread_local" 383 | version = "1.0.1" 384 | source = "registry+https://github.com/rust-lang/crates.io-index" 385 | checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" 386 | dependencies = [ 387 | "lazy_static", 388 | ] 389 | 390 | [[package]] 391 | name = "typenum" 392 | version = "1.12.0" 393 | source = "registry+https://github.com/rust-lang/crates.io-index" 394 | checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" 395 | 396 | [[package]] 397 | name = "ucd-trie" 398 | version = "0.1.3" 399 | source = "registry+https://github.com/rust-lang/crates.io-index" 400 | checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" 401 | 402 | [[package]] 403 | name = "unicode-xid" 404 | version = "0.2.1" 405 | source = "registry+https://github.com/rust-lang/crates.io-index" 406 | checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" 407 | 408 | [[package]] 409 | name = "winapi" 410 | version = "0.3.9" 411 | source = "registry+https://github.com/rust-lang/crates.io-index" 412 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 413 | dependencies = [ 414 | "winapi-i686-pc-windows-gnu", 415 | "winapi-x86_64-pc-windows-gnu", 416 | ] 417 | 418 | [[package]] 419 | name = "winapi-i686-pc-windows-gnu" 420 | version = "0.4.0" 421 | source = "registry+https://github.com/rust-lang/crates.io-index" 422 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 423 | 424 | [[package]] 425 | name = "winapi-x86_64-pc-windows-gnu" 426 | version = "0.4.0" 427 | source = "registry+https://github.com/rust-lang/crates.io-index" 428 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 429 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bf-rs" 3 | version = "1.0.2" 4 | authors = ["Hikaru Terazono (3c1u) <3c1u@vulpesgames.tokyo>"] 5 | edition = "2018" 6 | license = "MIT OR Apache-2.0" 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | description = "Fast Brainfuck interpreter written in Rust" 9 | repository = "https://github.com/3c1u/bf-rs" 10 | 11 | keywords = ["brainfuck", "llvm", "jit", "esolang", "interpreter"] 12 | 13 | [dependencies] 14 | pest = "2.1.3" 15 | pest_derive = "2.1.0" 16 | inkwell = { git = "https://github.com/TheDan64/inkwell", branch = "master", features = ["llvm10-0"] } 17 | thiserror = "1.0.20" 18 | -------------------------------------------------------------------------------- /LICENSE.Apache: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE.MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Hikaru Terazono 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bf-rs 2 | 3 | [![Actions Status](https://github.com/3c1u/bf-rs/workflows/Rust/badge.svg)](https://github.com/3c1u/bf-rs/actions) 4 | 5 | **Fast** Brainfuck interpreter written in Rust. 6 | 7 | ## Prerequisites 8 | 9 | * Rust toolchain (1.39.0 or greater) 10 | * LLVM 8.0 11 | 12 | ## Installation 13 | 14 | ```console 15 | cargo install --git https://github.com/3c1u/bf-rs.git 16 | ``` 17 | 18 | ## Benchmarks 19 | 20 | This table shows the time taken to run the programs on interpreters. These results were measured on a MacBook Pro (Late 2016, i7-6700HQ). 21 | 22 | | | bf-rs (v1.0.1) | bf-rs (opt) | [bfc](https://github.com/barracks510/bfc) | [bf02](https://github.com/3c1u/bf-interpreter) | 23 | |:--|:-|:-|:-|:--| 24 | |mandelbrot| 3.56 sec | 3.22 sec | 5.26 sec | 9.82 sec | 25 | |hanoi | 0.44 sec | 1.79 sec | 0.38 sec | 1.06 sec | 26 | |long | 2.07 sec | 0.87 sec | 2.51 sec | 7.30 sec | 27 | |bench | 0.16 sec | 0.10 sec | 0.41 sec | 0.58 sec | 28 | |factor | 0.83 sec | 0.67 sec | 1.19 sec | 4.00 sec | 29 | ## About example programs 30 | 31 | These are some programs that I have found online. I did not write any of them. 32 | 33 | * **bench.bf** Found on [here](https://github.com/kostya/benchmarks/tree/master/brainfuck). Shows the alphabets in a reverse order. 34 | * **mandelbrot.bf** Found on [here](https://github.com/kostya/benchmarks/tree/master/brainfuck). Prints a beautiful Mandelbrot set. 35 | * **hanoi.bf** Found on [here](https://github.com/fabianishere/brainfuck/blob/master/examples/hanoi.bf). Solves the Tower of Hanoi problem. 36 | * **factor.bf** Obtained from [here](https://github.com/retrage/brainfuck-rs). 37 | * **long.bf** Obtained from [bfc](https://github.com/barracks510/bfc) repositiory. 38 | * **oobrain.bf** Obtained from [here](https://github.com/Borisvl/brainfuck/blob/master/src/test/resources/bf/oobrain.b). Used for testing proper `u8` handling. 39 | 40 | ## License 41 | 42 | This program is lisensed under the Apache License 2.0 or MIT License. 43 | -------------------------------------------------------------------------------- /examples/bench.bf: -------------------------------------------------------------------------------- 1 | https://github.com/kostya/benchmarks/blob/master/brainfuck/bench.b 2 | Benchmark brainf*ck program 3 | >++[<+++++++++++++>-]<[[>+>+<<-]>[<+>-]++++++++ 4 | [>++++++++<-]>.[-]<<>++++++++++[>++++++++++[>++ 5 | ++++++++[>++++++++++[>++++++++++[>++++++++++[>+ 6 | +++++++++[-]<-]<-]<-]<-]<-]<-]<-]++++++++++. 7 | -------------------------------------------------------------------------------- /examples/factor.bf: -------------------------------------------------------------------------------- 1 | [ 2 | Takes an integer from stdin and emits its factors to stdout 3 | 4 | Factor an arbitrarily large positive integer 5 | 6 | Copyright (C) 1999 by Brian Raiter 7 | under the GNU General Public License 8 | ] 9 | 10 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>- 11 | 12 | * 13 | * read in the number 14 | * 15 | 16 | <<<<<<<<<+ 17 | [-[>>>>>>>>>>][-]<<<<<<<<<<[[->>>>>>>>>>+<<<<<<<<<<]<<<<<<<<<<] 18 | >>>>>>>>>>,----------] 19 | >>>>>>>>>>[------------------------------------->>>>>>>>>->] 20 | <[+>[>>>>>>>>>+>]<-<<<<<<<<<<]- 21 | 22 | * 23 | * display the number and initialize the loop variable to two 24 | * 25 | 26 | [>++++++++++++++++++++++++++++++++++++++++++++++++. 27 | ------------------------------------------------<<<<<<<<<<<] 28 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++. 29 | --------------------------.[-] 30 | >>>>>>>>>>>>++<<<<+ 31 | 32 | * 33 | * the main loop 34 | * 35 | 36 | [ [-]>> 37 | 38 | * 39 | * make copies of the number and the loop variable 40 | * 41 | 42 | [>>>>[-]>[-]>[-]>[-] 43 | >[-]>[-] 44 | <<<<<<<[->>>+>+<<<<]>>>>>>>>] 45 | <<<<<<<<<<[>>>>>>[-<<<<+>>>>]<<<<<<<<<<<<<<<<]>>>>>>>>>> 46 | [>[->>>+>>+<<<<<]>>>>>>>>>] 47 | <<<<<<<<<<[>>>>>>[-<<<<<+>>>>>]<<<<<<<<<<<<<<<<]>>>>>>>>>> 48 | 49 | * 50 | * divide the number by the loop variable 51 | * 52 | 53 | [>>>[-]>>>[-]>[-]>>>] initialize 54 | <<<<<<<<<<[<<<<<<<<<<] 55 | >>>>>>>>>[-]>>>>>>>+<<<<<<<<[+]+ 56 | [ ->> double divisor until above dividend 57 | [>>>>>>[->++<]>>>>]<<<<<<<<<< 58 | [>>>>>>>>[-]>[-] 59 | <<<<[->>>++<<<]<<<<<<<<<<<<<<<]>>>>>>>>>> 60 | [>>>>>>>>[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+< 61 | [->--------->>>>>>>>>+<<<<<<<<<<[->+<]]]]]]]]]]]>>] 62 | <<<<<<<<<<[>>>>>>>>>[-<+<<<+>>>>]<<<<<<<<<<<<<<<<<<<]>>>>>>>>>> 63 | [>>>>>>>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+> 64 | [-<--------->>>>>>>>>>>+<<<<<<<<<<[-<+>]]]]]]]]]]]>>>] 65 | <<<<<<<<<< 66 | [>>>>[->>>+>>+<<<<<]<<<<<<<<<<<<<<] 67 | >>>>>>>>>>[>>>>>>>[-<<<+>>>]>>>]<<<<<<<<<< 68 | [>>>>>>>>[->-<]> 69 | [<<<<<<<<<[<[-]>>>>>>>>>>[-<<<<<<<<<<+>>>>>>>>>>]<<<<<<<<<<<<<<<<<<<] 70 | >>>>>>>>>>>>>>>>>>>] 71 | <<<<<<<<<<<<<<<<<<<] 72 | >>>>>>>>>[+[+[+[+[+[+[+[+[+[+[[-]<+>]]]]]]]]]]]< 73 | ] 74 | >>>>>>>> 75 | [ subtract divisor from dividend 76 | <<<<<< 77 | [>>>>>>>>[-]>[-]<<<<<[->>>+>+<<<<]>>>>>>]<<<<<<<<<< 78 | [>>>>>>>>[-<<<<+>>>>]<<<[->>>+>+<<<<]<<<<<<<<<<<<<<<]>>>>>>>>>> 79 | [>>>>>>>>>[-<<<<+>>>>]>]<<<<<<<<<< 80 | [>>>>>>>>[-<->]<<<<<<<<<<<<<<<<<<]>>>>>>>>>> 81 | [>>>>>>>[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+< 82 | [++++++++++[+>-<]>>>>>>>>>>-<<<<<<<<<<]]]]]]]]]]]>>>] 83 | >>>>>>>+ 84 | [ if difference is nonnegative then 85 | [-]<<<<<<<<<<<<<<<<< replace dividend and increment quotient 86 | [>>>>[-]>>>>[-<<<<+>>>>]<<[->>+<<]<<<<<<<<<<<<<<<<]>>>>>>>>>> 87 | [>>>>>>>>[->+<<<+>>]>>]<<<<<<<<<< 88 | [>>>[->>>>>>+<<<<<<]<<<<<<<<<<<<<]>>>>>>>>>> 89 | [>>>>>>>>>[-<<<<<<+>>>>>>[-<<<<<<+>>>>>> 90 | [-<<<<<<+>>>>>>[-<<<<<<+>>>>>> 91 | [-<<<<<<+>>>>>>[-<<<<<<+>>>>>> 92 | [-<<<<<<+>>>>>>[-<<<<<<+>>>>>> 93 | [-<<<<<<+>>>>>>[-<<<<<<--------->>>>>>>>>>>>>>>>+<<<<<<<<<< 94 | [-<<<<<<+>>>>>>]]]]]]]]]]]>] 95 | >>>>>>> 96 | ] halve divisor and loop until zero 97 | <<<<<<<<<<<<<<<<<[<<<<<<<<<<]>>>>>>>>>> 98 | [>>>>>>>>[-]<<[->+<]<[->>>+<<<]>>>>>]<<<<<<<<<< 99 | [+>>>>>>>[-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+> 100 | [-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+> 101 | [-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+> 102 | [-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+> 103 | [-<<<<<<<+>>>>>>>]]]]]]]]]<<<<<<< 104 | [->>>>>>>+<<<<<<<]-<<<<<<<<<<] 105 | >>>>>>> 106 | [-<<<<<<<<<<<+>>>>>>>>>>>] 107 | >>>[>>>>>>>[-<<<<<<<<<<<+++++>>>>>>>>>>>]>>>]<<<<<<<<<< 108 | [+>>>>>>>>[-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>> 109 | [-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>> 110 | [-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>> 111 | [-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>> 112 | [-<<<<<<<<+>>>>>>>>]]]]]]]]]<<<<<<<< 113 | [->>>>>>>>+<<<<<<<<]-<<<<<<<<<<] 114 | >>>>>>>>[-<<<<<<<<<<<<<+>>>>>>>>>>>>>]>> 115 | [>>>>>>>>[-<<<<<<<<<<<<<+++++>>>>>>>>>>>>>]>>]<<<<<<<<<< 116 | [<<<<<<<<<<]>>>>>>>>>> 117 | >>>>>> 118 | ] 119 | <<<<<< 120 | 121 | * 122 | * make copies of the loop variable and the quotient 123 | * 124 | 125 | [>>>[->>>>+>+<<<<<]>>>>>>>] 126 | <<<<<<<<<< 127 | [>>>>>>>[-<<<<+>>>>]<<<<<[->>>>>+>>+<<<<<<<]<<<<<<<<<<<<] 128 | >>>>>>>>>>[>>>>>>>[-<<<<<+>>>>>]>>>]<<<<<<<<<< 129 | 130 | * 131 | * break out of the loop if the quotient is larger than the loop variable 132 | * 133 | 134 | [>>>>>>>>>[-<->]< 135 | [<<<<<<<< 136 | [<<[-]>>>>>>>>>>[-<<<<<<<<<<+>>>>>>>>>>]<<<<<<<<<<<<<<<<<<] 137 | >>>>>>>>>>>>>>>>>>]<<<<<<<<<<<<<<<<<<] 138 | >>>>>>>>[>-<[+[+[+[+[+[+[+[+[+[[-]>+<]]]]]]]]]]]>+ 139 | 140 | [ [-] 141 | 142 | * 143 | * partially increment the loop variable 144 | * 145 | 146 | <[-]+>>>>+>>>>>>>>[>>>>>>>>>>]<<<<<<<<<< 147 | 148 | * 149 | * examine the remainder for nonzero digits 150 | * 151 | 152 | [<<<<<<[<<<<[<<<<<<<<<<]>>>>+<<<<<<<<<<]<<<<] 153 | >>>>>>>>>>>>>>>>>>>>[>>>>>>>>>>]<<<<<<<<<<[<<<<<<<<<<] 154 | >>>>- 155 | 156 | [ [+] 157 | 158 | * 159 | * decrement the loop variable and replace the number with the quotient 160 | * 161 | 162 | >>>>>>>>-<<[>[-]>>[-<<+>>]>>>>>>>]<<<<<<<<<< 163 | 164 | * 165 | * display the loop variable 166 | * 167 | 168 | [+>>[>>>>>>>>+>>]<<-<<<<<<<<<<]- 169 | [>>++++++++++++++++++++++++++++++++++++++++++++++++. 170 | ------------------------------------------------<<<<<<<<<<<<] 171 | ++++++++++++++++++++++++++++++++.[-]>>>> 172 | 173 | ] 174 | 175 | * 176 | * normalize the loop variable 177 | * 178 | 179 | >>>>>> 180 | [>>[->>>>>+<<<<<[->>>>>+<<<<< 181 | [->>>>>+<<<<<[->>>>>+<<<<< 182 | [->>>>>+<<<<<[->>>>>+<<<<< 183 | [->>>>>+<<<<<[->>>>>+<<<<< 184 | [->>>>>+<<<<<[->>>>>--------->>>>>+<<<<<<<<<< 185 | [->>>>>+<<<<<]]]]]]]]]]]>>>>>>>>] 186 | <<<<<<<<<<[>>>>>>>[-<<<<<+>>>>>]<<<<<<<<<<<<<<<<<] 187 | >>>>>>>>> 188 | 189 | ]< 190 | 191 | ]>> 192 | 193 | * 194 | * display the number and end 195 | * 196 | 197 | [>>>>>>>>>>]<<<<<<<<<<[+>[>>>>>>>>>+>]<-<<<<<<<<<<]- 198 | [>++++++++++++++++++++++++++++++++++++++++++++++++.<<<<<<<<<<<] 199 | ++++++++++. 200 | -------------------------------------------------------------------------------- /examples/hanoi.bf: -------------------------------------------------------------------------------- 1 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 2 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[-]>>>>>>>>>>>>>>>>>>>>>>>>>>>> 3 | >>>>>>>>>>>>>[-]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[-]>>>>>>>>>>>>>>>> 4 | >>>>>>>>>>>>>>>>>>>>>>>>>[-]>[-]+++++++++++++++++++++++++++.++++++++++++++++ 5 | ++++++++++++++++++++++++++++++++++++++++++++++++.-------------------.------- 6 | --------------------------------------.+++++++++++++++++++++++++++++++++++++ 7 | +++++++++++++++++++++++++++.-----------------------------------------.++++++ 8 | ++++++++++++++++++.[-]+++++++++++++++++++++++++++.++++++++++++++++++++++++++ 9 | ++++++++++++++++++++++++++++++++++++++.------------------------------------- 10 | ----.+++++++++.---------.+++++.+++++++++++++++++.++++++++++++.++++++++++++++ 11 | +++++++++++++.++++++++.------------------.+++++++++++++.+.------------------ 12 | -----------------------------------------------------------------.++++++++++ 13 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.------ 14 | ---.----------------------------------------------------------------------.+ 15 | +++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++.++++++++++ 16 | +++.+.------.--------------------------------------------------------------- 17 | ----------.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 18 | ++++++++.+++++.------------------------------------------------------------- 19 | -----------------.++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++ 20 | +++++++++++++++++++++++++.-----------------.++++++++.+++++.--------.-------- 21 | ----------------------------------------------------.+++++++++++++++++++++++ 22 | ++++++++++++++++++++++++++++++++++.++++++++.[-]+++++++++++++++++++++++++++.+ 23 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.------------ 24 | ----------------------------.++++++++.----------.++++.+++++++++++++++++++.++ 25 | +++++++++++++.+++++++++++++++++++++++++++.---------.+++++++++++..----------- 26 | ----.+++++++++.------------------------------------------------------------- 27 | -----------------.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 28 | ++++++++.+++++++++++++++++++++++.------------------------------------------- 29 | ----------------------------------------------.+++++++++++++++++++++++++++++ 30 | ++++++.+++++++++++++++++++++++++++++++++++++++++.---.---..+++++++++.+++.---- 31 | ----------.----------------------------------------------------------------- 32 | ---.+++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++ 33 | ++++++++.---.------.-------------------------------------------------------- 34 | --------------.++++++++++++++++++++++++++++.++++++++++++++++++++++++++++++++ 35 | ++++++++++++.++++++++++++..----.-------------------------------------------- 36 | ----------.-----------..++++++++++++++++++++++++++++++++++++++++++++++++++++ 37 | ++++++++++++++++++++...----------------------------------------------------- 38 | --------------------.+++++++++++++++++++++++++++++++++++++++++++++++++++++.+ 39 | ++++++++.---.---..+++++++++.+++.--------------.----------------------------- 40 | -------------------------.++++++++++++++++++++++++++++++++++++++++++++++++++ 41 | +.+++++++++++++++++++.------------------------------------------------------ 42 | ---------------.+++++++++++++++++++++++++++++++++++++++++++++++++++.++++.--- 43 | .+++++++++++++.+++++.------------------------------------------------------- 44 | ---------------.+++++++++++++++.[-]>[-]+++++++++>[-]+++>>[-]>[-]<<<<<[->>>>> 45 | +<<<<<]>>>>>[-<+<<<<+>>>>>][-]++++++++++<<[-]>>>[-]>[-]<<<[->>>+<<<]>>>[[-<< 46 | <+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<->->[-]>[-]<<<[->>>+<<<] 47 | >>>[[-<<<+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]<<[->>+<<]>>[[- 48 | <<+>>]<<<[-]+>>>][-]<[->+<]>[[-<+>]<<<[-]+>>>]<<<[>[-]++++++++++++++++++++++ 49 | +++++++++++++++++++++++>[-]<<<<<[->>>>>+<<<<<]>>>>>[[-<<<<<+>>>>>]<+++++++++ 50 | ++++++++++++++++++++++++++++++++++>]<<<[>>>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<< 51 | ->>>][-]++++++++++++++++>[-]++++++++++++++>>>>[-]>[-]<<<<<<<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[->>>+<<<]>>>[[-<<<+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+ 66 | >>]<]<[<<->->[-]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>> 67 | >]<<[-]+>>]<]<][-]<<[->>+<<]>>[[-<<+>>]<<<[-]>>>][-]<[->+<]>[[-<+>]<<<[-]>>> 68 | ]<<<[[-]<<<<----->>>>][-]<<<<<<<<<[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>[-<<<<<<<<< 69 | +>>>>>>->>>][-]+++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++ 70 | +++++++++++++++++++++++++++++++.>[-]>[-]<<<<<[->>>>>+<<<<<]>>>>>[-<+<<<<+>>> 71 | >>]>>>[-]>[-]<<<<<[->>>>>+<<<<<]>>>>>[-<+<<<<+>>>>>][-]++++++++++>[-]<<[>>>[ 72 | -]<<[->>+<<]>[-]>[-<<+>+>][-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[-> 73 | >>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<<->>->[-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<< 74 | +>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<]<<<]<<<[-]>>>>>>[-]<[->+<] 75 | >[[-<+>]>[-]<<<[->>>+<<<]>>>[-<<<+<<<<+>>>>>>>]<<[-<<<<<->>>>>]>]<<<[-]>[-]< 76 | <<<<[->>>>>+<<<<<]>>>>>[-<+<<<<+>>>>>][-]++++++++++<<<<<[-]>>>>[>>>[-]<<[->> 77 | +<<]>[-]>[-<<+>+>][-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]> 78 | >>[[-<<<+>>>]<<[-]+>>]<]<[<<<->>->[-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[ 79 | -]<<<[->>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]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-] 93 | +>>]<]<]<<<]<[-]>>>>[-]<[->+<]>[[-<+>]>[-]<<<[->>>+<<<]>>>[-<<<+<<+>>>>>]<<[ 94 | -<<<->>>]>]<<<[-]>[-]<<<<<[->>>>>+<<<<<]>>>>>[-<+<<<<+>>>>>][-]++++++++++<<< 95 | <<[-]>>>>[>>>[-]<<[->>+<<]>[-]>[-<<+>+>][-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+> 96 | >>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<<->>->[-]>[-]<<<<[->>>>+<< 97 | <<]>>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]+>[-]<<[- 98 | >>+<<]>>[[-<<+>>]<[-]>]<[[-]<<<<<<<+>>>>>>>]<<<][-]<[->+<]>>[-]+<[[-<+>]<+++ 99 | +++++++++++++++++++++++++++++++++++++++++++++.<+++++++++++++++++++++++++++++ 100 | +++++++++++++++++++.<++++++++++++++++++++++++++++++++++++++++++++++++.>>>>-< 101 | ]>[[-]>[-]<<<<[->>>>+<<<<]>>>>>[-]+<[[-<<<<+>>>>]<<<<+++++++++++++++++++++++ 102 | +++++++++++++++++++++++++.<++++++++++++++++++++++++++++++++++++++++++++++++. 103 | >>>>>>-<]>[[-]<<<<<<++++++++++++++++++++++++++++++++++++++++++++++++.>>>>>>] 104 | <<]<<<<<<--------------------------------.>[-]>[-]<<<<<<[->>>>>>+<<<<<<]>>>> 105 | >>[-<+<<<<<+>>>>>>]>>>[-]>[-]<<<<<[->>>>>+<<<<<]>>>>>[-<+<<<<+>>>>>][-]+++++ 106 | +++++>[-]<<[>>>[-]<<[->>+<<]>[-]>[-<<+>+>][-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<< 107 | +>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<<->>->[-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>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<<->>->[-]>[-]<<<<[ 122 | ->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]+ 123 | >[-]<<[->>+<<]>>[[-<<+>>]<[-]>]<[[-]<<<<<<<+>>>>>>>]<<<][-]>[-]<<<<<[->>>>>+ 124 | <<<<<]>>>>>[-<+<<<<+>>>>>][-]++++++++++>[-]<<[>>>[-]<<[->>+<<]>[-]>[-<<+>+>] 125 | [-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-] 126 | +>>]<]<[<<<->>->[-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>> 127 | [[-<<<+>>>]<<[-]+>>]<]<]<<<]<[-]>>>>[-]<[->+<]>[[-<+>]>[-]<<<[->>>+<<<]>>>[- 128 | <<<+<<+>>>>>]<<[-<<<->>>]>]<<<[-]>[-]<<<<<[->>>>>+<<<<<]>>>>>[-<+<<<<+>>>>>] 129 | [-]++++++++++<<<<<[-]>>>>[>>>[-]<<[->>+<<]>[-]>[-<<+>+>][-]>[-]<<<<[->>>>+<< 130 | <<]>>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<<->>->[-]> 131 | [-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>] 132 | <]<][-]+>[-]<<[->>+<<]>>[[-<<+>>]<[-]>]<[[-]<<<<<<<+>>>>>>>]<<<][-]<[->+<]>> 133 | [-]+<[[-<+>]<++++++++++++++++++++++++++++++++++++++++++++++++.<+++++++++++++ 134 | +++++++++++++++++++++++++++++++++++.<+++++++++++++++++++++++++++++++++++++++ 135 | +++++++++.>>>>-<]>[[-]>[-]<<<<[->>>>+<<<<]>>>>>[-]+<[[-<<<<+>>>>]<<<<+++++++ 136 | +++++++++++++++++++++++++++++++++++++++++.<+++++++++++++++++++++++++++++++++ 137 | +++++++++++++++.>>>>>>-<]>[[-]<<<<<<++++++++++++++++++++++++++++++++++++++++ 138 | ++++++++.>>>>>>]<<]<<<<<<+++++++++++++.>[-]>[-]<<<<<<<[->>>>>>>+<<<<<<<]>>>> 139 | >>>[-<+<<<<<<+>>>>>>>][-]+++++++++++++++++++++++++++++++++++++++++++++++++++ 140 | +++++++++++++++++++++++++++++++++++++<<[-]+>>>[-]>[-]<<<[->>>+<<<]>>>[[-<<<+ 141 | >>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<->->[-]>[-]<<<[->>>+<<<]>> 142 | >[[-<<<+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]<<[->>+<<]>>[[-<< 143 | +>>]<<<[-]>>>][-]<[->+<]>[[-<+>]<<<[-]>>>]<<[-]+<[[-]>>[-]++++++++++++++++++ 144 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 145 | ++++++++++++++++++++++++++.<-<]>[[-]<<<<<<.>>>>>>]<[-]<<<<<<<<[->>>>>>>>+<<< 146 | <<<<<]>>>>>>[-]>>[-<<<<<<<<+>>>>>>+>>][-]<<[->>+<<]>>[[-<<+>>]<<->>]<<[<<<.. 147 | >>>-]<<<.>>>>>[-]<<<<<<<<[->>>>>>>>+<<<<<<<<]>>>>>>[-]>>[-<<<<<<<<+>>>>>>+>> 148 | ][-]<<[->>+<<]>>[[-<<+>>]<<->>]<<[<<<..>>>-]>>>[-]>[-]<<<<<<<[->>>>>>>+<<<<< 149 | <<]>>>>>>>[-<+<<<<<<+>>>>>>>][-]++++++++++++++++++++++++++++++++++++++++++++ 150 | ++++++++++++++++++++++++++++++++++++++++++++<<[-]+>>>[-]>[-]<<<[->>>+<<<]>>> 151 | [[-<<<+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<->->[-]>[-]<<<[->>> 152 | +<<<]>>>[[-<<<+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]<<[->>+<<] 153 | >>[[-<<+>>]<<<[-]>>>][-]<[->+<]>[[-<+>]<<<[-]>>>]<<[-]+<[[-]>>[-]+++++++++++ 154 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 155 | +++++++++++++++++++++++++++++++++.<-<]>[[-]<<<<<<.>>>>>>]<<<<<<<<]>>>[-]<<<< 156 | <[->>>>>+<<<<<]>>>>>[[-<<<<<+>>>>>]<<<<<<<[-]<[-]<[-]>>>>>>>>>>[-]<<<<<[->>> 157 | >>+<<<<<]>>>>>[-<<<<<+<<<+>>>>>>>>][-]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 158 | <<<<<<<<<<[->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<< 159 | <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 160 | >>>>>>[-<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>> 161 | >>>>>>>>>>>>>>>>>>>>+>>>>>>>>>]<<<<<<<<<[<<<[-]<[-]<[-]+>>>>>>[<<<<+>>>>-]<- 162 | [<<<<+>>>>-]<<<<]<<[-]>>>[<<<+>>>-]<<[>>>>]><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 163 | <<<<<<<+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[-]<<<<<[->>>>>+<<<< 164 | <]>>>>>[[-<<<<<+>>>>>]<<<<<->>>>>]<]<<<<<+>>[-]+>>[-]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>][-]<<<<<<<<[->>>>>>>>+<<<<<<<<]>>> 450 | >[-]>>>>[-<<<<<<<<+>>>>+>>>>]<<<[-]++++++++++++++++++++++++++++++++>>-<]>[[- 451 | ]>[-]<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<]>>>>>>>>>>>[-]>>>>> 452 | [-<<<<<<<<<<<<<<<<+>>>>>>>>>>>+>>>>>][-]<<<<<<<[->>>>>>>+<<<<<<<]>>>[-]>>>>[ 453 | -<<<<<<<+>>>+>>>>]<<<[-]++++++++++++++++++++++++++++++++++++++++++++++++++++ 454 | ++++++++++++++++++++++++++++++++++++>>]<[-]++++++++++++++++>[-]+++++++++++++ 455 | +>>>>[-]>[-]<<<<<<<<<[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>[-<+<<<<<<<<+>>>>>>>>>][ 456 | -]<<[-]+>>>[-]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>] 457 | <<[-]+>>]<]<[<<->->[-]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]>[-]<<<[->>>+<<<]>>>[[- 458 | <<<+>>>]<<[-]+>>]<]<][-]<<[->>+<<]>>[[-<<+>>]<<<[-]>>>][-]<[->+<]>[[-<+>]<<< 459 | [-]>>>]<<<[[-]<<<<+++++>>>>]>[-]>[-]<<<<<<<<<[->>>>>>>>>+<<<<<<<<<]>>>>>>>>> 460 | [-<+<<<<<<<<+>>>>>>>>>][-]+<<[-]+>>>[-]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]>[-]<< 461 | <[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<->->[-]>[-]<<<[->>>+<<<]>>>[[-<<<+>> 462 | >]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]<<[->>+<<]>>[[-<<+>>]<<<[-] 463 | >>>][-]<[->+<]>[[-<+>]<<<[-]>>>]<<<[[-]<<<++++++++++>>>][-]>[-]<<<<<<<<[->>> 464 | >>>>>+<<<<<<<<]>>>>>>>>[-<+<<<<<<<+>>>>>>>>][-]+++++++++++++++++++++++++<<<[ 465 | -]>>[>>[-]<[->+<]>[-<+<<<+>>>>]<<-][-]<<[->>+<<]>>[-<<+<<+>>>>][-]<<<<<<<<<< 466 | <[->>>>>>>>>>>+<<<<<<<<<<<]>>>>>>>>>>>[-<<<<<<<<<<<+>>>>>>>->>>>][-]<<<<<<<< 467 | <<<[->>>>>>>>>>>+<<<<<<<<<<<]>>>>>>>>>>>[-<<<<<<<<<<<+>>>>>>>->>>>]>[-]>[-]< 468 | <<<<<<<<[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>[-<+<<<<<<<<+>>>>>>>>>][-]++<<[-]+>>> 469 | [-]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<] 470 | <[<<->->[-]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[ 471 | -]+>>]<]<][-]<<[->>+<<]>>[[-<<+>>]<<<[-]>>>][-]<[->+<]>[[-<+>]<<<[-]>>>]<<<[ 472 | [-]<<<<----->>>>][-]<<<<<<[->>>>>>+<<<<<<]>>>>>>[-<<<<<<+>>>->>>][-]++++++++ 473 | +++++++++++++++++++.++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 474 | ++++++++.>[-]>[-]<<<<<[->>>>>+<<<<<]>>>>>[-<+<<<<+>>>>>]>>>[-]>[-]<<<<<[->>> 475 | >>+<<<<<]>>>>>[-<+<<<<+>>>>>][-]++++++++++>[-]<<[>>>[-]<<[->>+<<]>[-]>[-<<+> 476 | +>][-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<< 477 | [-]+>>]<]<[<<<->>->[-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<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>]<<[-]+>>]<]<[<<<->>->[-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[->> 492 | >+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]+>[-]<<[->>+<<]>>[[-<<+>>]<[-]>]<[[-]<<< 493 | <<<<+>>>>>>>]<<<][-]>[-]<<<<<[->>>>>+<<<<<]>>>>>[-<+<<<<+>>>>>][-]++++++++++ 494 | >[-]<<[>>>[-]<<[->>+<<]>[-]>[-<<+>+>][-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>> 495 | ]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<<->>->[-]>[-]<<<<[->>>>+<<<<] 496 | >>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<]<<<]<[-]>>>>[-] 497 | <[->+<]>[[-<+>]>[-]<<<[->>>+<<<]>>>[-<<<+<<+>>>>>]<<[-<<<->>>]>]<<<[-]>[-]<< 498 | <<<[->>>>>+<<<<<]>>>>>[-<+<<<<+>>>>>][-]++++++++++<<<<<[-]>>>>[>>>[-]<<[->>+ 499 | <<]>[-]>[-<<+>+>][-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>> 500 | >[[-<<<+>>>]<<[-]+>>]<]<[<<<->>->[-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[- 501 | ]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]+>[-]<<[->>+<<]>>[[-<<+>>]<[-]>] 502 | <[[-]<<<<<<<+>>>>>>>]<<<][-]<[->+<]>>[-]+<[[-<+>]<++++++++++++++++++++++++++ 503 | ++++++++++++++++++++++.<++++++++++++++++++++++++++++++++++++++++++++++++.<++ 504 | ++++++++++++++++++++++++++++++++++++++++++++++.>>>>-<]>[[-]>[-]<<<<[->>>>+<< 505 | <<]>>>>>[-]+<[[-<<<<+>>>>]<<<<++++++++++++++++++++++++++++++++++++++++++++++ 506 | ++.<++++++++++++++++++++++++++++++++++++++++++++++++.>>>>>>-<]>[[-]<<<<<<+++ 507 | +++++++++++++++++++++++++++++++++++++++++++++.>>>>>>]<<]<<<<<<-------------- 508 | ------------------.>[-]>[-]<<<<<<[->>>>>>+<<<<<<]>>>>>>[-<+<<<<<+>>>>>>]>>>[ 509 | -]>[-]<<<<<[->>>>>+<<<<<]>>>>>[-<+<<<<+>>>>>][-]++++++++++>[-]<<[>>>[-]<<[-> 510 | >+<<]>[-]>[-<<+>+>][-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<] 511 | >>>[[-<<<+>>>]<<[-]+>>]<]<[<<<->>->[-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]> 512 | [-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<]<<<]<<<[-]>>>>>>[-]<[->+<]>[[-<+> 513 | ]>[-]<<<[->>>+<<<]>>>[-<<<+<<<<+>>>>>>>]<<[-<<<<<->>>>>]>]<<<[-]>[-]<<<<<[-> 514 | >>>>+<<<<<]>>>>>[-<+<<<<+>>>>>][-]++++++++++<<<<<[-]>>>>[>>>[-]<<[->>+<<]>[- 515 | ]>[-<<+>+>][-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<< 516 | <+>>>]<<[-]+>>]<]<[<<<->>->[-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[- 517 | >>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]+>[-]<<[->>+<<]>>[[-<<+>>]<[-]>]<[[-]< 518 | <<<<<<+>>>>>>>]<<<][-]>[-]<<<<<[->>>>>+<<<<<]>>>>>[-<+<<<<+>>>>>][-]++++++++ 519 | ++>[-]<<[>>>[-]<<[->>+<<]>[-]>[-<<+>+>][-]>[-]<<<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>[>>>[-]<<[->>+<<]>[-]>[-<<+>+>][-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[- 534 | ]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<<->>->[-]>[-]<<<<[->>>>+<<<<]>>>> 535 | [[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]+>[-]<<[->>+<<]> 536 | >[[-<<+>>]<[-]>]<[[-]<<<<<<<+>>>>>>>]<<<][-]<[->+<]>>[-]+<[[-<+>]<++++++++++ 537 | ++++++++++++++++++++++++++++++++++++++.<++++++++++++++++++++++++++++++++++++ 538 | ++++++++++++.<++++++++++++++++++++++++++++++++++++++++++++++++.>>>>-<]>[[-]> 539 | [-]<<<<[->>>>+<<<<]>>>>>[-]+<[[-<<<<+>>>>]<<<<++++++++++++++++++++++++++++++ 540 | ++++++++++++++++++.<++++++++++++++++++++++++++++++++++++++++++++++++.>>>>>>- 541 | <]>[[-]<<<<<<++++++++++++++++++++++++++++++++++++++++++++++++.>>>>>>]<<]<<<< 542 | <<+++++++++++++.>[-]>[-]<<<<<<<[->>>>>>>+<<<<<<<]>>>>>>>[-<+<<<<<<+>>>>>>>][ 543 | -]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 544 | ++++++++++++++<<[-]+>>>[-]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]>[-]<<<[->>>+<<<]>> 545 | >[[-<<<+>>>]<<[-]+>>]<]<[<<->->[-]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]>[-]<<<[->> 546 | >+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]<<[->>+<<]>>[[-<<+>>]<<<[-]>>>][-]<[->+< 547 | ]>[[-<+>]<<<[-]>>>]<<[-]+<[[-]>>[-]+++++++++++++++++++++++++++++++++++++++++ 548 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 549 | +++.<-<]>[[-]<<<<<<.>>>>>>]<[-]<<<<<<<<<<<[->>>>>>>>>>>+<<<<<<<<<<<]>>>>>>>> 550 | >[-]>>[-<<<<<<<<<<<+>>>>>>>>>+>>][-]<<[->>+<<]>>[[-<<+>>]<<->>]<<[<<<..>>>-] 551 | <<<.>>>>>[-]<<<<<<<<<<<[->>>>>>>>>>>+<<<<<<<<<<<]>>>>>>>>>[-]>>[-<<<<<<<<<<< 552 | +>>>>>>>>>+>>][-]<<[->>+<<]>>[[-<<+>>]<<->>]<<[<<<..>>>-]>>>[-]>[-]<<<<<<<[- 553 | >>>>>>>+<<<<<<<]>>>>>>>[-<+<<<<<<+>>>>>>>][-]+++++++++++++++++++++++++++++++ 554 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++<<[-]+>>>[-]>[-]<<< 555 | [->>>+<<<]>>>[[-<<<+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<->->[- 556 | ]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<] 557 | [-]<<[->>+<<]>>[[-<<+>>]<<<[-]>>>][-]<[->+<]>[[-<+>]<<<[-]>>>]<<[-]+<[[-]>>[ 558 | -]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 559 | ++++++++++++++++++++++++++++++++++++++++++++++.<-<]>[[-]<<<<<<.>>>>>>]<<<<<< 560 | <<<]>[-]++++++++++.[-]+>[-]+>[-]+++++++++++++++++++++++++++.++++++++++++++++ 561 | ++++++++++++++++++++++++++++++++++++++++++++++++.>[-]>[-]<<<[->>>+<<<]>>>[-< 562 | +<<+>>>]>>>[-]>[-]<<<<<[->>>>>+<<<<<]>>>>>[-<+<<<<+>>>>>][-]++++++++++>[-]<< 563 | [>>>[-]<<[->>+<<]>[-]>[-<<+>+>][-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]< 564 | <<[->>>+<<<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>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>> 578 | ]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<<->>->[-]>[-]<<<<[->>>>+<<<<] 579 | >>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]+>[-]<<[->>+ 580 | <<]>>[[-<<+>>]<[-]>]<[[-]<<<<<<<+>>>>>>>]<<<][-]>[-]<<<<<[->>>>>+<<<<<]>>>>> 581 | [-<+<<<<+>>>>>][-]++++++++++>[-]<<[>>>[-]<<[->>+<<]>[-]>[-<<+>+>][-]>[-]<<<< 582 | [->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<< 583 | ->>->[-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>] 584 | <<[-]+>>]<]<]<<<]<[-]>>>>[-]<[->+<]>[[-<+>]>[-]<<<[->>>+<<<]>>>[-<<<+<<+>>>> 585 | >]<<[-<<<->>>]>]<<<[-]>[-]<<<<<[->>>>>+<<<<<]>>>>>[-<+<<<<+>>>>>][-]++++++++ 586 | ++<<<<<[-]>>>>[>>>[-]<<[->>+<<]>[-]>[-<<+>+>][-]>[-]<<<<[->>>>+<<<<]>>>>[[-< 587 | <<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<<->>->[-]>[-]<<<<[->> 588 | >>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]+>[- 589 | ]<<[->>+<<]>>[[-<<+>>]<[-]>]<[[-]<<<<<<<+>>>>>>>]<<<][-]<[->+<]>>[-]+<[[-<+> 590 | ]<++++++++++++++++++++++++++++++++++++++++++++++++.<++++++++++++++++++++++++ 591 | ++++++++++++++++++++++++.<++++++++++++++++++++++++++++++++++++++++++++++++.> 592 | >>>-<]>[[-]>[-]<<<<[->>>>+<<<<]>>>>>[-]+<[[-<<<<+>>>>]<<<<++++++++++++++++++ 593 | ++++++++++++++++++++++++++++++.<++++++++++++++++++++++++++++++++++++++++++++ 594 | ++++.>>>>>>-<]>[[-]<<<<<<++++++++++++++++++++++++++++++++++++++++++++++++.>> 595 | >>>>]<<]<<<<<<--------------------------------.>[-]>[-]<<<<[->>>>+<<<<]>>>>[ 596 | -<+<<<+>>>>]>>>[-]>[-]<<<<<[->>>>>+<<<<<]>>>>>[-<+<<<<+>>>>>][-]++++++++++>[ 597 | -]<<[>>>[-]<<[->>+<<]>[-]>[-<<+>+>][-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]> 598 | [-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<<->>->[-]>[-]<<<<[->>>>+<<<<]>> 599 | >>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<]<<<]<<<[-]>>>>>>[ 600 | -]<[->+<]>[[-<+>]>[-]<<<[->>>+<<<]>>>[-<<<+<<<<+>>>>>>>]<<[-<<<<<->>>>>]>]<< 601 | <[-]>[-]<<<<<[->>>>>+<<<<<]>>>>>[-<+<<<<+>>>>>][-]++++++++++<<<<<[-]>>>>[>>> 602 | [-]<<[->>+<<]>[-]>[-<<+>+>][-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[- 603 | >>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<<->>->[-]>[-]<<<<[->>>>+<<<<]>>>>[[-<<< 604 | <+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]+>[-]<<[->>+<<]>>[[-<< 605 | +>>]<[-]>]<[[-]<<<<<<<+>>>>>>>]<<<][-]>[-]<<<<<[->>>>>+<<<<<]>>>>>[-<+<<<<+> 606 | >>>>][-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->>>>>+<<<<<]>>>>>[-<+<<<<+>>>>>][-]++++ 620 | ++++++<<<<<[-]>>>>[>>>[-]<<[->>+<<]>[-]>[-<<+>+>][-]>[-]<<<<[->>>>+<<<<]>>>> 621 | [[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<<->>->[-]>[-]<<<< 622 | [->>>>+<<<<]>>>>[[-<<<<+>>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-] 623 | +>[-]<<[->>+<<]>>[[-<<+>>]<[-]>]<[[-]<<<<<<<+>>>>>>>]<<<][-]<[->+<]>>[-]+<[[ 624 | -<+>]<++++++++++++++++++++++++++++++++++++++++++++++++.<++++++++++++++++++++ 625 | ++++++++++++++++++++++++++++.<++++++++++++++++++++++++++++++++++++++++++++++ 626 | ++.>>>>-<]>[[-]>[-]<<<<[->>>>+<<<<]>>>>>[-]+<[[-<<<<+>>>>]<<<<++++++++++++++ 627 | ++++++++++++++++++++++++++++++++++.<++++++++++++++++++++++++++++++++++++++++ 628 | ++++++++.>>>>>>-<]>[[-]<<<<<<+++++++++++++++++++++++++++++++++++++++++++++++ 629 | +.>>>>>>]<<]<<<<<<+++++++++++++.<<[-]+++++++++++++++++++++++++++++++++++++++ 630 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 631 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 632 | +++++++++[>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 633 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 634 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[>[-]+++++++++ 635 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 636 | +++++++++++++++[-]<-]<-]<<<<<]<<<<+>>>>[-]>[-]<<<<<[->>>>>+<<<<<]>>>>>[-<+<< 637 | <<+>>>>>][-]++++<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<<<<<<< 702 | <<<]>>>>>>>>>>>[-<+<<<<<<<<<<+>>>>>>>>>>>]<<<[-]>>>[-]>[-]<<<[->>>+<<<]>>>[[ 703 | -<<<+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<->->[-]>[-]<<<[->>>+< 704 | <<]>>>[[-<<<+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]<[->+<]>[[-< 705 | +>]<<<[-]+>>>]<<<[<<<<<<<<--->+>>>>>>>>[-]++>[-]>[-]<<<<<<<<<<<[->>>>>>>>>>> 706 | +<<<<<<<<<<<]>>>>>>>>>>>[-<+<<<<<<<<<<+>>>>>>>>>>>]<<<[-]>>>[-]>[-]<<<[->>>+ 707 | <<<]>>>[[-<<<+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<[<<->->[-]>[-]< 708 | <<[->>>+<<<]>>>[[-<<<+>>>]>[-]<<<[->>>+<<<]>>>[[-<<<+>>>]<<[-]+>>]<]<][-]<[- 709 | >+<]>[[-<+>]<<<[-]+>>>]<<<]<<<<+>>>]<<]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 710 | -------------------------------------------------------------------------------- /examples/long.bf: -------------------------------------------------------------------------------- 1 | >+>+>+>+>++<[>[<+++>- 2 | 3 | >>>>> 4 | >+>+>+>+>++<[>[<+++>- 5 | 6 | >>>>> 7 | >+>+>+>+>++<[>[<+++>- 8 | 9 | >>>>> 10 | >+>+>+>+>++<[>[<+++>- 11 | 12 | >>>>> 13 | +++[->+++++<]>[-]< 14 | <<<<< 15 | 16 | ]<<]>[-] 17 | <<<<< 18 | 19 | ]<<]>[-] 20 | <<<<< 21 | 22 | ]<<]>[-] 23 | <<<<< 24 | 25 | ]<<]>. 26 | -------------------------------------------------------------------------------- /examples/mandelbrot.bf: -------------------------------------------------------------------------------- 1 | A mandelbrot set fractal viewer in brainfuck written by Erik Bosman 2 | +++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>>>->>[-<<<<<<<<+>>>>>>>>]<<<<<<<<[->>>>>>>>+<<<<<<<<<<<<<<<<<[<<<<<<< 141 | <<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>> 142 | -<<[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>> 143 | >>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>[-]<<<++++ 144 | +[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>-<<<<<<[<<<< 145 | <<<<<]]>>>] 146 | -------------------------------------------------------------------------------- /examples/oobrain.bf: -------------------------------------------------------------------------------- 1 | %% 2 | %% (C) 2003 Chris Rathman 3 | %% 4 | 5 | %% reserve some space for a stack (note: each stack entry takes two cells ~ value and a walk byte) 6 | >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> 7 | >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> 8 | >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> 9 | 10 | %% 11 | %% Object Definition: 12 | %% 13 | %% < object# > 14 | %% << function#/step# >> 15 | %% <<< class# >>> 16 | %% <<<< slot#1 (main!shape(0) | circle!x | rectangle!x) >>>> 17 | %% <<<<< slot#2 (main!shape(1) | circle!y | rectangle!y) >>>>> 18 | %% <<<<<< slot#3 (main!rect | circle!radius | rectangle!width) >>>>>> 19 | %% <<<<<<< slot#4 ( | | rectangle!height) >>>>>>> 20 | %% <<<<<<<< slot#5 >>>>>>>> 21 | %% <<<<<<<<< reserved >>>>>>>>> 22 | %% <<<<<<<<<<<<<<<<<<<< object length >>>>>>>>>>>>>>>>>>>> 23 | %% 24 | 25 | %% auto-allocate main root object 26 | >>>>>>>>>>>> 9~20 %% workspace (for previous object) 27 | [-]> 8 %% slot#5 28 | [-]> 7 %% slot#4 29 | [-]> 6 %% slot#3 30 | [-]> 5 %% slot#2 31 | [-]> 4 %% slot#1 32 | [-]> 3 %% class# 33 | [-]> 2 %% function#/step# 34 | [-]> 1 %% object# 35 | 36 | %% stack push step#1 for main object 37 | <<<<<<<<<<<<<<<<<<<< [<<]+<+>[>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push step# 38 | <<<<<<<<<<<<<<<<<<<< [<<]+<> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push object# 39 | 40 | <<<<<<<<<<<<<<<<<<<< <<[>> >>>>>>>>>>>>>>>>>>>> %% while stack do 41 | 42 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull next object# 43 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 44 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 45 | 46 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull next function#/step# 47 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 48 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 49 | [ %% walk to next object#n 50 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 51 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 52 | >>>>>>>>>>>>>>>>>>>> 53 | -] 54 | 55 | <<[-]>> >[<< <+> >>-]< %% set function#/step# for the object 56 | 57 | 58 | ================================================================================================ 59 | = main process = 60 | ================================================================================================ 61 | [-]<<<[>>>+>+<<< <-]>>> >[<<< <+> >>>-]< %% get class# 62 | >[-] [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (class#0) 63 | 64 | %% set to return to the next step# after continue 65 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< + %% get step# 66 | <<<<<<<<<<<<<<<<<<<< [<<]+<++++> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push step# 67 | <<<<<<<<<<<<<<<<<<<< [<<]+<[-]> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack mark spot for step# 68 | [<<<<<<<<<<<<<<<<<<<< [<<]>+> [>>]<< >>>>>>>>>>>>>>>>>>>>-] %% stack push step# 69 | <<<<<<<<<<<<<<<<<<<< [<<]+<[-]> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push object# 70 | 71 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 72 | % step#1 new shape() % 73 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 74 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 75 | >[-]+ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#1) 76 | 77 | %% allocate a new object in the heap 78 | <[<<<<<<<<<<<<<<<<<<<<]> %% walk back to root object 79 | >>>>>>>>>>>>>>>>>>>> %% skip over first object 80 | <[> %% find free space in the heap 81 | [-]<[>+>+< <-]> >[< <+> >-]< %% get object# 82 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<<-] 83 | >>>>>>>>>>>>>>>>>>>> 84 | <]> 85 | <[-]+ >[<+>-]<> %% object#n 86 | <<<[-]+>>> %% class# rectangle 87 | [-]<[>+>+< <-]> >[< <+> >-]< %% get new object# 88 | <[ %% walk back to root object 89 | >[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< 90 | <<<<<<<<<<<<<<<<<<<< 91 | ]> 92 | 93 | %% set local slot# for shape(0) 94 | [<<<< + >>>> -] %% set slot# shape(0) 95 | 96 | %% make a function call: shape(0) = new rectangle(x y width height) 97 | <<<<[>>>>+>+<<<< <-]>>>> >[<<<< <+> >>>>-]< %% get shape(0) from slot 98 | <<<<<<<<<<<<<<<<<<<< [<<]+ %% stack push param# height = 6 99 | <++++++> 100 | [>>]<< >>>>>>>>>>>>>>>>>>>> 101 | <<<<<<<<<<<<<<<<<<<< [<<]+ %% stack push param# width = 5 102 | <+++++> 103 | [>>]<< >>>>>>>>>>>>>>>>>>>> 104 | <<<<<<<<<<<<<<<<<<<< [<<]+ %% stack push param# y = 20 105 | <++++++++++++++++++++> 106 | [>>]<< >>>>>>>>>>>>>>>>>>>> 107 | <<<<<<<<<<<<<<<<<<<< [<<]+ %% stack push param# x = 10 108 | <++++++++++> 109 | [>>]<< >>>>>>>>>>>>>>>>>>>> 110 | <<<<<<<<<<<<<<<<<<<< [<<]+<+> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push function# rectangle 111 | <<<<<<<<<<<<<<<<<<<< [<<]+<[-]> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack mark spot for object# 112 | [<<<<<<<<<<<<<<<<<<<< [<<]>+> [>>]<< >>>>>>>>>>>>>>>>>>>>-] %% stack push object# shape(0) 113 | 114 | %% allocate a new object in the heap 115 | <[<<<<<<<<<<<<<<<<<<<<]> %% walk back to root object 116 | >>>>>>>>>>>>>>>>>>>> %% skip over first object 117 | <[> %% find free space in the heap 118 | [-]<[>+>+< <-]> >[< <+> >-]< %% get object# 119 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<<-] 120 | >>>>>>>>>>>>>>>>>>>> 121 | <]> 122 | <[-]+ >[<+>-]<> %% object#n 123 | <<<[-]++>>> %% class# 124 | [-]<[>+>+< <-]> >[< <+> >-]< %% get new object# 125 | <[ %% walk back to root object 126 | >[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< 127 | <<<<<<<<<<<<<<<<<<<< 128 | ]> 129 | 130 | %% set local slot# for shape(1) 131 | [<<<<< + >>>>> -] %% set slot# shape(1) 132 | 133 | %% make a function call: shape(1) = new circle(x y radius) 134 | <<<<<[>>>>>+>+<<<<< <-]>>>>> >[<<<<< <+> >>>>>-]< %% get shape(1) from slot 135 | <<<<<<<<<<<<<<<<<<<< [<<]+ %% stack push param# radius = 8 136 | <++++++++> 137 | [>>]<< >>>>>>>>>>>>>>>>>>>> 138 | <<<<<<<<<<<<<<<<<<<< [<<]+ %% stack push param# y = 25 139 | <+++++++++++++++++++++++++> 140 | [>>]<< >>>>>>>>>>>>>>>>>>>> 141 | <<<<<<<<<<<<<<<<<<<< [<<]+ %% stack push param# x = 15 142 | <+++++++++++++++> 143 | [>>]<< >>>>>>>>>>>>>>>>>>>> 144 | <<<<<<<<<<<<<<<<<<<< [<<]+<+> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push function# circle 145 | <<<<<<<<<<<<<<<<<<<< [<<]+<[-]> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack mark spot for object# 146 | [<<<<<<<<<<<<<<<<<<<< [<<]>+> [>>]<< >>>>>>>>>>>>>>>>>>>>-] %% stack push object# shape(1) 147 | >]< %% END IF (function#1) 148 | 149 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 150 | % step#2 shape!draw() % 151 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 152 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 153 | >[-]++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#2) 154 | %% get the two shapes to process 155 | <<<<[>>>>+>+<<<< <-]>>>> >[<<<< <+> >>>>-]< %% get shape(0) from slot 156 | [>>>>+<<<<-] %% push shape(0) in the workspace 157 | <<<<<[>>>>>+>+<<<<< <-]>>>>> >[<<<<< <+> >>>>>-]< %% get shape(1) from slot 158 | [>>>>>+<<<<<-] %% push shape(1) in the workspace 159 | 160 | %% make a function call: shape(i)!draw() 161 | >>>++[-<<< %% for i = 1 downto 0 162 | >>>>[<<<<+>>>>-]<<<< %% get next shape to process 163 | <<<<<<<<<<<<<<<<<<<< [<<]+<++++> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push function# draw 164 | <<<<<<<<<<<<<<<<<<<< [<<]+<[-]> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack mark spot for object# 165 | [<<<<<<<<<<<<<<<<<<<< [<<]>+> [>>]<< >>>>>>>>>>>>>>>>>>>>-] %% stack push object# shape(0) 166 | >>>>>[<+>-]<<<<< %% pull down next shape 167 | >>>]<<< 168 | >]< %% END IF (function#1) 169 | 170 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 171 | % step#3 shape!rMoveTo() % 172 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 173 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 174 | >[-]+++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#3) 175 | %% get the two shapes to process 176 | <<<<[>>>>+>+<<<< <-]>>>> >[<<<< <+> >>>>-]< %% get shape(0) from slot 177 | [>>>>+<<<<-] %% push shape(0) in the workspace 178 | <<<<<[>>>>>+>+<<<<< <-]>>>>> >[<<<<< <+> >>>>>-]< %% get shape(1) from slot 179 | [>>>>>+<<<<<-] %% push shape(1) in the workspace 180 | 181 | %% make a function call: shape(i)!rMoveTo(100) 182 | >>>++[-<<< %% for i = 1 downto 0 183 | >>>>[<<<<+>>>>-]<<<< %% get next shape to process 184 | <<<<<<<<<<<<<<<<<<<< [<<] %% stack push param# dy = 100 185 | <++++[>+++++<-]>[<+++++>-]<>+ 186 | [>>]<< >>>>>>>>>>>>>>>>>>>> 187 | <<<<<<<<<<<<<<<<<<<< [<<] %% stack push param# dx = 100 188 | <++++[>+++++<-]>[<+++++>-]<>+ 189 | [>>]<< >>>>>>>>>>>>>>>>>>>> 190 | <<<<<<<<<<<<<<<<<<<< [<<]+<+++> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push function# rmoveto 191 | <<<<<<<<<<<<<<<<<<<< [<<]+<[-]> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack mark spot for object# 192 | [<<<<<<<<<<<<<<<<<<<< [<<]>+> [>>]<< >>>>>>>>>>>>>>>>>>>>-] %% stack push object# shape(0) 193 | >>>>>[<+>-]<<<<< %% pull down next shape 194 | >>>]<<< 195 | >]< %% END IF (function#1) 196 | 197 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 198 | % step#4 shape!draw() % 199 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 200 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 201 | >[-]++++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#4) 202 | %% get the two shapes to process 203 | <<<<[>>>>+>+<<<< <-]>>>> >[<<<< <+> >>>>-]< %% get shape(0) from slot 204 | [>>>>+<<<<-] %% push shape(0) in the workspace 205 | <<<<<[>>>>>+>+<<<<< <-]>>>>> >[<<<<< <+> >>>>>-]< %% get shape(1) from slot 206 | [>>>>>+<<<<<-] %% push shape(1) in the workspace 207 | 208 | %% make a function call: shape(i)!draw() 209 | >>>++[-<<< %% for i = 1 downto 0 210 | >>>>[<<<<+>>>>-]<<<< %% get next shape to process 211 | <<<<<<<<<<<<<<<<<<<< [<<]+<++++> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push function# draw 212 | <<<<<<<<<<<<<<<<<<<< [<<]+<[-]> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack mark spot for object# 213 | [<<<<<<<<<<<<<<<<<<<< [<<]>+> [>>]<< >>>>>>>>>>>>>>>>>>>>-] %% stack push object# shape(0) 214 | >>>>>[<+>-]<<<<< %% pull down next shape 215 | >>>]<<< 216 | >]< %% END IF (function#1) 217 | 218 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 219 | % step#5 new rect() % 220 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 221 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 222 | >[-]+++++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#5) 223 | 224 | %% allocate a new object in the heap 225 | <[<<<<<<<<<<<<<<<<<<<<]> %% walk back to root object 226 | >>>>>>>>>>>>>>>>>>>> %% skip over first object 227 | <[> %% find free space in the heap 228 | [-]<[>+>+< <-]> >[< <+> >-]< %% get object# 229 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<<-] 230 | >>>>>>>>>>>>>>>>>>>> 231 | <]> 232 | <[-]+ >[<+>-]<> %% object#n 233 | <<<[-]+>>> %% class# rectangle 234 | [-]<[>+>+< <-]> >[< <+> >-]< %% get new object# 235 | <[ %% walk back to root object 236 | >[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< 237 | <<<<<<<<<<<<<<<<<<<< 238 | ]> 239 | 240 | %% set local slot# for rect 241 | [<<<<<< + >>>>>> -] %% set slot# rect 242 | 243 | %% make a function call: rect = new rectangle(x y width height) 244 | <<<<<<[>>>>>>+>+<<<<<< <-]>>>>>> >[<<<<<< <+> >>>>>>-]< %% get rect from slot# 245 | <<<<<<<<<<<<<<<<<<<< [<<]+<+++++++++++++++>[>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push param# height=15 246 | <<<<<<<<<<<<<<<<<<<< [<<]+<+++++++++++++++>[>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push param# width=15 247 | <<<<<<<<<<<<<<<<<<<< [<<]+<> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push param# y=0 248 | <<<<<<<<<<<<<<<<<<<< [<<]+<> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push param# x=0 249 | <<<<<<<<<<<<<<<<<<<< [<<]+<+> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push function# circle 250 | <<<<<<<<<<<<<<<<<<<< [<<]+<[-]> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack mark spot for object# 251 | [<<<<<<<<<<<<<<<<<<<< [<<]>+> [>>]<< >>>>>>>>>>>>>>>>>>>>-] %% stack push object# rect 252 | >]< %% END IF (function#1) 253 | 254 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 255 | % step#6 rect!setWidth() % 256 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 257 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 258 | >[-]++++++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#6) 259 | %% make a function call: rect!setRadius(radius) 260 | <<<<<<[>>>>>>+>+<<<<<< <-]>>>>>> >[<<<<<< <+> >>>>>>-]< %% get rect from slot# 261 | <<<<<<<<<<<<<<<<<<<< [<<]+ %% stack push param# radius=30 262 | <++++++++++++++++++++++++++++++> 263 | [>>]<< >>>>>>>>>>>>>>>>>>>> 264 | <<<<<<<<<<<<<<<<<<<< [<<]+<+++++> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push function# setRadius=30 265 | <<<<<<<<<<<<<<<<<<<< [<<]+<[-]> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack mark spot for object# 266 | [<<<<<<<<<<<<<<<<<<<< [<<]>+> [>>]<< >>>>>>>>>>>>>>>>>>>>-] %% stack push object# rect 267 | >]< %% END IF (function#1) 268 | 269 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 270 | % step#7 rect!draw() % 271 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 272 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 273 | >[-]+++++++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#7) 274 | %% make a function call: rect!draw() 275 | <<<<<<[>>>>>>+>+<<<<<< <-]>>>>>> >[<<<<<< <+> >>>>>>-]< %% get shape(0) from slot 276 | <<<<<<<<<<<<<<<<<<<< [<<]+<++++> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack push function# draw 277 | <<<<<<<<<<<<<<<<<<<< [<<]+<[-]> [>>]<< >>>>>>>>>>>>>>>>>>>> %% stack mark spot for object# 278 | [<<<<<<<<<<<<<<<<<<<< [<<]>+> [>>]<< >>>>>>>>>>>>>>>>>>>>-] %% stack push object# rect 279 | >]< %% END IF (function#1) 280 | 281 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 282 | % step#8 exit() % 283 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 284 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 285 | >[-]++++++++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#8) 286 | <<<<<<<<<<<<<<<<<<<< <<[-]>> >>>>>>>>>>>>>>>>>>>> %% kill stack to exit 287 | >]< %% END IF (function#99) 288 | 289 | >]< %% END IF (class#0) 290 | 291 | 292 | 293 | ================================================================================================ 294 | = rectangle class = 295 | ================================================================================================ 296 | [-]<<<[>>>+>+<<< <-]>>> >[<<< <+> >>>-]< %% get class# 297 | >[-]+ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (class#1) 298 | 299 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 300 | % function#1 rectangle(x y width height) % 301 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 302 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 303 | >[-]+ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#1) 304 | %% clear the slots 305 | <<<<[-]>>>> %% x=0 306 | <<<<<[-]>>>>> %% y=0 307 | <<<<<<[-]>>>>>> %% width=0 308 | <<<<<<<[-]>>>>>>> %% height=0 309 | 310 | %% grab the x value from the stack 311 | <[>+>+< <-]> >[< <+> >-]< %% get object# 312 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 313 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# x 314 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 315 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 316 | [ %% walk to object#n (drag param# & object index) 317 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 318 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 319 | >>>>>>>>>>>>>>>>>>>> 320 | -] 321 | >[< <<<<+>>>> >-]< %% set slot# x 322 | 323 | %% grab the y value from the stack 324 | <[>+>+< <-]> >[< <+> >-]< %% get object# 325 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 326 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# y 327 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 328 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 329 | [ %% walk to object#n (drag param# & object index) 330 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 331 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 332 | >>>>>>>>>>>>>>>>>>>> 333 | -] 334 | >[< <<<<<+>>>>> >-]< %% set slot# y 335 | 336 | %% grab the width value from the stack 337 | <[>+>+< <-]> >[< <+> >-]< %% get object# 338 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 339 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# width 340 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 341 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 342 | [ %% walk to object#n (drag param# & object index) 343 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 344 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 345 | >>>>>>>>>>>>>>>>>>>> 346 | -] 347 | >[< <<<<<<+>>>>>> >-]< %% set slot# width 348 | 349 | %% grab the height value from the stack 350 | <[>+>+< <-]> >[< <+> >-]< %% get object# 351 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 352 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# height 353 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 354 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 355 | [ %% walk to object#n (drag param# & object index) 356 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 357 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 358 | >>>>>>>>>>>>>>>>>>>> 359 | -] 360 | >[< <<<<<<<+>>>>>>> >-]< %% set slot# height 361 | >]< %% END IF (function#1) 362 | 363 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 364 | % function#2 moveTo(x y) % 365 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 366 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 367 | >[-]++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#2) 368 | %% grab the x value from the stack 369 | <<<<[-]>>>> %% x=0 370 | <[>+>+< <-]> >[< <+> >-]< %% get object# 371 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 372 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# x 373 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 374 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 375 | [ %% walk to object#n (drag param# & object index) 376 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 377 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 378 | >>>>>>>>>>>>>>>>>>>> 379 | -] 380 | >[< <<<<+>>>> >-]< %% set slot# x 381 | 382 | %% grab the y value from the stack 383 | <<<<<[-]>>>>> %% y=0 384 | <[>+>+< <-]> >[< <+> >-]< %% get object# 385 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 386 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# y 387 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 388 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 389 | [ %% walk to object#n (drag param# & object index) 390 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 391 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 392 | >>>>>>>>>>>>>>>>>>>> 393 | -] 394 | >[< <<<<<+>>>>> >-]< %% set slot# y 395 | >]< %% END IF (function#2) 396 | 397 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 398 | % function#3 rMoveTo(x y) % 399 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 400 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 401 | >[-]+++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#3) 402 | %% grab the x value from the stack 403 | <[>+>+< <-]> >[< <+> >-]< %% get object# 404 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 405 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# x 406 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 407 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 408 | [ %% walk to object#n (drag param# & object index) 409 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 410 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 411 | >>>>>>>>>>>>>>>>>>>> 412 | -] 413 | >[< <<<<+>>>> >-]< %% set slot# x 414 | 415 | %% grab the y value from the stack 416 | <[>+>+< <-]> >[< <+> >-]< %% get object# 417 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 418 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# y 419 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 420 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 421 | [ %% walk to object#n (drag param# & object index) 422 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 423 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 424 | >>>>>>>>>>>>>>>>>>>> 425 | -] 426 | >[< <<<<<+>>>>> >-]< %% set slot# y 427 | >]< %% END IF (function#3) 428 | 429 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 430 | % function#5 setWidth(width) % 431 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 432 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 433 | >[-]+++++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#5) 434 | %% grab the width value from the stack 435 | <<<<<<[-]>>>>>> %% width=0 436 | <[>+>+< <-]> >[< <+> >-]< %% get object# 437 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 438 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# width 439 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 440 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 441 | [ %% walk to object#n (drag param# & object index) 442 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 443 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 444 | >>>>>>>>>>>>>>>>>>>> 445 | -] 446 | >[< <<<<<<+>>>>>> >-]< %% set slot# width 447 | >]< %% END IF (function#5) 448 | 449 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 450 | % function#6 setHeight(height) % 451 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 452 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 453 | >[-]++++++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#6) 454 | %% grab the height value from the stack 455 | <<<<<<[-]>>>>>> %% height=0 456 | <[>+>+< <-]> >[< <+> >-]< %% get object# 457 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 458 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# height 459 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 460 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 461 | [ %% walk to object#n (drag param# & object index) 462 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 463 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 464 | >>>>>>>>>>>>>>>>>>>> 465 | -] 466 | >[< <<<<<<<+>>>>>>> >-]< %% set slot# height 467 | >]< %% END IF (function#5) 468 | 469 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 470 | % function#4 draw() % 471 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 472 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 473 | >[-]++++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#4) 474 | [-] #64# >++++++++[<++++++++>-]< ++++. %% D 475 | [-] #64# >++++++++[<++++++++>-]< ++++++++++++++++++. %% R 476 | [-] #64# >++++++++[<++++++++>-]< +. %% A 477 | [-] #64# >++++++++[<++++++++>-]< +++++++++++++++++++++++. %% W 478 | [-] #64# >++++++++[<++++++++>-]< +++++++++. %% I 479 | [-] #64# >++++++++[<++++++++>-]< ++++++++++++++. %% N 480 | [-] #64# >++++++++[<++++++++>-]< +++++++. %% G 481 | [-] #30# >+++++[<++++++>-]< ++. %% 482 | [-] #64# >++++++++[<++++++++>-]< +. %% A 483 | [-] #30# >+++++[<++++++>-]< ++. %% 484 | [-] #64# >++++++++[<++++++++>-]< ++++++++++++++++++. %% R 485 | [-] #64# >++++++++[<++++++++>-]< +++++. %% E 486 | [-] #64# >++++++++[<++++++++>-]< +++. %% C 487 | [-] #64# >++++++++[<++++++++>-]< ++++++++++++++++++++. %% T 488 | [-] #64# >++++++++[<++++++++>-]< +. %% A 489 | [-] #64# >++++++++[<++++++++>-]< ++++++++++++++. %% N 490 | [-] #64# >++++++++[<++++++++>-]< +++++++. %% G 491 | [-] #64# >++++++++[<++++++++>-]< ++++++++++++. %% L 492 | [-] #64# >++++++++[<++++++++>-]< +++++. %% E 493 | [-] #30# >+++++[<++++++>-]< ++. %% 494 | [-] #64# >++++++++[<++++++++>-]< +. %% A 495 | [-] #64# >++++++++[<++++++++>-]< ++++++++++++++++++++. %% T 496 | [-] #30# >+++++++[<++++++++>-]< ++. %% : 497 | [-] #42# >++++++[<+++++++>-]< --. %% ( 498 | [-] <<<<[>>>>+>+<<<< <-]>>>> [<<<< + >>>>-] %% x 499 | >[ %% output number 500 | [>+>+<<-]>>[<<+>>-]< %% dup 501 | >+++++++++<[>>>+<< [>+>[-]<<-] >[<+>-] %% mod10 502 | >[<<++++++++++>>-] <<- <-] +++++++++ >[<->-]< 503 | [>+<-] < [>+<-] < [>+<-] >>>[<<<+>>>-] < %% rrot 504 | >+++++++++< [ >>>+<< [>+>[-]<<-] >[<+>-] %% div10 505 | >[<<++++++++++>>>+<-] <<- <- ] >>>>[<<<<+>>>>-]<<<< >[-]< 506 | <+> %% inc1 507 | ] 508 | <[ 509 | [>+<-] %% mover 510 | +++++++[<+++++++>-]<-> %% add48 511 | <.[-]> %% putc 512 | >[<<+>>-]< %% movel2 513 | <-] 514 | [-]<<<<[>>>>+>+<<<< <-]>>>> >[<<<< <+> >>>>-]< %% get slot# x 515 | >[-][<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (x=0) 516 | [-]>[-]+++++++[<+++++++>-]<-.[-] %% output 0 digit 517 | >]< %% END IF (x=0) 518 | [-] #42# >++++++[<+++++++>-]< ++. %% comma 519 | [-] <<<<<[>>>>>+>+<<<<< <-]>>>>> [<<<<< + >>>>>-] %% y 520 | >[ %% output number 521 | [>+>+<<-]>>[<<+>>-]< %% dup 522 | >+++++++++<[>>>+<< [>+>[-]<<-] >[<+>-] %% mod10 523 | >[<<++++++++++>>-] <<- <-] +++++++++ >[<->-]< 524 | [>+<-] < [>+<-] < [>+<-] >>>[<<<+>>>-] < %% rrot 525 | >+++++++++< [ >>>+<< [>+>[-]<<-] >[<+>-] %% div10 526 | >[<<++++++++++>>>+<-] <<- <- ] >>>>[<<<<+>>>>-]<<<< >[-]< 527 | <+> %% inc1 528 | ] 529 | <[ 530 | [>+<-] %% mover 531 | +++++++[<+++++++>-]<-> %% add48 532 | <.[-]> %% putc 533 | >[<<+>>-]< %% movel2 534 | <-] 535 | [-]<<<<<[>>>>>+>+<<<<< <-]>>>>> >[<<<<< <+> >>>>>-]< %% get slot# y 536 | >[-][<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (y=0) 537 | [-]>[-]+++++++[<+++++++>-]<-.[-] %% output 0 digit 538 | >]< %% END IF (y=0) 539 | [-] #42# >++++++[<+++++++>-]< -. %% ) 540 | [-] #42# >++++++[<+++++++>-]< ++. %% comma 541 | [-] #30# >+++++[<++++++>-]< ++. %% 542 | [-] #64# >++++++++[<++++++++>-]< +++++++++++++++++++++++. %% W 543 | [-] #64# >++++++++[<++++++++>-]< +++++++++. %% I 544 | [-] #64# >++++++++[<++++++++>-]< ++++. %% D 545 | [-] #64# >++++++++[<++++++++>-]< ++++++++++++++++++++. %% T 546 | [-] #64# >++++++++[<++++++++>-]< ++++++++. %% H 547 | [-] #30# >+++++[<++++++>-]< ++. %% 548 | [-] <<<<<<[>>>>>>+>+<<<<<< <-]>>>>>> [<<<<<< + >>>>>>-] %% width 549 | >[ %% output number 550 | [>+>+<<-]>>[<<+>>-]< %% dup 551 | >+++++++++<[>>>+<< [>+>[-]<<-] >[<+>-] %% mod10 552 | >[<<++++++++++>>-] <<- <-] +++++++++ >[<->-]< 553 | [>+<-] < [>+<-] < [>+<-] >>>[<<<+>>>-] < %% rrot 554 | >+++++++++< [ >>>+<< [>+>[-]<<-] >[<+>-] %% div10 555 | >[<<++++++++++>>>+<-] <<- <- ] >>>>[<<<<+>>>>-]<<<< >[-]< 556 | <+> %% inc1 557 | ] 558 | <[ 559 | [>+<-] %% mover 560 | +++++++[<+++++++>-]<-> %% add48 561 | <.[-]> %% putc 562 | >[<<+>>-]< %% movel2 563 | <-] 564 | [-]<<<<<<[>>>>>>+>+<<<<<< <-]>>>>>> >[<<<<<< <+> >>>>>>-]< %% get slot# width 565 | >[-][<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (width=0) 566 | [-]>[-]+++++++[<+++++++>-]<-.[-] %% output 0 digit 567 | >]< %% END IF (width=0) 568 | [-] #42# >++++++[<+++++++>-]< ++. %% comma 569 | [-] #30# >+++++[<++++++>-]< ++. %% 570 | [-] #64# >++++++++[<++++++++>-]< ++++++++. %% H 571 | [-] #64# >++++++++[<++++++++>-]< +++++. %% E 572 | [-] #64# >++++++++[<++++++++>-]< +++++++++. %% I 573 | [-] #64# >++++++++[<++++++++>-]< +++++++. %% G 574 | [-] #64# >++++++++[<++++++++>-]< ++++++++. %% H 575 | [-] #64# >++++++++[<++++++++>-]< ++++++++++++++++++++. %% T 576 | [-] #30# >+++++[<++++++>-]< ++. %% 577 | [-] <<<<<<<[>>>>>>>+>+<<<<<<< <-]>>>>>>> [<<<<<<< + >>>>>>>-] %% width 578 | >[ %% output number 579 | [>+>+<<-]>>[<<+>>-]< %% dup 580 | >+++++++++<[>>>+<< [>+>[-]<<-] >[<+>-] %% mod10 581 | >[<<++++++++++>>-] <<- <-] +++++++++ >[<->-]< 582 | [>+<-] < [>+<-] < [>+<-] >>>[<<<+>>>-] < %% rrot 583 | >+++++++++< [ >>>+<< [>+>[-]<<-] >[<+>-] %% div10 584 | >[<<++++++++++>>>+<-] <<- <- ] >>>>[<<<<+>>>>-]<<<< >[-]< 585 | <+> %% inc1 586 | ] 587 | <[ 588 | [>+<-] %% mover 589 | +++++++[<+++++++>-]<-> %% add48 590 | <.[-]> %% putc 591 | >[<<+>>-]< %% movel2 592 | <-] 593 | [-]<<<<<<<[>>>>>>>+>+<<<<<<< <-]>>>>>>> >[<<<<<<< <+> >>>>>>>-]< %% get slot# height 594 | >[-][<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (height=0) 595 | [-]>[-]+++++++[<+++++++>-]<-.[-] %% output 0 digit 596 | >]< %% END IF (height=0) 597 | [-] ++++++++++.[-] %% \n 598 | >]< %% END IF (function#4) 599 | 600 | >]< %% END IF (class#2) 601 | 602 | 603 | 604 | ================================================================================================ 605 | = circle class = 606 | ================================================================================================ 607 | [-]<<<[>>>+>+<<< <-]>>> >[<<< <+> >>>-]< %% get class# 608 | >[-]++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (class#2) 609 | 610 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 611 | % function#1 circle(x y radius) % 612 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 613 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 614 | >[-]+ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#1) 615 | %% clear the slots 616 | <<<<[-]>>>> %% x=0 617 | <<<<<[-]>>>>> %% y=0 618 | <<<<<<[-]>>>>>> %% radius=0 619 | 620 | %% grab the x value from the stack 621 | <[>+>+< <-]> >[< <+> >-]< %% get object# 622 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 623 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# x 624 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 625 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 626 | [ %% walk to object#n (drag param# & object index) 627 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 628 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 629 | >>>>>>>>>>>>>>>>>>>> 630 | -] 631 | >[< <<<<+>>>> >-]< %% set slot# x 632 | 633 | %% grab the y value from the stack 634 | <[>+>+< <-]> >[< <+> >-]< %% get object# 635 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 636 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# y 637 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 638 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 639 | [ %% walk to object#n (drag param# & object index) 640 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 641 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 642 | >>>>>>>>>>>>>>>>>>>> 643 | -] 644 | >[< <<<<<+>>>>> >-]< %% set slot# y 645 | 646 | %% grab the radius value from the stack 647 | <[>+>+< <-]> >[< <+> >-]< %% get object# 648 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 649 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# radius 650 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 651 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 652 | [ %% walk to object#n (drag param# & object index) 653 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 654 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 655 | >>>>>>>>>>>>>>>>>>>> 656 | -] 657 | >[< <<<<<<+>>>>>> >-]< %% set slot# radius 658 | >]< %% END IF (function#1) 659 | 660 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 661 | % function#2 moveTo(x y) % 662 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 663 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 664 | >[-]++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#2) 665 | %% grab the x value from the stack 666 | <<<<[-]>>>> %% x=0 667 | <[>+>+< <-]> >[< <+> >-]< %% get object# 668 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 669 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# x 670 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 671 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 672 | [ %% walk to object#n (drag param# & object index) 673 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 674 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 675 | >>>>>>>>>>>>>>>>>>>> 676 | -] 677 | >[< <<<<+>>>> >-]< %% set slot# x 678 | 679 | %% grab the y value from the stack 680 | <<<<<[-]>>>>> %% y=0 681 | <[>+>+< <-]> >[< <+> >-]< %% get object# 682 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 683 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# y 684 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 685 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 686 | [ %% walk to object#n (drag param# & object index) 687 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 688 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 689 | >>>>>>>>>>>>>>>>>>>> 690 | -] 691 | >[< <<<<<+>>>>> >-]< %% set slot# y 692 | >]< %% END IF (function#2) 693 | 694 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 695 | % function#3 rMoveTo(x y) % 696 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 697 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 698 | >[-]+++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#3) 699 | %% grab the x value from the stack 700 | <[>+>+< <-]> >[< <+> >-]< %% get object# 701 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 702 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# x 703 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 704 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 705 | [ %% walk to object#n (drag param# & object index) 706 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 707 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 708 | >>>>>>>>>>>>>>>>>>>> 709 | -] 710 | >[< <<<<+>>>> >-]< %% set slot# x 711 | 712 | %% grab the y value from the stack 713 | <[>+>+< <-]> >[< <+> >-]< %% get object# 714 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 715 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# y 716 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 717 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 718 | [ %% walk to object#n (drag param# & object index) 719 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 720 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 721 | >>>>>>>>>>>>>>>>>>>> 722 | -] 723 | >[< <<<<<+>>>>> >-]< %% set slot# y 724 | >]< %% END IF (function#3) 725 | 726 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 727 | % function#5 setRadius(radius) % 728 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 729 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 730 | >[-]+++++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#5) 731 | %% grab the radius value from the stack 732 | <<<<<<[-]>>>>>> %% radius=0 733 | <[>+>+< <-]> >[< <+> >-]< %% get object# 734 | <[>[<<<<<<<<<<<<<<<<<<<< + >>>>>>>>>>>>>>>>>>>>-]< <<<<<<<<<<<<<<<<<<<<]> %% walk back to root object (drag object#) 735 | <<<<<<<<<<<<<<<<<<<< [<<] >> %% stack pull param# radius 736 | <[> [>>] << >>>>>>>>>>>>>>>>>>>> >+< <<<<<<<<<<<<<<<<<<<< [<<] >> <-]> 737 | [-]>> [>>] << >>>>>>>>>>>>>>>>>>>> 738 | [ %% walk to object#n (drag param# & object index) 739 | >[>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -]< 740 | [>>>>>>>>>>>>>>>>>>>> + <<<<<<<<<<<<<<<<<<<< -] 741 | >>>>>>>>>>>>>>>>>>>> 742 | -] 743 | >[< <<<<<<+>>>>>> >-]< %% set slot# radius 744 | >]< %% END IF (function#5) 745 | 746 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 747 | % function#4 draw() % 748 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 749 | [-]<<[>>+>+<< <-]>> >[<< <+> >>-]< %% get function# 750 | >[-]++++ [<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (function#4) 751 | [-] #64# >++++++++[<++++++++>-]< ++++. %% D 752 | [-] #64# >++++++++[<++++++++>-]< ++++++++++++++++++. %% R 753 | [-] #64# >++++++++[<++++++++>-]< +. %% A 754 | [-] #64# >++++++++[<++++++++>-]< +++++++++++++++++++++++. %% W 755 | [-] #64# >++++++++[<++++++++>-]< +++++++++. %% I 756 | [-] #64# >++++++++[<++++++++>-]< ++++++++++++++. %% N 757 | [-] #64# >++++++++[<++++++++>-]< +++++++. %% G 758 | [-] #30# >+++++[<++++++>-]< ++. %% 759 | [-] #64# >++++++++[<++++++++>-]< +. %% A 760 | [-] #30# >+++++[<++++++>-]< ++. %% 761 | [-] #64# >++++++++[<++++++++>-]< +++. %% C 762 | [-] #64# >++++++++[<++++++++>-]< +++++++++. %% I 763 | [-] #64# >++++++++[<++++++++>-]< ++++++++++++++++++. %% R 764 | [-] #64# >++++++++[<++++++++>-]< +++. %% C 765 | [-] #64# >++++++++[<++++++++>-]< ++++++++++++. %% L 766 | [-] #64# >++++++++[<++++++++>-]< +++++. %% E 767 | [-] #30# >+++++[<++++++>-]< ++. %% 768 | [-] #64# >++++++++[<++++++++>-]< +. %% A 769 | [-] #64# >++++++++[<++++++++>-]< ++++++++++++++++++++. %% T 770 | [-] #30# >+++++++[<++++++++>-]< ++. %% : 771 | [-] #42# >++++++[<+++++++>-]< --. %% ( 772 | [-] <<<<[>>>>+>+<<<< <-]>>>> [<<<< + >>>>-] %% x 773 | >[ %% output number 774 | [>+>+<<-]>>[<<+>>-]< %% dup 775 | >+++++++++<[>>>+<< [>+>[-]<<-] >[<+>-] %% mod10 776 | >[<<++++++++++>>-] <<- <-] +++++++++ >[<->-]< 777 | [>+<-] < [>+<-] < [>+<-] >>>[<<<+>>>-] < %% rrot 778 | >+++++++++< [ >>>+<< [>+>[-]<<-] >[<+>-] %% div10 779 | >[<<++++++++++>>>+<-] <<- <- ] >>>>[<<<<+>>>>-]<<<< >[-]< 780 | <+> %% inc1 781 | ] 782 | <[ 783 | [>+<-] %% mover 784 | +++++++[<+++++++>-]<-> %% add48 785 | <.[-]> %% putc 786 | >[<<+>>-]< %% movel2 787 | <-] 788 | [-]<<<<[>>>>+>+<<<< <-]>>>> >[<<<< <+> >>>>-]< %% get slot# x 789 | >[-][<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (x=0) 790 | [-]>[-]+++++++[<+++++++>-]<-.[-] %% output 0 digit 791 | >]< %% END IF (x=0) 792 | [-] #42# >++++++[<+++++++>-]< ++. %% comma 793 | [-] <<<<<[>>>>>+>+<<<<< <-]>>>>> [<<<<< + >>>>>-] %% y 794 | >[ %% output number 795 | [>+>+<<-]>>[<<+>>-]< %% dup 796 | >+++++++++<[>>>+<< [>+>[-]<<-] >[<+>-] %% mod10 797 | >[<<++++++++++>>-] <<- <-] +++++++++ >[<->-]< 798 | [>+<-] < [>+<-] < [>+<-] >>>[<<<+>>>-] < %% rrot 799 | >+++++++++< [ >>>+<< [>+>[-]<<-] >[<+>-] %% div10 800 | >[<<++++++++++>>>+<-] <<- <- ] >>>>[<<<<+>>>>-]<<<< >[-]< 801 | <+> %% inc1 802 | ] 803 | <[ 804 | [>+<-] %% mover 805 | +++++++[<+++++++>-]<-> %% add48 806 | <.[-]> %% putc 807 | >[<<+>>-]< %% movel2 808 | <-] 809 | [-]<<<<<[>>>>>+>+<<<<< <-]>>>>> >[<<<<< <+> >>>>>-]< %% get slot# y 810 | >[-][<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (y=0) 811 | [-]>[-]+++++++[<+++++++>-]<-.[-] %% output 0 digit 812 | >]< %% END IF (y=0) 813 | [-] #42# >++++++[<+++++++>-]< -. %% ) 814 | [-] #42# >++++++[<+++++++>-]< ++. %% comma 815 | [-] #30# >+++++[<++++++>-]< ++. %% 816 | [-] #64# >++++++++[<++++++++>-]< ++++++++++++++++++. %% R 817 | [-] #64# >++++++++[<++++++++>-]< +. %% A 818 | [-] #64# >++++++++[<++++++++>-]< ++++. %% D 819 | [-] #64# >++++++++[<++++++++>-]< +++++++++. %% I 820 | [-] #64# >++++++++[<++++++++>-]< +++++++++++++++++++++. %% U 821 | [-] #64# >++++++++[<++++++++>-]< +++++++++++++++++++. %% S 822 | [-] #30# >+++++[<++++++>-]< ++. %% 823 | [-] <<<<<<[>>>>>>+>+<<<<<< <-]>>>>>> [<<<<<< + >>>>>>-] %% radius 824 | >[ %% output number 825 | [>+>+<<-]>>[<<+>>-]< %% dup 826 | >+++++++++<[>>>+<< [>+>[-]<<-] >[<+>-] %% mod10 827 | >[<<++++++++++>>-] <<- <-] +++++++++ >[<->-]< 828 | [>+<-] < [>+<-] < [>+<-] >>>[<<<+>>>-] < %% rrot 829 | >+++++++++< [ >>>+<< [>+>[-]<<-] >[<+>-] %% div10 830 | >[<<++++++++++>>>+<-] <<- <- ] >>>>[<<<<+>>>>-]<<<< >[-]< 831 | <+> %% inc1 832 | ] 833 | <[ 834 | [>+<-] %% mover 835 | +++++++[<+++++++>-]<-> %% add48 836 | <.[-]> %% putc 837 | >[<<+>>-]< %% movel2 838 | <-] 839 | [-]<<<<<<[>>>>>>+>+<<<<<< <-]>>>>>> >[<<<<<< <+> >>>>>>-]< %% get slot# radius 840 | >[-][<->-]< >[-]< [>[-]+<-] >- [[-]< %% IF (radius=0) 841 | [-]>[-]+++++++[<+++++++>-]<-.[-] %% output 0 digit 842 | >]< %% END IF (radius=0) 843 | [-] ++++++++++.[-] %% \n 844 | >]< %% END IF (function#4) 845 | 846 | >]< %% END IF (class#2) 847 | 848 | 849 | <[<<<<<<<<<<<<<<<<<<<<]> %% walk back to root object 850 | <<<<<<<<<<<<<<<<<<<< <<] 851 | 852 | %% 853 | %% [ http://www.angelfire.com/tx4/cus/shapes/ ] 854 | %% 855 | -------------------------------------------------------------------------------- /examples/prime: -------------------------------------------------------------------------------- 1 | 179424691 2 | -------------------------------------------------------------------------------- /src/brainfuck.pest: -------------------------------------------------------------------------------- 1 | increment = { "+" } 2 | decrement = { "-" } 3 | pointer_increment = { ">" } 4 | pointer_decrement = { "<" } 5 | print_character = { "." } 6 | get_character = { "," } 7 | 8 | loop_block = { left_brace ~ block ~ right_brace } 9 | left_brace = { "[" } 10 | right_brace = { "]" } 11 | 12 | symbol = { increment+ | decrement+ | pointer_increment+ 13 | | pointer_decrement+ | print_character+ | get_character+ } 14 | 15 | block = { (loop_block | symbol) * } 16 | program = { SOI ~ block ~ EOI } 17 | 18 | WHITESPACE = _{ !(symbol | "[" | "]") ~ ANY } 19 | -------------------------------------------------------------------------------- /src/codegen.rs: -------------------------------------------------------------------------------- 1 | use crate::parser::BfAST; 2 | use crate::{Error, Result}; 3 | 4 | use inkwell::basic_block::BasicBlock; 5 | use inkwell::builder::Builder; 6 | use inkwell::context::Context; 7 | use inkwell::execution_engine::{ExecutionEngine, JitFunction}; 8 | use inkwell::module::Module; 9 | use inkwell::values::{FunctionValue, IntValue, PointerValue}; 10 | use inkwell::AddressSpace; 11 | use inkwell::IntPredicate; 12 | use inkwell::OptimizationLevel; 13 | 14 | // use crate::ice; 15 | 16 | use std::io::{Read, Write}; 17 | 18 | pub type BfBootstrap = unsafe extern "C" fn( 19 | unsafe extern "C" fn() -> u8, 20 | unsafe extern "C" fn(c: u8), 21 | unsafe extern "C" fn(ptr: *mut u8, value: u8, len: u64), 22 | ); 23 | 24 | pub struct Codegen<'c> { 25 | context: &'c Context, 26 | module: Module<'c>, 27 | builder: Builder<'c>, 28 | execution_engine: ExecutionEngine<'c>, 29 | } 30 | 31 | extern "C" fn bfrs_get_char() -> u8 { 32 | let mut input = std::io::stdin(); 33 | let mut buf = [0u8]; 34 | 35 | if input.read(&mut buf).unwrap() == 0 { 36 | return 0xFF; // EOF 37 | } 38 | 39 | buf[0] 40 | } 41 | 42 | extern "C" fn bfrs_print_char(c: u8) { 43 | let mut out = std::io::stdout(); 44 | out.write_all(&[c]).unwrap(); 45 | out.flush().unwrap(); 46 | } 47 | 48 | unsafe extern "C" fn bfrs_memset(ptr: *mut u8, value: u8, len: u64) { 49 | std::ptr::write_bytes(ptr, value, len as usize); 50 | } 51 | 52 | impl<'c> Codegen<'c> { 53 | pub fn new(context: &'c Context, optimized: bool) -> Result { 54 | let module = context.create_module("bfrs"); 55 | 56 | let execution_engine = module 57 | .create_jit_execution_engine(if optimized { 58 | OptimizationLevel::Aggressive 59 | } else { 60 | OptimizationLevel::None 61 | }) 62 | .map_err(|_| Error::Ice("failed to create execution engine".into()))?; 63 | let builder = context.create_builder(); 64 | 65 | Ok(Self { 66 | context, 67 | module, 68 | execution_engine, 69 | builder, 70 | }) 71 | } 72 | 73 | pub fn run(&self, ast: &[BfAST]) -> Result<()> { 74 | // 実行環境の構築 75 | let get_char_type = self 76 | .context 77 | .i8_type() 78 | .fn_type(&[], false) 79 | .ptr_type(AddressSpace::Global); 80 | 81 | let put_char_type = self 82 | .context 83 | .void_type() 84 | .fn_type(&[self.context.i8_type().into()], false) 85 | .ptr_type(AddressSpace::Global); 86 | 87 | let memset_type = self 88 | .context 89 | .void_type() 90 | .fn_type( 91 | &[ 92 | self.context 93 | .i8_type() 94 | .ptr_type(AddressSpace::Generic) 95 | .into(), 96 | self.context.i8_type().into(), 97 | self.context.i64_type().into(), 98 | ], 99 | false, 100 | ) 101 | .ptr_type(AddressSpace::Global); 102 | 103 | let fn_type = self.context.void_type().fn_type( 104 | &[ 105 | get_char_type.into(), 106 | put_char_type.into(), 107 | memset_type.into(), 108 | ], 109 | false, 110 | ); 111 | 112 | let func = self.module.add_function("bfrs_lang_start", fn_type, None); 113 | 114 | let basic_block = self.context.append_basic_block(func, "entry"); 115 | 116 | self.builder.position_at_end(basic_block); 117 | 118 | let get_char = func.get_nth_param(0).unwrap().into_pointer_value(); 119 | let put_char = func.get_nth_param(1).unwrap().into_pointer_value(); 120 | let memset = func.get_nth_param(2).unwrap().into_pointer_value(); 121 | 122 | let value_table = self.context.i8_type().array_type(10000); 123 | let value_table = self.builder.build_alloca(value_table, ""); 124 | let counter = self.builder.build_alloca(self.context.i64_type(), ""); 125 | 126 | self.builder 127 | .build_store(counter, self.context.i64_type().const_int(0, false)); 128 | 129 | self.builder.build_call( 130 | memset, 131 | &[ 132 | value_table.into(), 133 | self.context.i8_type().const_int(0, false).into(), 134 | self.context.i64_type().const_int(10000, false).into(), 135 | ], 136 | "", 137 | ); 138 | 139 | for op in ast { 140 | self.build_operation(func, (get_char, put_char), op, value_table, counter)?; 141 | } 142 | 143 | self.builder.build_return(None); 144 | 145 | print!("building..."); 146 | std::io::stdout().flush().unwrap(); 147 | 148 | let entry: JitFunction = 149 | unsafe { self.execution_engine.get_function("bfrs_lang_start") }.unwrap(); 150 | 151 | print!("\u{001b}[2K\r"); 152 | std::io::stdout().flush().unwrap(); 153 | 154 | unsafe { 155 | entry.call(bfrs_get_char, bfrs_print_char, bfrs_memset); 156 | } 157 | 158 | Ok(()) 159 | } 160 | 161 | fn balanced_loop_optimization( 162 | &self, 163 | value_table: PointerValue<'c>, 164 | counter: PointerValue<'c>, 165 | v: &[BfAST], 166 | ) -> Result { 167 | // TODO: too dirty; needs to refactor 168 | 169 | if let [BfAST::AddPtr(j), BfAST::AddOp(k), BfAST::SubPtr(l), BfAST::SubOp(1)] = v[0..4] { 170 | if j == l { 171 | let rhs = self.get_current(value_table, counter); 172 | 173 | let dest_pos = self.builder.build_int_add( 174 | self.builder.build_load(counter, "").into_int_value(), 175 | self.context.i64_type().const_int(j as u64, false), 176 | "", 177 | ); 178 | 179 | let dest_ref = unsafe { 180 | self.builder.build_in_bounds_gep( 181 | value_table, 182 | &[self.context.i64_type().const_int(0, false), dest_pos], 183 | "", 184 | ) 185 | }; 186 | 187 | let dest = self.builder.build_load(dest_ref, "").into_int_value(); 188 | 189 | let res = if k != 1 { 190 | let k = self.context.i8_type().const_int(k as u64, false); 191 | 192 | self.builder 193 | .build_int_add(dest, self.builder.build_int_mul(k, rhs, ""), "") 194 | } else { 195 | self.builder.build_int_add(dest, rhs, "") 196 | }; 197 | 198 | self.builder.build_store(dest_ref, res); 199 | self.set_current( 200 | value_table, 201 | counter, 202 | self.context.i8_type().const_int(0, false), 203 | ); 204 | 205 | return Ok(true); 206 | } 207 | } else if let [BfAST::SubPtr(j), BfAST::AddOp(k), BfAST::AddPtr(l), BfAST::SubOp(1)] = 208 | v[0..4] 209 | { 210 | if j == l { 211 | let rhs = self.get_current(value_table, counter); 212 | 213 | let dest_pos = self.builder.build_int_sub( 214 | self.builder.build_load(counter, "").into_int_value(), 215 | self.context.i64_type().const_int(j as u64, false), 216 | "", 217 | ); 218 | 219 | let dest_ref = unsafe { 220 | self.builder.build_in_bounds_gep( 221 | value_table, 222 | &[self.context.i64_type().const_int(0, false), dest_pos], 223 | "", 224 | ) 225 | }; 226 | 227 | let dest = self.builder.build_load(dest_ref, "").into_int_value(); 228 | 229 | let res = if k != 1 { 230 | let k = self.context.i8_type().const_int(k as u64, false); 231 | 232 | self.builder 233 | .build_int_add(dest, self.builder.build_int_mul(k, rhs, ""), "") 234 | } else { 235 | self.builder.build_int_add(dest, rhs, "") 236 | }; 237 | 238 | self.builder.build_store(dest_ref, res); 239 | self.set_current( 240 | value_table, 241 | counter, 242 | self.context.i8_type().const_int(0, false), 243 | ); 244 | 245 | return Ok(true); 246 | } 247 | } else if let [BfAST::AddPtr(j), BfAST::SubOp(k), BfAST::SubPtr(l), BfAST::SubOp(1)] = 248 | v[0..4] 249 | { 250 | if j == l { 251 | let rhs = self.get_current(value_table, counter); 252 | 253 | let dest_pos = self.builder.build_int_add( 254 | self.builder.build_load(counter, "").into_int_value(), 255 | self.context.i64_type().const_int(j as u64, false), 256 | "", 257 | ); 258 | 259 | let dest_ref = unsafe { 260 | self.builder.build_in_bounds_gep( 261 | value_table, 262 | &[self.context.i64_type().const_int(0, false), dest_pos], 263 | "", 264 | ) 265 | }; 266 | 267 | let dest = self.builder.build_load(dest_ref, "").into_int_value(); 268 | 269 | let res = if k != 1 { 270 | let k = self.context.i8_type().const_int(k as u64, false); 271 | 272 | self.builder 273 | .build_int_sub(dest, self.builder.build_int_mul(k, rhs, ""), "") 274 | } else { 275 | self.builder.build_int_sub(dest, rhs, "") 276 | }; 277 | 278 | self.builder.build_store(dest_ref, res); 279 | self.set_current( 280 | value_table, 281 | counter, 282 | self.context.i8_type().const_int(0, false), 283 | ); 284 | 285 | return Ok(true); 286 | } 287 | } else if let [BfAST::SubPtr(j), BfAST::SubOp(k), BfAST::AddPtr(l), BfAST::SubOp(1)] = 288 | v[0..4] 289 | { 290 | if j == l { 291 | let rhs = self.get_current(value_table, counter); 292 | 293 | let dest_pos = self.builder.build_int_sub( 294 | self.builder.build_load(counter, "").into_int_value(), 295 | self.context.i64_type().const_int(j as u64, false), 296 | "", 297 | ); 298 | 299 | let dest_ref = unsafe { 300 | self.builder.build_in_bounds_gep( 301 | value_table, 302 | &[self.context.i64_type().const_int(0, false), dest_pos], 303 | "", 304 | ) 305 | }; 306 | 307 | let dest = self.builder.build_load(dest_ref, "").into_int_value(); 308 | 309 | let res = if k != 1 { 310 | let k = self.context.i8_type().const_int(k as u64, false); 311 | 312 | self.builder 313 | .build_int_sub(dest, self.builder.build_int_mul(k, rhs, ""), "") 314 | } else { 315 | self.builder.build_int_sub(dest, rhs, "") 316 | }; 317 | 318 | self.builder.build_store(dest_ref, res); 319 | self.set_current( 320 | value_table, 321 | counter, 322 | self.context.i8_type().const_int(0, false), 323 | ); 324 | 325 | return Ok(true); 326 | } 327 | } 328 | 329 | return Ok(false); 330 | } 331 | 332 | fn div_optimization( 333 | &self, 334 | function: FunctionValue<'c>, 335 | value_table: PointerValue<'c>, 336 | counter: PointerValue<'c>, 337 | v: &[BfAST], 338 | loop_end: &BasicBlock, 339 | ) -> Result { 340 | // TODO: too dirty; needs to refactor 341 | 342 | if let [BfAST::SubOp(i), BfAST::AddPtr(j), BfAST::AddOp(1), BfAST::SubPtr(k)] = v[0..4] { 343 | if j == k { 344 | let cur = self.get_current(value_table, counter); 345 | let rat = self.context.i8_type().const_int(i as u64, false); 346 | 347 | let modulo = self.builder.build_int_unsigned_rem(cur, rat, ""); 348 | 349 | let br_okay = self.context.append_basic_block(function, ""); 350 | let br_not_okay = self.context.append_basic_block(function, ""); 351 | 352 | self.builder.build_conditional_branch( 353 | self.builder.build_int_compare( 354 | IntPredicate::EQ, 355 | modulo, 356 | self.context.i8_type().const_int(0 as u64, false), 357 | "", 358 | ), 359 | br_okay, 360 | br_not_okay, 361 | ); 362 | 363 | self.builder.position_at_end(br_okay); 364 | 365 | let dest_pos = self.builder.build_int_add( 366 | self.builder.build_load(counter, "").into_int_value(), 367 | self.context.i64_type().const_int(j as u64, false), 368 | "", 369 | ); 370 | 371 | let dest_ref = unsafe { 372 | self.builder.build_in_bounds_gep( 373 | value_table, 374 | &[self.context.i64_type().const_int(0, false), dest_pos], 375 | "", 376 | ) 377 | }; 378 | 379 | let dest = self.builder.build_load(dest_ref, "").into_int_value(); 380 | let res = self.builder.build_int_add( 381 | dest, 382 | self.builder.build_int_unsigned_div(cur, rat, ""), 383 | "", 384 | ); 385 | 386 | self.builder.build_store(dest_ref, res); 387 | 388 | self.set_current( 389 | value_table, 390 | counter, 391 | self.context.i8_type().const_int(0, false), 392 | ); 393 | 394 | self.builder.build_unconditional_branch(loop_end.clone()); 395 | 396 | self.builder.position_at_end(br_not_okay); 397 | 398 | return Ok(true); 399 | } 400 | } else if let [BfAST::SubOp(i), BfAST::SubPtr(j), BfAST::AddOp(1), BfAST::AddPtr(k)] = 401 | v[0..4] 402 | { 403 | if j == k { 404 | let cur = self.get_current(value_table, counter); 405 | let rat = self.context.i8_type().const_int(i as u64, false); 406 | 407 | let modulo = self.builder.build_int_unsigned_rem(cur, rat, ""); 408 | 409 | let br_okay = self.context.append_basic_block(function, ""); 410 | let br_not_okay = self.context.append_basic_block(function, ""); 411 | 412 | self.builder.build_conditional_branch( 413 | self.builder.build_int_compare( 414 | IntPredicate::EQ, 415 | modulo, 416 | self.context.i8_type().const_int(0 as u64, false), 417 | "", 418 | ), 419 | br_okay, 420 | br_not_okay, 421 | ); 422 | 423 | self.builder.position_at_end(br_okay); 424 | 425 | let dest_pos = self.builder.build_int_sub( 426 | self.builder.build_load(counter, "").into_int_value(), 427 | self.context.i64_type().const_int(j as u64, false), 428 | "", 429 | ); 430 | 431 | let dest_ref = unsafe { 432 | self.builder.build_in_bounds_gep( 433 | value_table, 434 | &[self.context.i64_type().const_int(0, false), dest_pos], 435 | "", 436 | ) 437 | }; 438 | 439 | let dest = self.builder.build_load(dest_ref, "").into_int_value(); 440 | let res = self.builder.build_int_add( 441 | dest, 442 | self.builder.build_int_unsigned_div(cur, rat, ""), 443 | "", 444 | ); 445 | 446 | self.builder.build_store(dest_ref, res); 447 | 448 | self.set_current( 449 | value_table, 450 | counter, 451 | self.context.i8_type().const_int(0, false), 452 | ); 453 | 454 | self.builder.build_unconditional_branch(*loop_end); 455 | 456 | self.builder.position_at_end(br_not_okay); 457 | 458 | return Ok(true); 459 | } 460 | } else if let [BfAST::SubOp(i), BfAST::AddPtr(j), BfAST::SubOp(1), BfAST::SubPtr(k)] = 461 | v[0..4] 462 | { 463 | if j == k { 464 | let cur = self.get_current(value_table, counter); 465 | let rat = self.context.i8_type().const_int(i as u64, false); 466 | 467 | let modulo = self.builder.build_int_unsigned_rem(cur, rat, ""); 468 | 469 | let br_okay = self.context.append_basic_block(function, ""); 470 | let br_not_okay = self.context.append_basic_block(function, ""); 471 | 472 | self.builder.build_conditional_branch( 473 | self.builder.build_int_compare( 474 | IntPredicate::EQ, 475 | modulo, 476 | self.context.i8_type().const_int(0 as u64, false), 477 | "", 478 | ), 479 | br_okay, 480 | br_not_okay, 481 | ); 482 | 483 | self.builder.position_at_end(br_okay); 484 | 485 | let dest_pos = self.builder.build_int_add( 486 | self.builder.build_load(counter, "").into_int_value(), 487 | self.context.i64_type().const_int(j as u64, false), 488 | "", 489 | ); 490 | 491 | let dest_ref = unsafe { 492 | self.builder.build_in_bounds_gep( 493 | value_table, 494 | &[self.context.i64_type().const_int(0, false), dest_pos], 495 | "", 496 | ) 497 | }; 498 | 499 | let dest = self.builder.build_load(dest_ref, "").into_int_value(); 500 | let res = self.builder.build_int_sub( 501 | dest, 502 | self.builder.build_int_unsigned_div(cur, rat, ""), 503 | "", 504 | ); 505 | 506 | self.builder.build_store(dest_ref, res); 507 | 508 | self.set_current( 509 | value_table, 510 | counter, 511 | self.context.i8_type().const_int(0, false), 512 | ); 513 | 514 | self.builder.build_unconditional_branch(*loop_end); 515 | 516 | self.builder.position_at_end(br_not_okay); 517 | 518 | return Ok(true); 519 | } 520 | } else if let [BfAST::SubOp(i), BfAST::SubPtr(j), BfAST::SubOp(1), BfAST::AddPtr(k)] = 521 | v[0..4] 522 | { 523 | if j == k { 524 | let cur = self.get_current(value_table, counter); 525 | let rat = self.context.i8_type().const_int(i as u64, false); 526 | 527 | let modulo = self.builder.build_int_unsigned_rem(cur, rat, ""); 528 | 529 | let br_okay = self.context.append_basic_block(function, ""); 530 | let br_not_okay = self.context.append_basic_block(function, ""); 531 | 532 | self.builder.build_conditional_branch( 533 | self.builder.build_int_compare( 534 | IntPredicate::EQ, 535 | modulo, 536 | self.context.i8_type().const_int(0 as u64, false), 537 | "", 538 | ), 539 | br_okay, 540 | br_not_okay, 541 | ); 542 | 543 | self.builder.position_at_end(br_okay); 544 | 545 | let dest_pos = self.builder.build_int_sub( 546 | self.builder.build_load(counter, "").into_int_value(), 547 | self.context.i64_type().const_int(j as u64, false), 548 | "", 549 | ); 550 | 551 | let dest_ref = unsafe { 552 | self.builder.build_in_bounds_gep( 553 | value_table, 554 | &[self.context.i64_type().const_int(0, false), dest_pos], 555 | "", 556 | ) 557 | }; 558 | 559 | let dest = self.builder.build_load(dest_ref, "").into_int_value(); 560 | let res = self.builder.build_int_sub( 561 | dest, 562 | self.builder.build_int_unsigned_div(cur, rat, ""), 563 | "", 564 | ); 565 | 566 | self.builder.build_store(dest_ref, res); 567 | 568 | self.set_current( 569 | value_table, 570 | counter, 571 | self.context.i8_type().const_int(0, false), 572 | ); 573 | 574 | self.builder.build_unconditional_branch(*loop_end); 575 | 576 | self.builder.position_at_end(br_not_okay); 577 | 578 | return Ok(true); 579 | } 580 | } 581 | return Ok(false); 582 | } 583 | 584 | fn build_operation( 585 | &self, 586 | function: FunctionValue<'c>, 587 | env: (PointerValue<'c>, PointerValue<'c>), 588 | operation: &BfAST, 589 | value_table: PointerValue<'c>, 590 | counter: PointerValue<'c>, 591 | ) -> Result<()> { 592 | let cur = self.get_current(value_table, counter); 593 | 594 | match operation { 595 | BfAST::LoopBlock(v) => { 596 | // 特殊パターンの高速化 597 | if v.is_empty() { 598 | return Ok(()); 599 | } else if v.len() == 1 { 600 | if let BfAST::SubOp(_) = v[0] { 601 | self.set_current( 602 | value_table, 603 | counter, 604 | self.context.i8_type().const_int(0 as u64, false), 605 | ); 606 | 607 | return Ok(()); 608 | } 609 | } else if v.len() == 4 { 610 | // balanced loop optimization (frequently used on multiplications) 611 | if self.balanced_loop_optimization(value_table, counter, &v)? { 612 | return Ok(()); 613 | } 614 | } 615 | 616 | let loop_head = self.context.append_basic_block(function, ""); 617 | let loop_body = self.context.append_basic_block(function, ""); 618 | let loop_end = self.context.append_basic_block(function, ""); 619 | 620 | if v.len() == 4 { 621 | // division optimization 622 | self.div_optimization(function, value_table, counter, &v, &loop_end)?; 623 | } 624 | 625 | self.builder.build_unconditional_branch(loop_head); 626 | 627 | self.builder.position_at_end(loop_head); 628 | 629 | self.builder.build_conditional_branch( 630 | self.builder.build_int_compare( 631 | IntPredicate::EQ, 632 | self.get_current(value_table, counter), 633 | self.context.i8_type().const_int(0, false), 634 | "", 635 | ), 636 | loop_end, 637 | loop_body, 638 | ); 639 | 640 | self.builder.position_at_end(loop_body); 641 | 642 | for i in v { 643 | self.build_operation(function, env, i, value_table, counter)?; 644 | } 645 | 646 | self.builder.build_unconditional_branch(loop_head); 647 | 648 | self.builder.position_at_end(loop_end); 649 | } 650 | BfAST::AddOp(k) => { 651 | let cur = self.builder.build_int_add( 652 | cur, 653 | self.context.i8_type().const_int(*k as u64, false), 654 | "", 655 | ); 656 | self.set_current(value_table, counter, cur); 657 | } 658 | BfAST::SubOp(k) => { 659 | let cur = self.builder.build_int_sub( 660 | cur, 661 | self.context.i8_type().const_int(*k as u64, false), 662 | "", 663 | ); 664 | self.set_current(value_table, counter, cur); 665 | } 666 | BfAST::AddPtr(k) => { 667 | let counter_v = self.builder.build_load(counter, "").into_int_value(); 668 | let counter_incr = self.builder.build_int_add( 669 | counter_v, 670 | self.context.i64_type().const_int(*k as u64, false), 671 | "", 672 | ); 673 | self.builder.build_store(counter, counter_incr); 674 | } 675 | BfAST::SubPtr(k) => { 676 | let counter_v = self.builder.build_load(counter, "").into_int_value(); 677 | let counter_incr = self.builder.build_int_sub( 678 | counter_v, 679 | self.context.i64_type().const_int(*k as u64, false), 680 | "", 681 | ); 682 | self.builder.build_store(counter, counter_incr); 683 | } 684 | BfAST::PutChar => { 685 | self.builder.build_call(env.1, &[cur.into()], ""); 686 | } 687 | BfAST::GetChar => { 688 | let res = self 689 | .builder 690 | .build_call(env.0, &[], "") 691 | .try_as_basic_value() 692 | .left() 693 | .unwrap() 694 | .into_int_value(); 695 | 696 | self.set_current(value_table, counter, res); 697 | } 698 | } 699 | 700 | Ok(()) 701 | } 702 | 703 | pub fn get_current( 704 | &self, 705 | value_table: PointerValue<'c>, 706 | counter: PointerValue<'c>, 707 | ) -> IntValue<'c> { 708 | let counter = self.builder.build_load(counter, ""); 709 | let value = unsafe { 710 | self.builder.build_in_bounds_gep( 711 | value_table, 712 | &[ 713 | self.context.i64_type().const_int(0, false), 714 | counter.into_int_value(), 715 | ], 716 | "", 717 | ) 718 | }; 719 | 720 | self.builder.build_load(value, "").into_int_value() 721 | } 722 | 723 | pub fn set_current( 724 | &self, 725 | value_table: PointerValue<'c>, 726 | counter: PointerValue<'c>, 727 | value: IntValue<'c>, 728 | ) { 729 | let counter = self.builder.build_load(counter, ""); 730 | let ref_val = unsafe { 731 | self.builder.build_in_bounds_gep( 732 | value_table, 733 | &[ 734 | self.context.i64_type().const_int(0, false), 735 | counter.into_int_value(), 736 | ], 737 | "", 738 | ) 739 | }; 740 | 741 | self.builder.build_store(ref_val, value); 742 | } 743 | } 744 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | //! Brainfuck implementation in Rust 2 | #[macro_use] 3 | extern crate pest_derive; 4 | use thiserror::Error; 5 | 6 | pub mod codegen; 7 | pub mod parser; 8 | 9 | #[macro_export] 10 | macro_rules! ice { 11 | ($($x: expr),*) => { 12 | return Err(Error::ice(format!($($x),*))); 13 | }; 14 | } 15 | 16 | #[derive(Debug, Error)] 17 | pub enum Error { 18 | #[error("{0}")] 19 | ParseError(parser::ParseError), 20 | #[error("internal compiler error: {0}")] 21 | Ice(std::borrow::Cow<'static, str>), 22 | } 23 | 24 | impl Error { 25 | pub fn ice>>(message: S) -> Error { 26 | Error::Ice(message.into()) 27 | } 28 | } 29 | 30 | impl From for Error { 31 | fn from(p: parser::ParseError) -> Self { 32 | Self::ParseError(p) 33 | } 34 | } 35 | 36 | pub type Result = std::result::Result; 37 | 38 | fn main() { 39 | use crate::codegen::Codegen; 40 | use inkwell::context::Context; 41 | 42 | let mut args = std::env::args(); 43 | if args.len() < 2 { 44 | eprintln!("No file specified. Abort."); 45 | return; 46 | } 47 | 48 | let res = parser::parse(std::fs::read_to_string(args.nth(1).unwrap()).unwrap()).unwrap(); 49 | let opt_flag = args.nth(0).map(|v| v.starts_with("--opt")).unwrap_or(false); 50 | 51 | let ctx = Context::create(); 52 | let codegen = Codegen::new(&ctx, opt_flag).unwrap(); 53 | 54 | codegen.run(&res).unwrap(); 55 | } 56 | -------------------------------------------------------------------------------- /src/parser.rs: -------------------------------------------------------------------------------- 1 | use crate::{ice, Error, Result}; 2 | use pest::{iterators::Pair, Parser}; 3 | 4 | #[derive(Clone, Debug, PartialEq, Eq)] 5 | pub enum BfAST { 6 | LoopBlock(Vec), 7 | AddOp(usize), 8 | SubOp(usize), 9 | AddPtr(usize), 10 | SubPtr(usize), 11 | PutChar, 12 | GetChar, 13 | } 14 | 15 | #[derive(Parser)] 16 | #[grammar = "brainfuck.pest"] 17 | struct BfParser; 18 | 19 | pub type ParseError = pest::error::Error; 20 | 21 | fn visit_symbol(p: Pair<'_, Rule>, v: &mut Vec) -> Result<()> { 22 | if p.as_rule() != Rule::symbol { 23 | ice!( 24 | "wrong visitor: expected symbol, but given {:?}", 25 | p.as_rule() 26 | ); 27 | } 28 | 29 | let inner = p.into_inner(); 30 | let inner: Vec<_> = inner.collect(); 31 | 32 | for tok in &inner { 33 | match tok.as_rule() { 34 | Rule::increment => { 35 | v.push(BfAST::AddOp(inner.len())); 36 | break; 37 | } 38 | Rule::decrement => { 39 | v.push(BfAST::SubOp(inner.len())); 40 | break; 41 | } 42 | Rule::pointer_increment => { 43 | v.push(BfAST::AddPtr(inner.len())); 44 | break; 45 | } 46 | Rule::pointer_decrement => { 47 | v.push(BfAST::SubPtr(inner.len())); 48 | break; 49 | } 50 | Rule::print_character => { 51 | v.push(BfAST::PutChar); 52 | } 53 | Rule::get_character => { 54 | v.push(BfAST::GetChar); 55 | } 56 | _ => { 57 | ice!("unexpected token while visiting block: {:?}", tok); 58 | } 59 | } 60 | } 61 | 62 | Ok(()) 63 | } 64 | 65 | fn visit_block(p: Pair<'_, Rule>, v: &mut Vec) -> Result<()> { 66 | if p.as_rule() != Rule::block { 67 | ice!("wrong visitor: expected block, but given {:?}", p.as_rule()); 68 | } 69 | 70 | for tok in p.into_inner() { 71 | match tok.as_rule() { 72 | Rule::symbol => { 73 | visit_symbol(tok, v)?; 74 | } 75 | Rule::loop_block => { 76 | visit_loop_block(tok, v)?; 77 | } 78 | _ => { 79 | ice!("unexpected token while visiting block: {:?}", tok); 80 | } 81 | } 82 | } 83 | 84 | Ok(()) 85 | } 86 | 87 | fn visit_loop_block(p: Pair<'_, Rule>, v: &mut Vec) -> Result<()> { 88 | if p.as_rule() != Rule::loop_block { 89 | ice!( 90 | "wrong visitor: expected loop_block, but given {:?}", 91 | p.as_rule() 92 | ); 93 | } 94 | 95 | for tok in p.into_inner() { 96 | match tok.as_rule() { 97 | Rule::left_brace => { 98 | continue; 99 | } 100 | Rule::right_brace => { 101 | break; 102 | } 103 | Rule::block => { 104 | let mut v2 = vec![]; 105 | visit_block(tok, &mut v2)?; 106 | v.push(BfAST::LoopBlock(v2)); 107 | } 108 | _ => { 109 | ice!("unexpected token while visiting loop block: {:?}", tok); 110 | } 111 | } 112 | } 113 | 114 | Ok(()) 115 | } 116 | 117 | fn visit_program(p: Pair<'_, Rule>, v: &mut Vec) -> Result<()> { 118 | if p.as_rule() != Rule::program { 119 | ice!( 120 | "wrong visitor: expected program, but given {:?}", 121 | p.as_rule() 122 | ); 123 | } 124 | 125 | for tok in p.into_inner() { 126 | match tok.as_rule() { 127 | Rule::EOI => {} 128 | Rule::block => { 129 | visit_block(tok, v)?; 130 | } 131 | _ => { 132 | ice!("unexpected token while visiting program: {:?}", tok); 133 | } 134 | } 135 | } 136 | 137 | Ok(()) 138 | } 139 | 140 | pub fn parse>(program: P) -> Result> { 141 | let mut pairs = BfParser::parse(Rule::program, program.as_ref())?; 142 | let program = pairs 143 | .next() 144 | .ok_or_else(|| Error::ice("no matching program"))?; 145 | 146 | let mut program_out = vec![]; 147 | visit_program(program, &mut program_out)?; 148 | 149 | Ok(program_out) 150 | } 151 | 152 | #[test] 153 | fn test_parse_hello_world() { 154 | parse( 155 | ">+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++ 156 | ++>-]<.>+++++++++++[<+++++>-]<.>++++++++[<+++>-]<.+++.------.--------.[-]> 157 | ++++++++[<++++>-]<+.[-]++++++++++.", 158 | ) 159 | .unwrap(); 160 | } 161 | 162 | #[test] 163 | #[should_panic] 164 | fn test_parse_fail() { 165 | parse("[").unwrap(); 166 | } 167 | --------------------------------------------------------------------------------