Skip to content

Commit

Permalink
feat: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Fumuran committed Jan 30, 2023
1 parent 4c87098 commit 6d2eafb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
5 changes: 3 additions & 2 deletions parser/src/ast/random_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use super::Identifier;
///
/// created [RandomValues] instance will look like
///
/// `RandomValues{name: "rand", size: 2, bindings: [RandBinding{name: "a", size: 1}, RandBinding{name: "b", size: 12}]}`
/// `RandomValues{name: "rand", size: 13, bindings: [RandBinding{name: "a", size: 1}, RandBinding{name: "b", size: 12}]}`
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct RandomValues {
name: Identifier,
Expand Down Expand Up @@ -61,7 +61,8 @@ impl RandomValues {
}
}

/// Declaration of a random value used in [RandomValues]. It is represented by a named identifier and its size.
/// Declaration of a random value binding used in [RandomValues]. It is represented by a named
/// identifier and its size.
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct RandBinding {
name: Identifier,
Expand Down
6 changes: 3 additions & 3 deletions parser/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ pub enum Error {

#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ParseError {
InvalidInt(String),
InvalidTraceCols(String),
InvalidConst(String),
InvalidInt(String),
InvalidRandomValues(String),
MissingMainTraceCols(String),
InvalidTraceCols(String),
MissingBoundaryConstraint(String),
MissingIntegrityConstraint(String),
MissingMainTraceCols(String),
}
1 change: 0 additions & 1 deletion parser/src/parser/grammar.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ RandValuesDecl: RandomValues = {
}
),
<name: Identifier> ":" "[" <rand_vec: CommaElems<RandElem>> "]" => RandomValues::new(name, rand_vec.iter().map(|v| v.size()).sum(), rand_vec)

}

RandElem: RandBinding = {
Expand Down
2 changes: 1 addition & 1 deletion parser/src/parser/tests/random_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn random_values_ident_vector_custom_name() {
fn random_values_empty_list_error() {
let source = "
random_values:
rand: []";
rand: [ ]";
let error = Error::ParseError(ParseError::InvalidRandomValues(
"Random Values section cannot be empty".to_string(),
));
Expand Down

0 comments on commit 6d2eafb

Please sign in to comment.