From efc68f54e3476de0bd209995c36043c26131b8df Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Fri, 25 Dec 2020 21:10:37 -0800 Subject: refactor path parsing into a separate file, implement some Display traits, etc --- src/path/parser.lalrpop | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/path') diff --git a/src/path/parser.lalrpop b/src/path/parser.lalrpop index 0b3be9a..3547444 100644 --- a/src/path/parser.lalrpop +++ b/src/path/parser.lalrpop @@ -63,14 +63,20 @@ pub PathNoColons: GenericPath = { } PathNoColons2: Vec = { - => - vec![GenericPathComponent::FileOrDirectoryName(<>.to_string())], - SLASH => { - left.push(GenericPathComponent::FileOrDirectoryName(right.to_string())); + => 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"[^z:/]+" => PATH_COMPONENT_NO_COLONS, @@ -78,5 +84,9 @@ match { r"/" => SLASH, ":" => COLON, + + "." => DOT, + + ".." => DOT_DOT, } -- cgit 1.4.1