raw_char = _{ !(sigil) ~ ANY }
char_seq = { raw_char+ }
-string = @{ "\"" ~ char+ ~ "\"" }
+string = { escaped_string | raw_string }
+escaped_string = @{ "\"" ~ char+ ~ "\"" }
+raw_string = @{ "'" ~ (!("'") ~ ANY)+ ~ "'" }
char = _{
!("\"" | "\\") ~ ANY
| "\\" ~ ("\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t")
key = pair.as_str();
}
if Rule::value == pair.as_rule() {
- val = pair.as_str();
+ let tmp = pair.as_str();
+ // blank and default shoud be handled by whoever is getting the value
+ // set it to empty strings do remove it from the HashMap
+ if tmp == "BLANK" || tmp == "DEFAULT" {
+ return ("", "");
+ }
+ // remove surrounding quotes from values
+ val = &tmp[1..tmp.len() - 1];
}
}
for pair in pairs {
if Rule::string == pair.as_rule() {
- vec.push(pair.as_str());
+ let tmp = pair.as_str();
+ // remove surrounding quotes from values
+ let val = &tmp[1..tmp.len() - 1];
+ vec.push(val);
}
}
vec
&vec!["stuff", "with", "spaces"]
);
assert_eq!(source.arrays.get("not_defined"), None);
- assert_eq!(source.arrays.get("blank"), None);
assert_eq!(source.patterns.get("pat").unwrap(), &"pattern");
assert_eq!(source.patterns.get("pat.sub_pat"), None);
${
var = "good"
+ single = 'quotes'
blank = BLANK
}
@{
sub.array = ["sub","value"]
- arr = ["split","up","values"]
- blank = BLANK -{ post line comment }
+ arr = ["split",'up',"values"]
with_spaces = [ "stuff", "with" , "spaces" ]
}