use proptest_derive::Arbitrary;
use std::borrow::Cow;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum Separator {
Eq,
Colon,
DoubleColon,
}
#[derive(Copy, Clone, Debug, Arbitrary, PartialEq)]
pub enum QuoteType {
Single,
Double,
Backtick,
}
#[derive(Clone, Debug, Arbitrary, PartialEq)]
pub enum Delimiter {
Paren,
Bracket,
Brace,
Angle,
}
#[derive(Clone, Debug, PartialEq)]
pub struct AnyString<'a> {
pub prefix: Cow<'a, str>,
pub ty: QuoteType,
pub contents: Cow<'a, str>,
pub num_hashtags: usize,
pub suffix: Cow<'a, str>,
}
#[derive(Clone, Debug, PartialEq)]
pub struct Space<'a>(pub Cow<'a, str>);
#[derive(Copy, Clone, Debug, PartialEq, Arbitrary)]
pub enum PathSep {
None,
Slash,
Backslash,
}
#[derive(Clone, Debug, PartialEq)]
pub struct PathSegment<'a> {
pub leading_separator: PathSep,
pub segment: Cow<'a, str>,
}
#[derive(Clone, Debug, PartialEq)]
pub struct FileLocation<'a> {
pub line: Cow<'a, str>,
pub offset: Option<Cow<'a, str>>,
}
#[derive(Clone, Debug, PartialEq)]
pub struct FileName<'a> {
pub leading_separator: PathSep,
pub segment: Cow<'a, str>,
pub ext_excluding_dot: Option<Cow<'a, str>>,
pub location: Option<FileLocation<'a>>,
}
#[derive(Clone, Debug, PartialEq)]
pub struct Path<'a> {
pub drive_excluding_colon: Option<char>,
pub segments: Vec<PathSegment<'a>>,
pub filename: FileName<'a>,
}
#[derive(Clone, Debug, PartialEq)]
pub struct Number<'a>(pub Cow<'a, str>);
#[derive(Clone, Debug, PartialEq)]
pub enum Atom<'a> {
Text(Cow<'a, str>),
}
#[derive(Clone, Debug, PartialEq)]
pub enum Token<'a> {
True,
False,
None,
Path(Path<'a>),
String(AnyString<'a>),
Number(Number<'a>),
Separated {
before: Box<Token<'a>>,
space_before: Space<'a>,
separator: Separator,
after: Box<Segment<'a>>,
},
Delimited(Delimited<'a>),
Atom(Atom<'a>),
}
#[derive(Clone, Debug, PartialEq)]
pub struct Delimited<'a> {
pub prefix: Option<Atom<'a>>,
pub delimiter: Delimiter,
pub contents: Segments<'a>,
}
#[derive(Clone, Debug, PartialEq)]
pub struct Segment<'a> {
pub leading_space: Space<'a>,
pub token: Token<'a>,
}
#[derive(Clone, Debug, PartialEq)]
pub struct Segments<'a> {
pub segments: Vec<Segment<'a>>,
pub trailing_space: Space<'a>,
}