Hasty Briefsbeta

Bilingual

Inverse Parentheses

4 months ago
  • #programming
  • #parsing
  • #parentheses
  • Programming languages use parentheses for grouping operands but not for ungrouping them.
  • Grouping with parentheses is straightforward in language grammars, but anti-grouping is more complex.
  • Python's grammar uses braces implicitly, with the tokenizer handling indentation and parentheses nesting.
  • A tokenizer hack can track nesting depth and emit a 'friendliness' score for each token to handle anti-grouping.
  • Precedence climbing parsers can manage infinitely many precedence levels, making them suitable for this approach.
  • The implementation allows for ordinary parsing if friendliness is increased instead of decreased.
  • Future work includes exploring double-parenthesising expressions and involution in anti-grouping parsers.
  • The post also humorously discusses the lack of a satisfactory singular form for 'parentheses'.