Skip to content

refactor(apl): clean up the grammar #17

Description

@araujof

Description

crates/ppe-apl-core/src/parser.rs is 5,588 lines and the grammar it implements exists only as informal comments inside it (parser.rs:9, :1042). There is no single statement of what APL accepts, so the parser is the spec, and the grammar's rough edges are only visible by reading it.

Known edges:

  • require(...) is a rule-level shorthand that is a grammar error inside & or |, handled as a special case in the parser.
  • not is valid only in one context and rejected elsewhere.
  • Five hand-rolled quote strippers were consolidated into one helper after two of them crashed the parser on a lone quote. That class exists because quoting is not specified in one place.

Write the grammar down as EBNF, reconcile it against what the parser actually accepts, and fix the divergences in whichever direction is right. Some will be parser bugs, some will be grammar warts worth removing. Removing a wart is a breaking change to policy text, so each one needs a call on whether it is worth it at 0.1.x.

This pairs with #14: the parser is also the largest uncovered file, and the error sites are easier to enumerate against a written grammar.

Acceptance criteria

  • A grammar document exists under docs/ with the full EBNF and the rule for quoting, escaping, and operator precedence.
  • Every divergence between the document and the parser is resolved, not just noted.
  • Special-case handling that the grammar does not justify is removed, or the grammar is amended to justify it.
  • Breaking changes to accepted policy text are listed in the CHANGELOG with a migration note.
  • make ci passes and the parser's public entry points keep their behavior on valid input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    choreInfra, dependency updates, etc.

    Type

    Projects

    Status
    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions