Skip to main content

Module round_trip

Module round_trip 

Source
Expand description

Mutation-guarded grammar interchange round trips.

A plain round trip (import, emit, re-import, compare) cannot tell a correct importer/emitter pair from two that are wrong in mutually cancelling ways, and it cannot tell an emitter that re-emits a cached source from one that prints the grammar it was given. The guard therefore changes the grammar before export, requires the change in the exported text and in the re-imported grammar, and checks both the imported and the re-imported grammar against independent accept and reject samples that do not come from the pair under test. It mirrors js/src/grammar-round-trip.js.

Structs§

GrammarRoundTrip
The importer/emitter pair under test and the independent samples.
GrammarRoundTripFailure
One failed check.
GrammarRoundTripReport
The outcome of check_grammar_round_trip.

Enums§

GrammarRoundTripError
Why the guard could not run.
GrammarRoundTripFailureKind
What a failed check found.
GrammarRoundTripStage
The grammar a failed check looked at.
GrammarRoundTripStatus
Whether the pair carried the grammar and the mutation.

Constants§

GRAMMAR_ROUND_TRIP_MARKER
The literal alternative the guard adds to the start rule by default.

Functions§

accepts_text
Whether text parses with grammar on the native executor, as the JavaScript acceptsText does.
canonical_rule_definition
The meaning-aware definition of a rule.
check_grammar_round_trip
Round trips source through a mutated export and reports every failure.
mutate_grammar_start_rule
Adds marker as a literal alternative of the start rule.

Type Aliases§

GrammarEmitFn
Emits a grammar in one notation, with its fidelity report.
GrammarImportFn
Imports grammar source text of one notation.