a2aaron / BrainFriendly

A BF interpreter made in Python
0 stars 2 forks source link

Make BF Programs compile to an intermediate representation #18

Open a2aaron opened 7 years ago

a2aaron commented 7 years ago

This removes the annoyance of having to check for both [ and ord('[')

porglezomp commented 7 years ago

Our intermediate representation should also be somewhat richer to enable optimizations, like

(ADD, 3) # +++
(ADD, -3) # ---
(MOV, -3) # <<<
(MOV, 3) # >>>
(SET, 2) # [-]++
(READ, None)
(WRITE, None)
(OPEN, 14) # a [ that branches 14 instructions on success
(CLOSE, 14) # a ] that branches 14 instructions back on success

etc…