summary refs log tree commit diff
path: root/src/path
diff options
context:
space:
mode:
Diffstat (limited to 'src/path')
-rw-r--r--src/path/error.rs16
-rw-r--r--src/path/parser.lalrpop2
2 files changed, 17 insertions, 1 deletions
diff --git a/src/path/error.rs b/src/path/error.rs
index 1162a3b..0ee5423 100644
--- a/src/path/error.rs
+++ b/src/path/error.rs
@@ -8,11 +8,18 @@ pub enum DirectoryNameError {
   ContainsSlash(String),
 }
 
+#[derive(Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)]
+pub enum PathError {
+  Parse(String),
+}
+
 
 impl std::error::Error for FileNameError { }
 
 impl std::error::Error for DirectoryNameError { }
 
+impl std::error::Error for PathError { }
+
 impl std::fmt::Display for FileNameError {
   fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
     match self {
@@ -33,3 +40,12 @@ impl std::fmt::Display for DirectoryNameError {
   }
 }
 
+impl std::fmt::Display for PathError {
+  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+    match self {
+      PathError::Parse(s) =>
+        f.write_fmt(format_args!("Syntax error in path: {}", s)),
+    }
+  }
+}
+
diff --git a/src/path/parser.lalrpop b/src/path/parser.lalrpop
index 9705fc3..c41b3fd 100644
--- a/src/path/parser.lalrpop
+++ b/src/path/parser.lalrpop
@@ -70,7 +70,7 @@ PathNoColons2: Vec<GenericPathComponent> = {
   }
 }
 
-PathComponent: GenericPathComponent = {
+pub PathComponent: GenericPathComponent = {
   DOT => GenericPathComponent::CurrentDirectory,
   DOT_DOT => GenericPathComponent::ParentDirectory,
   <PATH_COMPONENT_NO_COLONS> =>