quantum_queries/src/vm/parsing/ast.rs

100 lines
1.9 KiB
Rust

use std::fmt::Debug;
#[derive(Debug)]
pub enum UnaryBooleanOperator {
Not,
}
#[derive(Debug)]
pub enum BinaryArithmeticOperator {
Times,
Divide,
Plus,
Minus,
Xor,
}
#[derive(Debug)]
pub enum ComparisonOperator {
GreaterOrEqual,
LessOrEqual,
GreaterThan,
LessThan,
NotEqual,
Equal,
}
#[derive(Debug)]
pub enum UnaryArithmeticOperator {
Negative,
Ham,
}
#[derive(Debug)]
pub enum BinaryBooleanOperator {
And,
Or,
Xor,
}
#[derive(Debug)]
pub enum Variable {
X,
Y,
N,
P,
K,
}
#[derive(Debug)]
pub enum BooleanExpression {
BinaryBooleanConjunction(Box<BinaryBooleanConjunction>),
UnaryBooleanConjunction(Box<UnaryBooleanConjunction>),
ComparisonConjunction(Box<ComparisonConjunction>),
}
#[derive(Debug)]
pub struct BinaryBooleanConjunction {
pub operator: BinaryBooleanOperator,
pub left_operand: BooleanExpression,
pub right_operand: BooleanExpression,
}
#[derive(Debug)]
pub struct UnaryBooleanConjunction {
pub operator: UnaryBooleanOperator,
pub operand: BooleanExpression,
}
#[derive(Debug)]
pub struct ComparisonConjunction {
pub operator: ComparisonOperator,
pub left_operand: ArithmeticOperand,
pub right_operand: ArithmeticOperand,
}
#[derive(Debug)]
pub struct BinaryArithmeticConjunction {
pub operator: BinaryArithmeticOperator,
pub left_operand: ArithmeticOperand,
pub right_operand: ArithmeticOperand,
}
#[derive(Debug)]
pub enum ArithmeticOperand {
Literal(usize),
Expression(Box<ArithmeticExpression>),
}
#[derive(Debug)]
pub enum ArithmeticExpression {
Variable(Variable),
UnaryArithmeticConjunction(Box<UnaryArithmeticConjunction>),
BinaryArithmeticConjunction(Box<BinaryArithmeticConjunction>),
}
#[derive(Debug)]
pub struct UnaryArithmeticConjunction {
pub operator: UnaryArithmeticOperator,
pub operand: ArithmeticOperand,
}