Hacker News new | ask | show | jobs
by tess0r 2364 days ago
I agree. I've written an interpreter in rust [1] and input handling, esp for numbers, was really annoying.

I guess the best reference for implementing new interpreters is npiet and testing all example images.

[1] https://github.com/tessi/rpiet

1 comments

Cool, I haven't seen your interpreter! I'll have to give it a read through.

npiet is good, and I use its examples for testing, but FYI it diverges from the spec in how it handles whitespace. According to DMM, if the cursor enters a loop entirely within whitespace, the program should terminate. Currently, npiet doesn't have a cycle-detection algorithm so it hangs.

One of these days I'll get around to making my test infrastructure and polishing up my tests... but I've recently had some weird thoughts about a place&route algorithm to replace my existing Piet backend and that's more interesting. First step, design a router that creates right-hand-rule paths through whitespace? What am I even doing with my life...

I implemented my interpreter with the goal to learn some rust. So please let me know should you find things to improve :)

I remember a point in development when I implemented whitespace handling and cycles therein. I thought I had implemented the spec but some example programs did not run properly. Maybe that was because of the divergence in the spec vs. npiet you mentioned. Since my main goal was to learn rust I just made the example programs work and did not double check the spec again. Will look into it again when I find some time :)

One of these days we’ll need to get IEEE to formalize a standard.