Draft
Conversation
f218a7d to
6decc60
Compare
| MatchTree::build(module, &fs, Rc::new(Next::Empty)).is_none() | ||
| } | ||
|
|
||
| fn recursion_check(&self, module: &FormatModule, format_ref: FormatRef) -> Result<bool, ()> { |
Contributor
There was a problem hiding this comment.
The method name recursion_check and the return value do not have an intuitive semantics as far as what each possible return value of Ok(true), Ok(false), and Err(()) might signify. Either a bespoke enum, a doc-comment, or a rename of the method would make things clearer.
Contributor
There was a problem hiding this comment.
A more complex type might be useful than a simple enum if we want to capture more information than ternary classification of the form 'yes'/'no'/'failure'
// Allomorph of Option representing the possibly-unknown/unknowable answer to a question
pub enum Questionable<T> {
Known(T), // can be resolved consistently without external context or runtime information
Unknown // cannot be resolved in the absence of runtime information, missing context, or complex logic
}
// For possible branches, alternations, variable or dynamic formats, represents under what conditions a particular property is true
pub enum Consistency {
Always,
Never,
Sometimes, // Definitely not 'Never', strongly suggests not 'Always'
}
pub struct RecursionDiagnostic {
is_auto_recursive: Questionable<bool>, // indicates whether there is a verbatim reference back to the format in question embedded in its definition
is_cyclic: Questionable<bool>, // indicates whether any evaluation of the format in question will form a cycle back to itself, even if not directly (e.g. through mutual recursion)
will_advance_offset: Questionable<Consistency>, // indicates whether a successful decode of the format in question will always result in the offset being advanced by at least one byte
accepts_end_of_input: Questionable<bool>, // Indicates whether, if there was no input left to consume, whether the format would potentially yield a viable parse
}
/* appropriate methods to combine Diagnostics across branches and terms */
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.