Our cut-down version of BASIC won’t be able to handle a program like Eliza. But it shows how we can apply the same techniques we learned in the silly bf and the simple jsonic to build a more sophisticated language:
Even though BASIC has a very different control flow than Racket—including the famous goto—we figured out how these elements either corresponded to existing elements in Racket (e.g., lines becoming functions) and how others could be implemented in Racket (e.g., a program loop using for/fold).
We saw how to automatically collect source locations in the lexer, so we get more precise error messages, and graphical error highlighting in DrRacket. We also separated out our lexer from the tokenizer—later, we can reuse it as the basis of a syntax colorer.
We learned about how to make cuts and splices in the parser to streamline the parse tree by filtering out unnecessary elements.