diff options
author | Irene Knapp <ireneista@gmail.com> | 2020-12-14 20:14:11 -0800 |
---|---|---|
committer | Irene Knapp <ireneista@gmail.com> | 2020-12-14 20:14:11 -0800 |
commit | 0940e1f0bf8b9e499717b02cefe8c59601c21673 (patch) | |
tree | 80305a08b71a06e151fcd50a8d81197e42516be3 /src/path.lalrpop | |
parent | 71e647b349036069751a457f3e0e8fda1b54cd2a (diff) |
path lists parse okay now
Diffstat (limited to 'src/path.lalrpop')
-rw-r--r-- | src/path.lalrpop | 38 |
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, +} + |