summary refs log tree commit diff
path: root/src/path
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@gmail.com>2020-12-25 21:10:37 -0800
committerIrene Knapp <ireneista@gmail.com>2020-12-25 21:10:37 -0800
commitefc68f54e3476de0bd209995c36043c26131b8df (patch)
tree676d6915d9daa336586aeb50fb46dcaf09622efb /src/path
parentf5ec40b8fbbe7d4409d94dafcbfcdd41b8a6202b (diff)
refactor path parsing into a separate file, implement some Display traits, etc
Diffstat (limited to 'src/path')
-rw-r--r--src/path/parser.lalrpop18
1 files changed, 14 insertions, 4 deletions
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<GenericPathComponent> = {
-  <PATH_COMPONENT_NO_COLONS> =>
-      vec![GenericPathComponent::FileOrDirectoryName(<>.to_string())],
-  <mut left:PathNoColons2> SLASH <right:PATH_COMPONENT_NO_COLONS> => {
-    left.push(GenericPathComponent::FileOrDirectoryName(right.to_string()));
+  <PathComponent> => vec![<>],
+  <mut left:PathNoColons2> SLASH <right:PathComponent> => {
+    left.push(right);
     left
   }
 }
 
+PathComponent: GenericPathComponent = {
+  DOT => GenericPathComponent::CurrentDirectory,
+  DOT_DOT => GenericPathComponent::ParentDirectory,
+  <PATH_COMPONENT_NO_COLONS> =>
+    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,
 }