summary refs log tree commit diff
path: root/src/path
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2024-03-12 21:54:28 -0700
committerIrene Knapp <ireneista@irenes.space>2024-03-12 21:54:28 -0700
commit7be9acd0bb08901c9fdfa45b694b7d3d5a594e70 (patch)
tree8a38a3ff200bae284fc0e2009220dacf0b53205b /src/path
parent3086d361665aedf840f76ded2f46c6ff5204f776 (diff)
remove a lot of stuff that was part of the shell and does not need to be part of the line input library
Change-Id: Idd0435a4b29f5f525c9279e5c1d27916e6320685
Diffstat (limited to 'src/path')
-rw-r--r--src/path/error.rs79
-rw-r--r--src/path/parser.lalrpop92
-rw-r--r--src/path/prelude.rs5
3 files changed, 0 insertions, 176 deletions
diff --git a/src/path/error.rs b/src/path/error.rs
deleted file mode 100644
index aee6e9f..0000000
--- a/src/path/error.rs
+++ /dev/null
@@ -1,79 +0,0 @@
-#![forbid(unsafe_code)]
-
-use crate::path::GenericPath;
-
-pub type Result<T> = std::result::Result<T, PathError>;
-
-
-#[derive(Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)]
-pub enum FileNameError {
-  ContainsSlash(String),
-}
-
-#[derive(Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)]
-pub enum DirectoryNameError {
-  ContainsSlash(String),
-}
-
-#[derive(Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)]
-pub enum PathError {
-  Parse(String),
-  PathLexicallyDirectory(GenericPath),
-  PathLexicallyRelative(GenericPath),
-  PathLexicallyInvalid(GenericPath),
-  PathListHasEmptyComponents(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 {
-      FileNameError::ContainsSlash(s) =>
-        f.write_fmt(format_args!(
-            "File names cannot contain slashes, but {:?} does.", s)),
-    }
-  }
-}
-
-impl std::fmt::Display for DirectoryNameError {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-    match self {
-      DirectoryNameError::ContainsSlash(s) =>
-        f.write_fmt(format_args!(
-            "File names cannot contain slashes, but {:?} does.", s)),
-    }
-  }
-}
-
-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)),
-      PathError::PathLexicallyDirectory(path) =>
-        f.write_fmt(format_args!(
-            "The path {} ends in a slash, but is supposed to refer to a file, \
-             not a directory.",
-            path)),
-      PathError::PathLexicallyRelative(path) =>
-        f.write_fmt(format_args!(
-            "The path {} is relative, not absolute.",
-            path)),
-      PathError::PathLexicallyInvalid(path) =>
-        f.write_fmt(format_args!(
-            "This isn't a valid path. {}",
-            path)),
-      PathError::PathListHasEmptyComponents(path_list) =>
-        f.write_fmt(format_args!(
-            "Path list has empty components: {}",
-            path_list)),
-    }
-  }
-}
-
diff --git a/src/path/parser.lalrpop b/src/path/parser.lalrpop
deleted file mode 100644
index c41b3fd..0000000
--- a/src/path/parser.lalrpop
+++ /dev/null
@@ -1,92 +0,0 @@
-grammar;
-
-use crate::path::GenericPath;
-use crate::path::GenericPathComponent;
-
-pub PathList: Vec<GenericPath> = {
-  => {
-    Vec::new()
-  },
-  <mut left:(<PathNoColons> COLON)*> <right:PathNoColons> => {
-    left.push(right);
-    left
-  },
-};
-
-pub PathListAllowingEmptyPaths: Vec<GenericPath> = {
-  => vec![GenericPath {
-    components: Vec::new(),
-    starts_with_slash: false,
-    ends_with_slash: false,
-  }],
-  PathNoColons => vec![<>],
-  <mut left:PathListAllowingEmptyPaths> COLON => {
-    left.push(GenericPath {
-      components: Vec::new(),
-      starts_with_slash: false,
-      ends_with_slash: false,
-    });
-    left
-  },
-  <mut left:PathListAllowingEmptyPaths> COLON <right:PathNoColons> => {
-    left.push(right);
-    left
-  },
-}
-
-pub PathNoColons: GenericPath = {
-  SLASH => GenericPath {
-    components: Vec::new(),
-    starts_with_slash: true,
-    ends_with_slash: true,
-  },
-  <PathNoColons2> => GenericPath {
-    components: <>,
-    starts_with_slash: false,
-    ends_with_slash: false,
-  },
-  <PathNoColons2> SLASH => GenericPath {
-    components: <>,
-    starts_with_slash: false,
-    ends_with_slash: true,
-  },
-  SLASH <PathNoColons2> => GenericPath {
-    components: <>,
-    starts_with_slash: true,
-    ends_with_slash: false,
-  },
-  SLASH <PathNoColons2> SLASH => GenericPath {
-    components: <>,
-    starts_with_slash: true,
-    ends_with_slash: true,
-  },
-}
-
-PathNoColons2: Vec<GenericPathComponent> = {
-  <PathComponent> => vec![<>],
-  <mut left:PathNoColons2> SLASH <right:PathComponent> => {
-    left.push(right);
-    left
-  }
-}
-
-pub PathComponent: GenericPathComponent = {
-  DOT => GenericPathComponent::CurrentDirectory,
-  DOT_DOT => GenericPathComponent::ParentDirectory,
-  <PATH_COMPONENT_NO_COLONS> =>
-    GenericPathComponent::FileOrDirectoryName(<>.to_string())
-}
-
-// Whitespace is not allowed.
-match {
-  r"[^:/]+" => PATH_COMPONENT_NO_COLONS,
-
-  r"/" => SLASH,
-
-  ":" => COLON,
-
-  "." => DOT,
-
-  ".." => DOT_DOT,
-}
-
diff --git a/src/path/prelude.rs b/src/path/prelude.rs
deleted file mode 100644
index f7b23dd..0000000
--- a/src/path/prelude.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-#![forbid(unsafe_code)]
-
-pub use crate::path::error::{
-    Result, DirectoryNameError, FileNameError, PathError};
-