bf17

BF variable expander - explanation

Mar 20th, 2019 (edited)
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. The concept of using variables to generalize brainfuck programs is described here: https://esolangs.org/wiki/Brainfuck_algorithms
  2. In brainfuck, a variable is simply a label that refers to a specific memory cell. To exand the variable, means to use the current location of the Data Pointer and calculate the necessary amount of ">" or "<" to move the Pointer to the that location. This makes brainfuck code easily re-locatable. The Python 3 program 'bfvx.py' replaces the variable with zero or more ">" or "<". The output is an unformatted brainfuck program.
  3.  
  4. Required format:
  5.  
  6. - variable declaration
  7. - brainfuck program with variables
  8.  
  9. Guidelines:
  10. - variable names must not include brainfuck commands "><+-,.[]"
  11. - variable names may contain any number of characters; upper and lowercase letters, numerals and many special characters
  12. - other characters may cause Python errors
  13. - there should be no comments in the program
  14. - number of variables used must be hard-coded in the program, something large
  15.  
  16. Program examples with output.
  17. 1.
  18. = a 5 (variable declaration)
  19. a (program)
  20. >>>>> (output)
  21.  
  22. 2.
  23. = a 8
  24. = B 3
  25. a+B
  26. >>>>>>>>+<<<<<
  27.  
  28. 3.
  29. = a 5
  30. = BB 2
  31. a-BB
  32. >>>>>-<<<
  33.  
  34. 4.
  35. = a 5
  36. = B1 3
  37. a>>>+B1
  38. >>>>>>>>+<<<<<
  39.  
  40. 5.
  41. = a 3
  42. = temp_1 7
  43. = z 0
  44. a++++[temp_1++a-]z
  45. >>>++++[>>>>++<<<<-]<<<
  46.  
  47. 6.
  48. = a 3
  49. = z 0
  50. az
  51. error: 'az' not a declared variable, will not produce >>><<<
  52.  
  53. 7.
  54. = x" 10
  55. x"
  56. probably error
Add Comment
Please, Sign In to add comment