use crate::ast::{Side, WireOp};
use crate::span::Span;
#[derive(Debug, Clone)]
pub struct File {
pub stylesheet: Vec<StyleItem>,
pub stylesheet_span: Span,
pub instances: Vec<Child>,
pub wires: Vec<Wire>,
}
#[derive(Debug, Clone)]
pub enum StyleItem {
RootDecl(Decl),
Var(Decl),
Rule(Rule),
Define(Define),
}
#[derive(Debug, Clone)]
pub struct Rule {
pub selector: Selector,
pub decls: Vec<Decl>,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct Selector {
pub parts: Vec<SelPart>,
}
#[derive(Debug, Clone)]
pub enum SelPart {
Type(String),
Class(String),
}
#[derive(Debug, Clone)]
pub struct Define {
pub name: String,
pub base: String,
pub style: Vec<Decl>,
pub style_span: Option<Span>,
pub children: Vec<Child>,
pub wires: Vec<Wire>,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct Node {
pub id: Option<String>,
pub ty: Option<String>,
pub classes: Vec<String>,
pub style: Vec<Decl>,
pub style_span: Option<Span>,
pub children: Vec<Child>,
pub wires: Vec<Wire>,
pub span: Span,
}
#[derive(Debug, Clone)]
pub enum Child {
Box(Node),
Text(TextNode),
}
#[derive(Debug, Clone)]
pub struct TextNode {
pub text: String,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct Wire {
pub chain: Vec<EndpointGroup>,
pub op: WireOp,
pub classes: Vec<String>,
pub style: Vec<Decl>,
pub style_span: Option<Span>,
pub labels: Vec<TextNode>,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct EndpointGroup {
pub endpoints: Vec<Endpoint>,
}
#[derive(Debug, Clone)]
pub struct Endpoint {
pub path: Vec<String>,
pub side: Option<Side>,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct Decl {
pub name: String,
pub groups: Vec<Vec<Value>>,
pub span: Span,
}
#[derive(Debug, Clone)]
pub enum Value {
Number(f64),
Percent(f64),
String(String),
Hex(String),
Ident(String),
Var(String),
Call(Call),
}
#[derive(Debug, Clone)]
pub struct Call {
pub name: String,
pub args: Vec<Value>,
}