At risk of shameless self-promotion let me mention an interpreter for Joy I've written (in Python) https://code.google.com/p/joypy/
Joy is one of the major inspirations for Factor (I think it is considered the first "concatinative" language but I may be mistaken about that) and I think it deserves serious consideration from anyone interested in language design and formal systems. In a word, it's name is apt.
I have added a trace ability that lets the interpreter print out a complete description of the steps in an evaluation, like so (the bullet mark indicates the current interpreter "position", items to the left are on the stack, items to the right are the expression to be evaluated):
joy? 3 range_to_zero
# frame start
• 3 range_to_zero
3 • range_to_zero
# .. range_to_zero == unit [down_to_zero] infra
# .. frame start
3 • unit [down_to_zero] infra
# .... unit == [] cons
# .... frame start
3 • [] cons
3 [] • cons
[3] •
# .... frame end
# .... unit done.
[3] • [down_to_zero] infra
[3] [down_to_zero] • infra
# .... frame start
3 • down_to_zero
# ...... down_to_zero == [0 gt] [dup pred] while
# ...... frame start
3 • [0 gt] [dup pred] while
3 [0 gt] • [dup pred] while
3 [0 gt] [dup pred] • while
# ........ frame start
3 • 0 gt
3 0 • gt
True •
# ........ frame end
# ........ frame start
3 • dup pred
3 3 • pred
3 2 •
# ........ frame end
# ........ frame start
3 2 • 0 gt
3 2 0 • gt
3 True •
# ........ frame end
# ........ frame start
3 2 • dup pred
3 2 2 • pred
3 2 1 •
# ........ frame end
# ........ frame start
3 2 1 • 0 gt
3 2 1 0 • gt
3 2 True •
# ........ frame end
# ........ frame start
3 2 1 • dup pred
3 2 1 1 • pred
3 2 1 0 •
# ........ frame end
# ........ frame start
3 2 1 0 • 0 gt
3 2 1 0 0 • gt
3 2 1 False •
# ........ frame end
# ........ while done.
3 2 1 0 •
# ...... frame end
# ...... down_to_zero done.
3 2 1 0 •
# .... frame end
# .... infra done.
[0 1 2 3] •
# .. frame end
# .. range_to_zero done.
[0 1 2 3] •
# frame end
-> [0 1 2 3]
joy?
It's a little hard to follow but it is complete and visible.
Joy is one of the major inspirations for Factor (I think it is considered the first "concatinative" language but I may be mistaken about that) and I think it deserves serious consideration from anyone interested in language design and formal systems. In a word, it's name is apt.
I have added a trace ability that lets the interpreter print out a complete description of the steps in an evaluation, like so (the bullet mark indicates the current interpreter "position", items to the left are on the stack, items to the right are the expression to be evaluated):
It's a little hard to follow but it is complete and visible.