This code is generated by this version of the pl/0 compiler:
code generated by running:
# if ply not installed:
cd ply-3.4 ; sudo python setup.py install ; cd ..
# main step:
./pl0_to_retro.py < tests/41_recursion.pl0 > recurse.rx
This code is generated by this version of the pl/0 compiler:
code generated by running:
# if ply not installed:
cd ply-3.4 ; sudo python setup.py install ; cd ..
# main step:
./pl0_to_retro.py < tests/41_recursion.pl0 > recurse.rx
( -- runtime library ------------ ) | |
: odd? mod 2 1 = ; | |
( -- main code ------------------ ) | |
4 variable: | |
digits | |
variables| number cursor | | |
{{ | |
variables| bit | | |
---reveal--- | |
: helper 0 bit ! number @ odd? [ 1 bit ! ] ifTrue | |
number @ 2 / number ! cursor @ 0 > | |
[ cursor @ 1 - cursor ! helper ] ifTrue | |
bit @ putn cr ; | |
}} | |
{{ | |
---reveal--- | |
: binary digits @ cursor ! helper ; | |
}} | |
: run digits @ cursor ! 5 number ! binary number @ putn cr ; | |
( ------------------------------- ) | |
3 [ cr ] times | |
run |
michal@proton:~/vrx$ ./retro --with ~/vrx/recurse.rx | |
Retro 11.5 | |
ok ( -- runtime library ------------ ) | |
ok : odd? mod 2 1 = ; | |
ok ( -- main code ------------------ ) | |
ok 4 | |
ok variable: digits | |
ok variables| number cursor | | |
ok {{ | |
ok variables| bit | | |
ok ---reveal--- | |
ok : helper 0 bit ! number @ odd? [ 1 bit ! ] ifTrue number @ 2 / number ! cursor @ 0 > [ curs | |
or @ 1 - cursor ! helper ] ifTrue bit @ putn cr ; | |
ok }} | |
ok {{ | |
ok ---reveal--- | |
ok : binary digits @ cursor ! helper ; | |
ok }} | |
ok : run digits @ cursor ! 5 number ! binary number @ putn cr ; | |
ok ( ------------------------------- ) | |
ok 3 | |
ok [ cr ] | |
ok times | |
ok run 101 | |
ok 2 | |
2 ? | |
ok |
michal@proton:~/b/gen$ ./retro --with ~/vrx/recurse.rx | |
<<include: "/home/michal/vrx/recurse.rx">> | |
Retro 11.5 | |
ok ( -- runtime library ------------ ) | |
ok : odd? mod 2 1 = ; | |
ok ( -- main code ------------------ ) | |
ok 4 | |
ok variable: digits | |
ok variables| number cursor | | |
ok {{ | |
ok variables| bit | | |
ok ---reveal--- | |
ok : helper 0 bit ! number @ odd? [ 1 bit ! ] ifTrue number @ 2 / number ! cursor @ 0 > [ curs | |
or @ 1 - cursor ! helper ] ifTrue bit @ putn cr ; | |
ok }} | |
ok {{ | |
ok ---reveal--- | |
ok : binary digits @ cursor ! helper ; | |
ok }} | |
ok : run digits @ cursor ! 5 number ! binary number @ putn cr ; | |
ok ( ------------------------------- ) | |
ok 3 | |
ok [ cr ] | |
ok times | |
ok run 101 | |
ok 2 | |
2 ? | |
ok |