#[derive(Debug, Clone, PartialEq, Eq)]
pub struct File {
pub statements: Vec<Statement>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Statement {
Command(CommandInvocation),
TemplatePlaceholder(String),
Comment(Comment),
BlankLines(usize),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CommandInvocation {
pub name: String,
pub arguments: Vec<Argument>,
pub trailing_comment: Option<Comment>,
pub span: (usize, usize),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Argument {
Bracket(BracketArgument),
Quoted(String),
Unquoted(String),
InlineComment(Comment),
}
impl Argument {
pub fn as_str(&self) -> &str {
match self {
Argument::Bracket(b) => &b.raw,
Argument::Quoted(s) | Argument::Unquoted(s) => s,
Argument::InlineComment(c) => c.as_str(),
}
}
pub fn is_comment(&self) -> bool {
matches!(self, Argument::InlineComment(_))
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BracketArgument {
pub level: usize,
pub raw: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Comment {
Line(String),
Bracket(String),
}
impl Comment {
pub fn as_str(&self) -> &str {
match self {
Comment::Line(s) | Comment::Bracket(s) => s,
}
}
}