summary refs log tree commit diff
path: root/src/path.lalrpop
blob: 099b2178ca51b2d34327dd878fc33f6ebdb2fcf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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,
}