Hasty Briefsbeta

Bilingual

Some Subtleties When Parsing 6502 Assembly Language

21 hours ago
  • #assembler development
  • #grammar ambiguity
  • #parser design
  • Adding parentheses in math expressions caused parser issues in the Ophis assembler, distinguishing between Absolute and Indirect addressing modes.
  • Formal grammars and parser classes like LL(k) and LR(1) are explained, with hand-coded parsers often using recursive descent and machine-generated ones using shift-reduce.
  • Ambiguous grammars lead to conflicts; the article details shift-reduce and reduce-reduce conflicts, with an example from the assembler's grammar.
  • Fixing ambiguity in an LR(1) parser involves defining operator precedence and introducing a new symbol to separate parenthesized expressions.
  • In Ophis, an LL(1) parser, the fix required adjusting the predictive logic to not commit to indirection prematurely, handling arithmetic operators after parentheses.