/examples/brainfuck.y

https://gitlab.com/lily-mara/schwift · Happy · 85 lines · 70 code · 15 blank · 0 comment · 0 complexity · 49d1d59a38b4c2c253dc066eda16c151 MD5 · raw file

  1. show me what you got! "Please input your brainfuck program: "
  2. portal gun input
  3. show me what you got ""
  4. size squanch (input squanch - 1)
  5. count squanch 0
  6. memory on a cob
  7. i squanch 0
  8. while (i less 30000) :<
  9. memory assimilate 0
  10. i squanch (i + 1)
  11. >:
  12. squanch i
  13. memPointer squanch 0
  14. loop squanch 0
  15. while (count less size) :<
  16. char squanch input[count]
  17. if (char == "<") :<
  18. memPointer squanch (memPointer - 1)
  19. >:
  20. if (char == ">") :<
  21. memPointer squanch (memPointer + 1)
  22. >:
  23. if (char == "+") :<
  24. memory[memPointer] squanch (memory[memPointer] + 1)
  25. >:
  26. if (char == "-") :<
  27. memory[memPointer] squanch (memory[memPointer] - 1)
  28. >:
  29. if (char == ".") :<
  30. show me what you got! ascii(memory[memPointer])
  31. >:
  32. if (char == ",") :<
  33. portal gun in
  34. memory[memPointer] squanch in
  35. squanch in
  36. >:
  37. if (char == "[") :<
  38. l squanch 0
  39. if (memory[memPointer] == 0) :<
  40. count squanch (count + 1)
  41. while ((l more 0) or !(input[count] == "]")) :<
  42. if (input[count] == "[") :<
  43. l squanch (l + 1)
  44. >:
  45. if (input[count] == "]") :<
  46. l squanch (l - 1)
  47. >:
  48. count squanch (count + 1)
  49. >:
  50. >:
  51. >:
  52. if (char == "]") :<
  53. l squanch 0
  54. if !(memory[memPointer] == 0) :<
  55. count squanch (count - 1)
  56. while ((l more 0) or !(input[count] == "[")) :<
  57. if (input[count] == "]") :<
  58. l squanch (l + 1)
  59. >:
  60. if (input[count] == "[") :<
  61. l squanch (l - 1)
  62. >:
  63. count squanch (count - 1)
  64. >:
  65. count squanch (count - 1)
  66. >:
  67. >:
  68. count squanch (count + 1)
  69. >:
  70. show me what you got ""