go-v.orgcodex
Menu
Page tools

codex · Philosophy

Lexer hack

In computer programming, the lexer hack is a solution to parsing a context-sensitive grammar such as C, where classifying a sequence of characters as a variable name or a type name requires contextual information, by feeding contextual information backwards from the parser to the lexer. The lexer hack is frowned upon in modern compilers as it creates tight coupling between otherwise largely independent steps in the compilation process. Instead, identifier-like tokens are tokenized as identifiers and later disambiguated by the parser, allowing cleaner separation of concerns.

Wikipedia contributors, "Lexer hack", Wikipedia, revision 1366066717, retrieved 20 November 2026, source, CC BY-SA 4.0.

More Philosophy · Search the codex