Fixed bug in parser. Added opt_vec_at() fn.

[?]
CrEcTsRjb1hHQjHuumqRfqdbVV4X58iLEubi4noaDPFa
Jul 25, 2021, 2:29 AM
WPR2A6Y7OMJ7JIO7LNFVUR5YSB34HFWWZNGQLAQOJBFGUCNLNA4QC

Dependencies

Change contents

  • replacement in src/parser.rs at line 122
    [3.4577][3.535:600]()
    Err(first_token_must_be_key(&token.to_string()))
    [3.4577]
    [3.4660]
    Err(first_token_must_be_key(
    file!(),
    line!(),
    &token.to_string()
    ))
  • edit in src/parser.rs at line 169
    [3.658]
    [3.658]
    file!(),
    line!(),
  • replacement in src/parser.rs at line 309
    [3.11108][3.11108:11165]()
    key: &s[start_key..=pos],
    [3.11108]
    [3.11165]
    key: &s[start_key..=end_key],
  • edit in src/parser.rs at line 385
    [3.841]
    [2.123]
    file!(),
    line!(),
  • edit in src/parser.rs at line 396
    [3.931]
    [3.931]
    file!(),
    line!(),
  • replacement in src/parser.rs at line 407
    [3.13974][3.1022:1076]()
    return Err(no_space_after_key());
    [3.13974]
    [3.14046]
    line += 1;
    let token_str = &s[start_key..=pos - 1];
    return Err(no_space_after_key(
    file!(),
    line!(),
    &token_str.to_string(),
    line,
    ));
  • edit in src/parser.rs at line 423
    [3.1051]
    [3.1077]
    file!(),
    line!(),
  • edit in src/parser.rs at line 435
    [3.1148]
    [3.1160]
    file!(),
    line!(),
  • replacement in src/parser.rs at line 446
    [3.14620][3.14620:14661](),[3.14661][3.1173:1224]()
    // line_start = pos;
    return Err(colon_before_key())
    [3.14620]
    [3.14732]
    line += 1;
    let token_str = &s[start_key..=pos - 1];
    return Err(colon_before_key(
    file!(),
    line!(),
    &token_str.to_string(),
    line,
    ))
  • replacement in src/parser.rs at line 456
    [3.14794][3.14794:14834](),[3.14834][3.1225:1276]()
    // start_key = pos;
    return Err(colon_before_key())
    [3.14794]
    [3.14905]
    line += 1;
    let token_str = &s[start_key..=pos - 1];
    return Err(colon_before_key(
    file!(),
    line!(),
    &token_str.to_string(),
    line,
    ))
  • replacement in src/parser.rs at line 466
    [3.14968][3.1277:1330]()
    return Err(no_space_after_key())
    [3.14968]
    [3.15040]
    line += 1;
    let token_str = &s[start_key..=pos - 1];
    return Err(no_space_after_key(
    file!(),
    line!(),
    &token_str.to_string(),
    line,
    ))
  • replacement in src/parser.rs at line 479
    [3.15385][3.1247:1300]()
    return Err(no_space_after_key())
    [3.15385]
    [3.15457]
    line += 1;
    let token_str = &s[start_key..=pos - 1];
    return Err(no_space_after_key(
    file!(),
    line!(),
    &token_str.to_string(),
    line,
    ))
  • edit in src/parser.rs at line 501
    [3.1458]
    [3.1301]
    file!(),
    line!(),
  • edit in src/parser.rs at line 513
    [3.1543]
    [3.1380]
    file!(),
    line!(),
  • replacement in src/parser.rs at line 569
    [3.17635][3.1564:1593]()
    Err(no_tokens())
    [3.17635]
    [3.17684]
    Err(no_tokens(
    file!(),
    line!(),
    ))
  • replacement in src/lib.rs at line 349
    [3.30][3.22838:22889](),[3.22838][3.22838:22889]()
    pub struct KeyTreeRef<'a>(&'a KeyTree<'a>, usize);
    [3.30]
    [3.22889]
    pub struct KeyTreeRef<'a>(&'a KeyTree<'a>, pub usize);
  • replacement in src/lib.rs at line 433
    [2.4819][2.4819:4889]()
    _ => Err(expected_unique_keyvalue_found_multi(key_path)),
    [2.4819]
    [3.23294]
    _ => Err(expected_unique_keyvalue_found_multi(file!(), line!(), key_path)),
  • replacement in src/lib.rs at line 445
    [2.5165][2.5165:5234]()
    0 => Err(expected_unique_keyvalue_found_none(key_path)),
    [2.5165]
    [2.5234]
    0 => Err(expected_unique_keyvalue_found_none(file!(), line!(), key_path)),
  • replacement in src/lib.rs at line 447
    [2.5275][2.5275:5345]()
    _ => Err(expected_unique_keyvalue_found_multi(key_path)),
    [2.5275]
    [2.5345]
    _ => Err(expected_unique_keyvalue_found_multi(file!(), line!(), key_path)),
  • replacement in src/lib.rs at line 458
    [2.5574][2.5574:5643]()
    0 => Err(expected_unique_keyvalue_found_none(key_path)),
    [2.5574]
    [2.5643]
    0 => Err(expected_unique_keyvalue_found_none(file!(), line!(), key_path)),
  • replacement in src/lib.rs at line 460
    [2.5689][2.5689:5759]()
    _ => Err(expected_unique_keyvalue_found_multi(key_path)),
    [2.5689]
    [2.5759]
    _ => Err(expected_unique_keyvalue_found_multi(file!(), line!(), key_path)),
  • replacement in src/lib.rs at line 473
    [2.6069][2.6069:6139]()
    _ => Err(expected_unique_keyvalue_found_multi(key_path)),
    [2.6069]
    [2.6139]
    _ => Err(expected_unique_keyvalue_found_multi(file!(), line!(), key_path)),
  • edit in src/lib.rs at line 492
    [2.6540]
    [2.6540]
    where
    KeyTreeRef<'a>: TryInto<T>,
    KeyTreeRef<'a>: TryInto<T, Error = Error>,
    {
    let path = KeyPath::from_str(key_path);
    let kts = self.resolve_path(&path)?;
    let mut v = Vec::new();
    for kt in kts {
    v.push(kt.key_into()?)
    }
    if v.is_empty() {
    return Err(expected_non_empty_collection(
    file!(),
    line!(),
    key_path
    ))
    };
    Ok(v)
    }
    pub fn opt_vec_at<T>(&self, key_path: &str) -> Result<Vec<T>>
  • replacement in src/error.rs at line 19
    [2.9603][2.9603:9664]()
    "[01] line {}, token [{}]. Bad first segment [{}].",
    [2.9603]
    [2.9664]
    "[keytree:01] line {}, token [{}]. Bad first segment [{}].",
  • replacement in src/error.rs at line 28
    [2.9807][2.9807:9876]()
    "[02] line {}, token [{}]. Indentation of {} is incorrect.",
    [2.9807]
    [2.9876]
    "[keytree:02] line {}, token [{}]. Indentation of {} is incorrect.",
  • replacement in src/error.rs at line 37
    [2.10027][2.10027:10100]()
    "[03] line {}, token [{}], Cannot resolve token with siblings.",
    [2.10027]
    [2.10100]
    "[keytree:03] line {}, token [{}]. Cannot resolve token with siblings.",
  • replacement in src/error.rs at line 43
    [3.40368][2.10137:10224]()
    pub fn colon_before_key() -> Error {
    Error(String::from("[03] Colon before key."))
    [3.40368]
    [3.2834]
    pub fn colon_before_key(file: &str, code_line: u32, token: &str, line: usize) -> Error {
    Error(format!(
    "[keytree:04:{}:{}] Line {}, token [{}]. Colon before key.",
    file,
    code_line,
    line,
    token,
    ))
  • replacement in src/error.rs at line 54
    [2.10256][2.10256:10300]()
    Error(String::from("[04] Empty path."))
    [2.10256]
    [2.10300]
    Error(String::from("[keytree:05] Empty path."))
  • replacement in src/error.rs at line 58
    [2.10336][2.10336:10393]()
    Error(String::from("[05] Keytree string is empty."))
    [2.10336]
    [3.3058]
    Error(String::from("[keytree:06] Keytree string is empty."))
  • replacement in src/error.rs at line 63
    [2.10485][2.10485:10562]()
    "[06] line {}, token [{}]. Expected [key:] but found [key: value].",
    [2.10485]
    [2.10562]
    "[keytree:07] line {}, token [{}]. Expected [key:] but found [key: value].",
  • replacement in src/error.rs at line 71
    [2.10692][2.10692:10769]()
    "[07] line {}, token [{}]. Expected [key: value] but found [key:].",
    [2.10692]
    [2.10769]
    "[keytree:08] line {}, token [{}]. Expected [key: value] but found [key:].",
  • edit in src/error.rs at line 77
    [2.10808]
    [2.10808]
    pub fn expected_non_empty_collection(code_file: &str, code_line: u32, keypath: &str) -> Error {
    Error(format!(
    "[keytree:09:{}:{}] Expected non-empty collection at [{}].",
    code_file,
    code_line,
    keypath,
    ))
    }
  • replacement in src/error.rs at line 88
    [2.10889][2.10889:10969]()
    "[08] keypath: [{}]. Expected unique token but found multiple tokens.",
    [2.10889]
    [2.10969]
    "[keytree:09] keypath: [{}]. Expected unique token but found multiple tokens.",
  • replacement in src/error.rs at line 93
    [3.43462][2.10995:11066]()
    pub fn expected_unique_keyvalue_found_multi(key_path: &str) -> Error {
    [3.43462]
    [2.11066]
    pub fn expected_unique_keyvalue_found_multi(file: &str, code_line: u32, key_path: &str) -> Error {
  • replacement in src/error.rs at line 95
    [2.11085][2.11085:11172]()
    "[09] keypath: [{}]. Expected unique [key: value] but found multiple tokens.",
    [2.11085]
    [2.11172]
    "[keytree:10:{}:{}] keypath: [{}]. Expected unique [key: value] but found multiple tokens.",
    file,
    code_line,
  • replacement in src/error.rs at line 102
    [3.43585][2.11198:11268]()
    pub fn expected_unique_keyvalue_found_none(key_path: &str) -> Error {
    [3.43585]
    [2.11268]
    pub fn expected_unique_keyvalue_found_none(file: &str, code_line: u32, key_path: &str) -> Error {
  • replacement in src/error.rs at line 104
    [2.11287][2.11287:11363]()
    "[10] keypath: [{}]. Expected unique [key: value] but found none.",
    [2.11287]
    [2.11363]
    "[keytree:11:{}:{}] Keypath [{}]. Expected unique [key: value] but found none.",
    file,
    code_line,
  • replacement in src/error.rs at line 111
    [2.11391][2.11391:11445](),[3.6808][3.3345:3356](),[2.11445][3.3345:3356](),[3.3345][3.3345:3356](),[3.3356][2.11446:11519](),[2.11519][3.3509:3515](),[3.3509][3.3509:3515]()
    pub fn expected_unique_token_found_multi() -> Error {
    Error(
    String::from("[11] Expected a unique token but found multiple.")
    )
    [2.11391]
    [3.3515]
    pub fn expected_unique_token_found_multi(file: &str, code_line: u32, key_path: &str) -> Error {
    Error(format!(
    "[keytree:12:{}:{}] Keypath [{}]. Expected a unique token but found multiple.",
    file,
    code_line,
    key_path,
    ))
  • replacement in src/error.rs at line 122
    [2.11605][2.11605:11665]()
    "[12] line {}, token [{}]. Failed to parse value.",
    [2.11605]
    [2.11665]
    "[keytree:13] line {}, token [{}]. Failed to parse value.",
  • replacement in src/error.rs at line 128
    [3.43814][2.11704:11759]()
    pub fn first_token_must_be_key(token: &str) -> Error {
    [3.43814]
    [2.11759]
    pub fn first_token_must_be_key(file: &str, code_line: u32, token: &str) -> Error {
  • replacement in src/error.rs at line 130
    [2.11778][2.11778:11832]()
    "[13] token {}. First token must be [key:].",
    [2.11778]
    [2.11832]
    "[keytree:14:{}:{}] token {}. First token must be [key:].",
    file,
    code_line,
  • replacement in src/error.rs at line 139
    [2.11957][2.11957:12036]()
    "[14] line {}, token [{}]. The first segment of [{}] does not match.",
    [2.11957]
    [2.12036]
    "[keytree:15] line {}, token [{}]. The first segment of [{}] does not match.",
  • replacement in src/error.rs at line 146
    [3.43945][3.7013:7083]()
    pub fn incomplete_comment_or_key(token: &str, line: usize) -> Error {
    [3.43945]
    [2.12091]
    pub fn incomplete_comment_or_key(file: &str, code_line: u32, token: &str, line: usize) -> Error {
  • replacement in src/error.rs at line 148
    [2.12110][2.12110:12174]()
    "[15] line {}, token [{}]. Incomplete comment or key.",
    [2.12110]
    [2.12174]
    "[keytree:16:{}:{}] line {}, token [{}]. Incomplete comment or key.",
    file,
    code_line,
  • replacement in src/error.rs at line 156
    [3.43946][3.7084:7144]()
    pub fn incomplete_line(token: &str, line: usize) -> Error {
    [3.43946]
    [2.12211]
    pub fn incomplete_line(file: &str, code_line: u32, token: &str, line: usize) -> Error {
  • replacement in src/error.rs at line 158
    [2.12230][2.12230:12283]()
    "[16] line {}, token [{}]. Incomplete line.",
    [2.12230]
    [2.12283]
    "[keytree:17:{}:{}] line {}, token [{}]. Incomplete line.",
    file,
    code_line,
  • replacement in src/error.rs at line 168
    [2.12433][2.12433:12517]()
    "[17] line {}, token [{}], keypath [{}]. Keypath extends beyond keyvalue.",
    [2.12433]
    [2.12517]
    "[keytree:18] line {} token [{}], keypath [{}]. Keypath extends beyond keyvalue.",
  • replacement in src/error.rs at line 176
    [2.12647][2.12647:12728]()
    Error(format!( "[18] Keypath {} must have two or more segments.", key_path))
    [2.12647]
    [3.3949]
    Error(format!( "[keytree:19] Keypath {} must have two or more segments.", key_path))
  • replacement in src/error.rs at line 181
    [2.12842][2.12842:12918]()
    "[19] line {}, token [{}]. Keypath segment {} does not match key.",
    [2.12842]
    [2.12918]
    "[keytree:20] line {} token [{}]. Keypath segment {} does not match key.",
  • replacement in src/error.rs at line 190
    [2.13069][2.13069:13130]()
    "[20] line {}, token [{}]. Failed to find key [{}]",
    [2.13069]
    [2.13130]
    "[keytree:21] line {} token [{}]. Failed to find key [{}]",
  • replacement in src/error.rs at line 197
    [3.351][2.13180:13243]()
    pub fn no_colon_after_key(token: &str, line: usize) -> Error {
    [3.351]
    [2.13243]
    pub fn no_colon_after_key(file: &str, code_line: u32, token: &str, line: usize) -> Error {
  • replacement in src/error.rs at line 199
    [2.13262][2.13262:13319]()
    "[21] line {}, token [{}], No colon after key.",
    [2.13262]
    [2.13319]
    "[keytree:22:{}:{}] line {} token [{}], No colon after key.",
    file,
    code_line,
  • replacement in src/error.rs at line 207
    [3.45249][3.4344:4383](),[3.4383][2.13356:13408]()
    pub fn no_space_after_key() -> Error {
    Error(String::from("[22] No space after key."))
    [3.45249]
    [3.4430]
    pub fn no_space_after_key(file: &str, code_line: u32, token: &str, line: usize) -> Error {
    Error(format!(
    "[keytree:23:{}:{}] line {} token [{}]. No space after key.",
    file,
    code_line,
    line,
    token,
    ))
  • replacement in src/error.rs at line 217
    [3.47290][3.4433:4463](),[3.4463][2.13409:13452]()
    pub fn no_tokens() -> Error {
    Error(String::from("[23] No tokens."))
    [3.47290]
    [3.47727]
    pub fn no_tokens(file: &str, code_line: u32) -> Error {
    Error(format!(
    "[keytree:24:{}:{}] No tokens in parsed keytree.",
    file,
    code_line,
    ))
  • replacement in src/error.rs at line 225
    [3.47730][2.13453:13522]()
    pub fn non_root_has_zero_indent(token: &str, line: usize) -> Error {
    [3.47730]
    [2.13522]
    pub fn non_root_has_zero_indent(file: &str, code_line: u32, token: &str, line: usize) -> Error {
  • replacement in src/error.rs at line 227
    [2.13541][2.13541:13622]()
    "[24] line {}, token [{}]. Token other than root token as zero indent.",
    [2.13541]
    [2.13622]
    "[keytree:25:{}:{}] line {}, token [{}]. Token other than root token as zero indent.",
    file,
    code_line,