Six Missing Features Forced a Self-Hosting Lexer to Grow from 129 to 355 Lines
A developer building 'lm', a small statically-typed low-level language with four compiler backends, attempted to port its JavaScript lexer into lm itself as a self-hosting milestone. The port revealed six core language gaps — including no pointer-to-local, no constants, no character literals, no string type, no labelled loop breaks, and no hex notation — that together caused the lm lexer to be nearly three times longer than its JavaScript equivalent. The absence of a centralised advance() function forced inline duplication across 14 call sites, which introduced a latent correctness bug in column counting that only goes undetected due to incidental newline resets. The developer intentionally chose the lexer as the first porting target because, at 129 lines, it was small enough to abandon if the language proved inadequate. The exercise served as a planned diagnostic, exposing fundamental expressiveness limits before the project scaled further.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in