Add element structure

pull/1/head
trivernis 4 years ago
parent 7c345c83ec
commit 83588964c3

@ -0,0 +1,59 @@
use crate::elements::special::Expression;
#[derive(Clone, Debug)]
pub enum Group {
Parentheses(Parentheses),
Brackets(Brackets),
Braces(Braces),
Angles(Angles),
XGroup(XGroup),
Abs(Abs),
Floor(Floor),
Ceil(Ceil),
Norm(Norm),
}
#[derive(Clone, Debug)]
pub struct Parentheses {
inner: Box<Expression>,
}
#[derive(Clone, Debug)]
pub struct Brackets {
inner: Box<Expression>,
}
#[derive(Clone, Debug)]
pub struct Braces {
inner: Box<Expression>,
}
#[derive(Clone, Debug)]
pub struct Angles {
inner: Box<Expression>,
}
#[derive(Clone, Debug)]
pub struct XGroup {
inner: Box<Expression>,
}
#[derive(Clone, Debug)]
pub struct Abs {
inner: Box<Expression>,
}
#[derive(Clone, Debug)]
pub struct Floor {
inner: Box<Expression>,
}
#[derive(Clone, Debug)]
pub struct Ceil {
inner: Box<Expression>,
}
#[derive(Clone, Debug)]
pub struct Norm {
inner: Box<Expression>,
}

@ -1,4 +1,4 @@
use crate::tokens::{FontCommand, Greek};
use crate::tokens::{Arrow, FontCommand, Function, Greek, Logical, Relation};
#[derive(Clone, Debug)]
pub enum Literal {
@ -53,54 +53,15 @@ pub enum Literal {
Rational,
Real,
Integer,
Eq,
Ne,
Lt,
Gt,
Le,
Ge,
Prec,
PrecEq,
Succ,
SuccEq,
In,
NotIn,
Subset,
SupSet,
SubSetEq,
SupSetEq,
Equiv,
Cong,
Approx,
PropTo,
And,
Or,
Not,
Implies,
If,
ForAll,
Exists,
Bot,
Top,
VDash,
Models,
UpArrow,
DownArrow,
RightArrow,
To,
RightArrowTail,
TwoHeadRightArrrow,
MapsTo,
LeftArrow,
LeftRightArrow,
BigRightArrow,
BigLeftArrow,
BigLeftRightArrow,
Text(TextNode),
Symbol(SymbolNode),
Number(NumberNode),
Greek(Greek),
FontCommand(FontCommand),
Relation(Relation),
Function(Function),
Logical(Logical),
Arrow(Arrow),
}
#[derive(Clone, Debug)]

@ -1,5 +1,14 @@
use crate::elements::group::Group;
use crate::elements::literal::Literal;
use crate::elements::special::Special;
pub mod group;
pub mod literal;
pub mod special;
#[derive(Debug, Clone)]
pub enum Element {}
pub enum Element {
Literal(Literal),
Special(Special),
Group(Group),
}

@ -1,6 +1,65 @@
use crate::elements::Element;
#[derive(Clone, Debug)]
pub struct Root {
pub struct Expression {
children: Vec<Element>,
}
#[derive(Clone, Debug)]
pub enum Special {
Sum(Sum),
Prod(Prod),
Frac(Frac),
Exp(Exp),
Sqrt(Sqrt),
Root(Root),
Integral(Integral),
OIntegral(OIntegral),
}
#[derive(Clone, Debug)]
pub struct Sum {
top: Option<Expression>,
bottom: Option<Expression>,
}
#[derive(Clone, Debug)]
pub struct Prod {
top: Box<Expression>,
bottom: Box<Expression>,
}
#[derive(Clone, Debug)]
pub struct Frac {
top: Box<Expression>,
bottom: Box<Expression>,
}
#[derive(Clone, Debug)]
pub struct Exp {
base: Box<Element>,
exp: Box<Expression>,
}
#[derive(Clone, Debug)]
pub struct Sqrt {
inner: Box<Expression>,
}
#[derive(Clone, Debug)]
pub struct Root {
base: Box<Expression>,
inner: Box<Expression>,
}
#[derive(Clone, Debug)]
pub struct Integral {
top: Box<Expression>,
bottom: Box<Expression>,
}
#[derive(Clone, Debug)]
pub struct OIntegral {
top: Box<Expression>,
bottom: Box<Expression>,
}

Loading…
Cancel
Save