Get a parser for a Starstream source file.
()
| 7 | |
| 8 | /// Get a parser for a Starstream source file. |
| 9 | pub fn parser<'a>() -> impl Parser<'a, &'a str, Program, Extra<'a>> { |
| 10 | comment::shebang() |
| 11 | .or_not() |
| 12 | .then( |
| 13 | definition() |
| 14 | .spanned() |
| 15 | .padded() |
| 16 | .repeated() |
| 17 | .collect::<Vec<_>>(), |
| 18 | ) |
| 19 | .then_ignore(end()) |
| 20 | .map(|(shebang, definitions)| Program { |
| 21 | shebang, |
| 22 | definitions, |
| 23 | }) |
| 24 | } |
| 25 | |
| 26 | // NOTE: The test cases for the root program parser are included in the |
| 27 | // compiler integration tests, rather than separated out here. |