1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::grammar::Rule;

#[derive(Debug)]
pub(crate) enum PathSeg<'a> {
    Named(&'a str),
    Ruled(Rule),
}

pub(crate) fn merge_json_path<'a>(path_stack: &mut Vec<String>, relative_path: &[PathSeg<'a>]) {
    for seg in relative_path {
        match seg {
            PathSeg::Named(s) => {
                path_stack.push((*s).to_string());
            }
            PathSeg::Ruled(Rule::path_root) => {}
            PathSeg::Ruled(Rule::path_up) => {
                path_stack.pop();
            }
            _ => {}
        }
    }
}