Skip to content

Commit

Permalink
feat: support whitespaces between key value pair
Browse files Browse the repository at this point in the history
  • Loading branch information
mitfik committed Mar 21, 2024
1 parent 267b39e commit 6c0c59c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions oca-file/src/ocafile.pest
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ws = _{ " " | "\t" }

meta_attr_key = ${ "name" | "version" }
meta_attr_value = ${ string | char+}
meta_key_pair = @{ meta_attr_key ~ "=" ~ meta_attr_value }
meta_key_pair = @{ meta_attr_key ~ arg_ws? ~ "=" ~ arg_ws? ~ meta_attr_value }
meta_comment = @{ "--" ~ ws* ~ (!NEWLINE ~ meta_key_pair)* }
meta_comment_line = _{ ws* ~ meta_comment ~ NEWLINE? }

Expand Down Expand Up @@ -184,7 +184,7 @@ remove_label = { ^"label" ~ arg_ws ~ lang ~ (arg_ws ~ attrs_key ~ attr_key+)? }
attr_key = ${ (ASCII_ALPHANUMERIC | "-" | "_" )+ }
prop_key = ${ (ASCII_ALPHANUMERIC | "-" | "_")+ }
key_value = ${ string | char+}
key_pair = @{ attr_key ~ "=" ~ key_value }
key_pair = @{ attr_key ~ arg_ws? ~ "=" ~ arg_ws? ~ key_value }
attr_key_pairs = ${ (arg_ws? ~ key_pair ~ arg_ws?)+ }
prop_key_pairs = ${ (arg_ws? ~ key_pair ~ arg_ws?)+ }

Expand Down Expand Up @@ -219,7 +219,7 @@ refn = _{^"refn:"}
ref_said = _{ refs ~ said}
ref_alias = _{ refn ~ alias }
_attr_type = ${ base_attr_type | array_attr_type | ref_said | ref_alias }
attr_pair = @{attr_key ~ "=" ~ _attr_type}
attr_pair = @{attr_key ~ arg_ws? ~ "=" ~ arg_ws? ~ _attr_type}
attr_pairs = ${ (arg_ws ~ attr_pair)+}

lang = ${ ASCII_ALPHA{2} ~ ("-" ~ ASCII_ALPHA{2})? }
Expand Down
2 changes: 1 addition & 1 deletion oca-file/src/ocafile/instructions/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ mod tests {
fn test_add_attribute_instruction() {
// test vector with example instruction and boolean if they should be valid or not
let instructions = vec![
("ADD ATTRIBUTE documentNumber=Array[refn:dokument]", true),
("ADD ATTRIBUTE documentNumber = Array[refn:dokument]", true),
("ADD ATTRIBUTE documentNumber=Array[Array[Array[refn:dokument]]]", true),
("ADD ATTRIBUTE documentNumber=Array[ refs:ENyO7FUBx7oILUYt8FwmLaDVmvOZGETXWHICultMSEpW ]", true),
("ADD ATTRIBUTE documentNumber=Array[refn:klient, refs:ENyO7FUBx7oILUYt8FwmLaDVmvOZGETXWHICultMSEpW]", false),
Expand Down
4 changes: 2 additions & 2 deletions tests/build_from_ocafile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ mod test {
let db_cache = InMemoryDataStorage::new();
let cache_storage_config = SQLiteConfig::build().unwrap();
let ocafile = r#"
ADD ATTRIBUTE d=Text i=Text passed=Boolean
ADD META en PROPS name="Entrance credential" description="Entrance credential"
ADD ATTRIBUTE d=Text i = Text passed=Boolean
ADD META en PROPS name = "Entrance credential" description = "Entrance credential"
ADD CHARACTER_ENCODING ATTRS d=utf-8 i=utf-8 passed=utf-8
ADD CONFORMANCE ATTRS d=M i=M passed=M
ADD LABEL en ATTRS d="Schema digest" i="Credential Issuee" passed="Passed"
Expand Down

0 comments on commit 6c0c59c

Please sign in to comment.