summary refs log tree commit diff
path: root/src/path.lalrpop
diff options
context:
space:
mode:
Diffstat (limited to 'src/path.lalrpop')
-rw-r--r--src/path.lalrpop38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/path.lalrpop b/src/path.lalrpop
new file mode 100644
index 0000000..099b217
--- /dev/null
+++ b/src/path.lalrpop
@@ -0,0 +1,38 @@
+grammar;
+
+pub PathList: Vec<&'input str> = {
+  => {
+    Vec::new()
+  },
+  <mut left:(<Path> COLON)*> <right:Path> => {
+    left.push(right);
+    left
+  },
+};
+
+pub PathListAllowingEmptyPaths: Vec<&'input str> = {
+  => vec![""],
+  Path => vec![<>],
+  <mut left:PathListAllowingEmptyPaths> COLON => {
+    left.push("");
+    left
+  },
+  <mut left:PathListAllowingEmptyPaths> COLON <right:Path> => {
+    left.push(right);
+    left
+  },
+}
+
+pub Path: &'input str = {
+  <PATH_COMPONENT>,
+}
+
+// Whitespace is not allowed.
+match {
+  r"[^z:/]+" => PATH_COMPONENT,
+
+  r"/" => SLASH,
+
+  ":" => COLON,
+}
+