mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
Move the math expression parser from Pest to Chumsky and add more features (#2685)
Rewrite the math-parser library using a chumsky-based lexer and parser, adding functions, comparisons, logic, and conditionals
This commit is contained in:
@@ -37,7 +37,7 @@ impl Unit {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Literal {
|
||||
Float(f64),
|
||||
Complex(Complex),
|
||||
@@ -54,8 +54,19 @@ pub enum BinaryOp {
|
||||
Add,
|
||||
Sub,
|
||||
Mul,
|
||||
/// Logical AND (nonzero treated as true, returns 1. or 0.)
|
||||
And,
|
||||
Div,
|
||||
/// Logical OR (nonzero treated as true, returns 1. or 0.)
|
||||
Or,
|
||||
Modulo,
|
||||
Pow,
|
||||
Leq,
|
||||
Lt,
|
||||
Geq,
|
||||
Gt,
|
||||
Neq,
|
||||
Eq,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
||||
@@ -63,6 +74,7 @@ pub enum UnaryOp {
|
||||
Neg,
|
||||
Sqrt,
|
||||
Fac,
|
||||
Not,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
@@ -72,4 +84,5 @@ pub enum Node {
|
||||
FnCall { name: String, expr: Vec<Node> },
|
||||
BinOp { lhs: Box<Node>, op: BinaryOp, rhs: Box<Node> },
|
||||
UnaryOp { expr: Box<Node>, op: UnaryOp },
|
||||
Conditional { condition: Box<Node>, if_block: Box<Node>, else_block: Box<Node> },
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user