diff options
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, +} + |