Skip to content

Commit

Permalink
parent implementation and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
anweiss committed Oct 13, 2022
1 parent 6877f77 commit b991d3e
Show file tree
Hide file tree
Showing 8 changed files with 331 additions and 847 deletions.
525 changes: 35 additions & 490 deletions src/ast.rs

Large diffs are not rendered by default.

182 changes: 0 additions & 182 deletions src/parser.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/validator/cbor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub struct CBORValidator<'a> {
cddl_location: String,
cbor_location: String,
// Occurrence indicator detected in current state of AST evaluation
occurrence: Option<Occur<'a>>,
occurrence: Option<Occur>,
// Current group entry index detected in current state of AST evaluation
group_entry_idx: Option<usize>,
// cbor object value hoisted from previous state of AST evaluation
Expand Down Expand Up @@ -175,7 +175,7 @@ pub struct CBORValidator<'a> {
advance_to_next_entry: bool,
// Is validation checking for map quality
is_ctrl_map_equality: bool,
entry_counts: Option<Vec<EntryCount<'a>>>,
entry_counts: Option<Vec<EntryCount>>,
// Collect map entry keys that have already been validated
validated_keys: Option<Vec<Value>>,
// Collect map entry values that have yet to be validated
Expand Down
6 changes: 0 additions & 6 deletions src/validator/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,6 @@ mod tests {
value: "foo\n bar\n baz\n".into(),
#[cfg(feature = "ast-span")]
span: Span::default(),
#[cfg(feature = "ast-parent")]
parent: None,
}],
);

Expand Down Expand Up @@ -897,17 +895,13 @@ mod tests {
generic_args: None,
#[cfg(feature = "ast-span")]
span: Span::default(),
#[cfg(feature = "ast-parent")]
parent: None,
},
true,
)?,
vec![Type2::TextValue {
value: "foo\nbar\nbaz\n".into(),
#[cfg(feature = "ast-span")]
span: Span::default(),
#[cfg(feature = "ast-parent")]
parent: None,
}]
);

Expand Down
4 changes: 2 additions & 2 deletions src/validator/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub struct JSONValidator<'a> {
cddl_location: String,
json_location: String,
// Occurrence indicator detected in current state of AST evaluation
occurrence: Option<Occur<'a>>,
occurrence: Option<Occur>,
// Current group entry index detected in current state of AST evaluation
group_entry_idx: Option<usize>,
// JSON object value hoisted from previous state of AST evaluation
Expand Down Expand Up @@ -193,7 +193,7 @@ pub struct JSONValidator<'a> {
// fails as detected during the current state of AST evaluation
advance_to_next_entry: bool,
is_ctrl_map_equality: bool,
entry_counts: Option<Vec<EntryCount<'a>>>,
entry_counts: Option<Vec<EntryCount>>,
// Collect map entry keys that have already been validated
validated_keys: Option<Vec<String>>,
// Collect map entry values that have yet to be validated
Expand Down
6 changes: 3 additions & 3 deletions src/validator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ pub fn validate_array_occurrence<'de, T: Deserialize<'de>>(
/// entries in arrays, but may be useful in other contexts. The occurrence is
/// only captured for the second element of the CDDL array to avoid ambiguity in
/// non-homogenous array definitions
pub fn entry_counts_from_group<'a>(cddl: &'a CDDL, group: Group<'a>) -> Vec<EntryCount<'a>> {
pub fn entry_counts_from_group<'a>(cddl: &'a CDDL, group: Group<'a>) -> Vec<EntryCount> {
// Each EntryCount is associated with a group choice in the given group
let mut entry_counts = Vec::new();

Expand Down Expand Up @@ -1044,11 +1044,11 @@ pub fn validate_entry_count(valid_entry_counts: &[EntryCount], num_entries: usiz

/// Entry count
#[derive(Clone, Debug)]
pub struct EntryCount<'a> {
pub struct EntryCount {
/// Count
pub count: u64,
/// Optional occurrence
pub entry_occurrence: Option<Occur<'a>>,
pub entry_occurrence: Option<Occur>,
}

/// Regex needs to be formatted in a certain way so it can be parsed. See
Expand Down
Loading

0 comments on commit b991d3e

Please sign in to comment.