static_graph/parser/
mod.rs1pub mod annotations;
2pub mod document;
3pub mod field;
4pub mod graph;
5pub mod ident;
6pub mod literal;
7pub mod node;
8pub mod path;
9pub mod ty;
10
11use nom::character::complete::{multispace1, one_of};
12
13use nom::{
14 branch::alt,
15 bytes::complete::{tag, take_till, take_until},
16 combinator::map,
17 multi::many1,
18 sequence::{preceded, terminated},
19 IResult,
20};
21
22pub trait Parser<'a>: Sized {
23 fn parse(input: &'a str) -> IResult<&'a str, Self>;
24}
25
26fn comment(input: &str) -> IResult<&str, &str> {
27 alt((
28 preceded(tag("//"), take_till(|c| c == '\n')),
29 preceded(tag("/*"), terminated(take_until("*/"), tag("*/"))),
30 ))(input)
31}
32
33pub(crate) fn blank(input: &str) -> IResult<&str, ()> {
34 map(many1(alt((comment, multispace1))), |_| ())(input)
35}
36
37pub(crate) fn list_separator(input: &str) -> IResult<&str, char> {
38 one_of(",;")(input)
39}