mod elements;
mod literal;
mod value;
pub use self::{
elements::*,
literal::Literal,
value::{Array, Object, Set, Value, ValueType},
};
pub use indexmap::map::{Keys, Values};
use indexmap::{map::IndexMap, set::IndexSet};
use num::{BigInt, BigUint};
use std::{
collections::BTreeMap,
fmt::{self, Debug, Display, Formatter},
hash::{Hash, Hasher},
mem::transmute,
};
pub type ASTNode = Literal<ASTKind>;
pub type ASTNodes = Vec<Literal<ASTKind>>;
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub enum ASTKind {
Statements(ASTNodes),
Header(Box<Header>),
Paragraph(ASTNodes),
Delimiter(Box<Delimiter>),
TableView(Box<TableView>),
ListView(Box<ListView>),
CodeNode(Box<CodeNode>),
MathNode(Box<MathNode>),
LinkNode(Box<SmartLink>),
TextSpan(Box<TextNode>),
StyledSpan(Box<StyleNode>),
Command(Box<Command>),
Value(Box<Value>),
}
impl Default for ASTKind {
fn default() -> Self {
Self::Value(Box::new(Value::Null))
}
}
impl ASTKind {
pub fn statements(children: ASTNodes, range: Option<(u32, u32)>) -> ASTNode {
ASTNode { value: Self::Statements(children), range }
}
pub fn paragraph(children: ASTNodes, range: Option<(u32, u32)>) -> ASTNode {
ASTNode { value: Self::Paragraph(children), range }
}
pub fn header(children: ASTNodes, level: u8) -> Self {
let header = Header { level, children };
Self::Header(Box::new(header))
}
pub fn hr(range: Option<(u32, u32)>) -> ASTNode {
ASTNode { value: Self::Delimiter(Box::new(Delimiter::HorizontalRule)), range }
}
}