100 Days of Code Day 97
I’ve got to get back on the daily exercise bandwagon. So today I completed Binary Search Tree on exercism.org. The only part that got me was the enumerators, I didn’t know what they wanted and the way they wanted me to do it was giving me syntax errors in the editor. I eventually fixed it by outsourcing the enumeration to another function and had both GetEnumerator’s call that. With that exercise completed I officially crossed the two-thirds mark on the C# track.
I decided to go back and try to finish my BASIC interpreter. Or at least the BNF I got from https://rosettacode.org/wiki/BNF_Grammar. There are a few things like peek, poke, and sys that I am not going to implement but I do want to implement file handling OPEN, CLOSE, FREEFILE INPUT #FileNum, PRINT #FileNum and maybe LINE INPUT #FileNum. I added a FileReference class to wrap the stream reader and stream writer in .NET. I also made a backend hook for freefile. I added tokens for OUTPUT (file access mode) and FREEFILE but no parser stuff for it yet (INPUT already had a token).
Since I wanted a picture to show I took another BASIC Computer Games listing, and adapted it for my interpreter. Turns out if you say PRINT:PRINT:PRINT, my interpreter thinks you are making a label named print (need to fix that). I also go hit by on x goto, and if x=y instead of if x==y. I also removed the potential plus sign from integers so you could write x=x+1 more compactly. Otherwise it thinks that is x, +1. I also apparently need to allow commas between print items and treat that as moving to a tab stop before printing the next item.
Bug is cute but the computer never wins, I am wondering if the random number calls are broken.
Nevermind my code to rewrite on goto had a missing THEN. The computer is beating me now.
So, three days left. I was thinking of extending to 119 since I didn’t start updating on X.com until then. Should I?
