Skip to content

Refactor items 5-10: unknown headers, aliases, implicit labels, lexer, validation - #12

Merged
leonbohn merged 6 commits into
mainfrom
refactor
Nov 5, 2026
Merged

leonbohn merged 6 commits into
mainfrom
refactor

Conversation

@leonbohn

@leonbohn leonbohn commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Works through items 5–10 of the refactor list (the P1 "valid HOA that is rejected" group plus lexer/header validation). One commit per item; ./scripts/check passes after each.

Changes

  • 5. Unknown header items: parsed into HeaderItem::Unknown(name, Vec<UnknownValue>) instead of failing, and written back out. Uppercase unknown names log a tracing warning. Header names may contain . (e.g. spot.state-player).
  • 6. Unknown properties: / acc-name:: new Property::Other and AcceptanceName::Other. TryFrom<String> became an infallible From<String> (breaking).
  • 7. Alias references: AbstractLabelExpression::Alias, @name in labels and aliases, and HoaRepresentation::unalias (recursive, detects undefined and cyclic aliases, leaves the automaton untouched on error). Parsing does not unalias; BDD conversion of an unresolved alias returns an error.
  • 8. Implicit and state labels: edges may omit labels. A label-less state needs exactly 2^|AP| edges; a state label is copied onto its edges; mixing labelled and unlabelled edges is an error. These parse to the same HoaRepresentation as the explicit form. Label resolution happens in the HoaRepresentation parser, where the AP count is known.
  • 9. Lexer: C-like string escapes (\" and \\ decoded, other escapes kept verbatim), nested comments, and --ABORT-- lexes as Token::Abort. Token::Bool removed. Abort handling is token-based: from_hoa, parse_hoa_automata and first_automaton_split_position no longer match substrings, so --ABORT-- inside a string or foo--ABORT-- are not aborts, and a valid automaton after an aborted one in the same chunk is returned.
  • 10. Validation: HoaRepresentation::validate (run by the parser) with FromHoaError::Invalid(ValidationError). It checks the version (v1, v1.x; otherwise UnsupportedVersion), a missing Acceptance:, header multiplicities, and state, acceptance-set and AP indices against their declared counts.

Notes

  • Every item adds tests, and CHANGELOG.md is updated.
  • A lexer error in parse_hoa_automata now yields no automata at all (previously each --END-- chunk was lexed separately).
  • Known values of unknown header items are limited to integers, strings and identifiers.
  • validate returns the first violation only.

@leonbohn
leonbohn merged commit 0a24d83 into main Nov 5, 2026
3 checks passed
@leonbohn
leonbohn deleted the refactor branch November 5, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant