use crate::scanner::Pos;
use crate::value::{Color, ListSep};
pub(crate) struct Stylesheet {
pub stmts: Vec<Stmt>,
}
pub(crate) enum Stmt {
VarDecl(VarDecl),
Rule(Rule),
Decl(Declaration),
Import(Vec<String>),
Comment(String),
}
pub(crate) struct VarDecl {
pub name: String,
pub value: Expr,
pub is_default: bool,
pub is_global: bool,
}
pub(crate) struct Rule {
pub selector: Vec<TplPiece>,
pub body: Vec<Stmt>,
pub pos: Pos,
}
pub(crate) struct Declaration {
pub property: Vec<TplPiece>,
pub value: Expr,
pub important: bool,
pub pos: Pos,
}
pub(crate) enum TplPiece {
Lit(String),
Interp(Expr),
}
pub(crate) enum Expr {
Number(f64, String),
Color(Color),
QuotedString(Vec<TplPiece>),
Ident(Vec<TplPiece>),
Bool(bool),
Null,
Var(String),
Binary {
op: BinOp,
lhs: Box<Expr>,
rhs: Box<Expr>,
pos: Pos,
},
Unary { op: UnOp, operand: Box<Expr> },
Func {
name: String,
args: Vec<CallArg>,
pos: Pos,
},
List { items: Vec<Expr>, sep: ListSep },
Paren(Box<Expr>),
Interp(Box<Expr>),
}
pub(crate) struct CallArg {
pub name: Option<String>,
pub value: Expr,
}
#[derive(Clone, Copy)]
pub(crate) enum BinOp {
Add,
Sub,
Mul,
Mod,
}
#[derive(Clone, Copy)]
pub(crate) enum UnOp {
Neg,
}