Of course, these adventures never proceed without at least one critical issue. Just when I thought I was done, I pointed my glorious new line/statement parser at adventure.bas. It blew up on an input that I thought I had handled but slipped through the cracks, an expression like (X AND Y)=Z. I put in a quick fix but it was not sufficient to handle the general situation. Basically, due to the way that I implemented AND/OR expressions — having them in the upper level with separate forks for string and numeric expressions — I kept running into examples beyond the reach of my parser. Seeing that I was on the verge of a major refactor, I added several new tests. Then I set out to eliminate the string/number parser dichotomy and instead lean on semantic analysis to ensure valid results.

With the path now fully unblocked, I could complete the final set of statements needed to parse adventure.bas! A finishing touch to add the visitor pattern, similar to what I had done for expressions, and it was complete.

The code can now produce a valid AST of a sort for some subset of GW-BASIC programs.

Here is an example program, followed by a textual output of how my GWParse library interprets it: