This article is reproduced from ADR Matanuska BasicsI tried to write a BASIC interpreter using TypeScript.
context
My initial parsing strategy was to use a parser combinator. In Rust, this is nom
library. In Typescript, this is typescript-parsec
.
This strategy is great for hacking a simple parser. However, I find this to be a relatively inflexible approach and requires adjusting your interface to match the library’s assumptions.
Crafting Interpreters
Also, details on how to write a recursive descent parser. These are “hand rolled” and may look like they require more work. However, the architecture is relatively easy to understand and implement, and a lot of More flexible.
Decide
Matanuska BASIC will use a recursive descent parser for its parser and compiler.