use crate::token::Span;
#[derive(Debug, Clone, PartialEq)]
pub struct Program {
pub items: Vec<AndOrList>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct AndOrList {
pub first: Pipeline,
pub rest: Vec<(AndOrOp, Pipeline)>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AndOrOp {
And,
Or,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Pipeline {
pub negated: bool,
pub commands: Vec<Command>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Command {
pub assignments: Vec<Assignment>,
pub words: Vec<Word>,
pub redirects: Vec<Redirect>,
pub span: Span,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Assignment {
pub name: String,
pub value: Word,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Word {
pub parts: Vec<WordPart>,
pub span: Span,
}
#[derive(Debug, Clone, PartialEq)]
pub enum WordPart {
Text(String),
Escaped(char),
SingleQuoted(String),
DoubleQuoted(Vec<WordPart>),
Var(String),
LastExit,
CmdSubst(Box<Program>),
}
#[derive(Debug, Clone, PartialEq)]
pub enum Redirect {
Out {
stderr: bool,
append: bool,
target: Word,
},
In {
target: Word,
},
StderrToStdout,
}