grammar; use crate::path::GenericPath; use crate::path::GenericPathComponent; pub PathList: Vec = { => { Vec::new() }, COLON)*> => { left.push(right); left }, }; pub PathListAllowingEmptyPaths: Vec = { => vec![GenericPath { components: Vec::new(), starts_with_slash: false, ends_with_slash: false, }], PathNoColons => vec![<>], COLON => { left.push(GenericPath { components: Vec::new(), starts_with_slash: false, ends_with_slash: false, }); left }, COLON => { left.push(right); left }, } pub PathNoColons: GenericPath = { SLASH => GenericPath { components: Vec::new(), starts_with_slash: true, ends_with_slash: true, }, => GenericPath { components: <>, starts_with_slash: false, ends_with_slash: false, }, SLASH => GenericPath { components: <>, starts_with_slash: false, ends_with_slash: true, }, SLASH => GenericPath { components: <>, starts_with_slash: true, ends_with_slash: false, }, SLASH SLASH => GenericPath { components: <>, starts_with_slash: true, ends_with_slash: true, }, } PathNoColons2: Vec = { => vec![<>], SLASH => { left.push(right); left } } PathComponent: GenericPathComponent = { DOT => GenericPathComponent::CurrentDirectory, DOT_DOT => GenericPathComponent::ParentDirectory, => GenericPathComponent::FileOrDirectoryName(<>.to_string()) } // Whitespace is not allowed. match { r"[^:/]+" => PATH_COMPONENT_NO_COLONS, r"/" => SLASH, ":" => COLON, "." => DOT, ".." => DOT_DOT, }