use super::{AstNodeId, SourceSpan};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct OpFlags {
pub atomize: bool,
pub singleton: bool,
pub ordered: bool,
}
impl OpFlags {
pub fn atomized() -> Self {
Self {
atomize: true,
..Default::default()
}
}
pub fn singleton() -> Self {
Self {
singleton: true,
..Default::default()
}
}
pub fn ordered() -> Self {
Self {
ordered: true,
..Default::default()
}
}
}
#[derive(Debug, Clone)]
pub struct RangeNode {
pub start: AstNodeId,
pub end: AstNodeId,
pub span: SourceSpan,
}
impl RangeNode {
pub fn new(start: AstNodeId, end: AstNodeId, span: SourceSpan) -> Self {
Self { start, end, span }
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum UnaryOpKind {
Negate,
Identity,
}
#[derive(Debug, Clone)]
pub struct UnaryOpNode {
pub kind: UnaryOpKind,
pub operand: AstNodeId,
pub span: SourceSpan,
}
impl UnaryOpNode {
pub fn new(kind: UnaryOpKind, operand: AstNodeId, span: SourceSpan) -> Self {
Self {
kind,
operand,
span,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BinaryOpKind {
Or,
And,
GeneralEq,
GeneralNe,
GeneralLt,
GeneralLe,
GeneralGt,
GeneralGe,
ValueEq,
ValueNe,
ValueLt,
ValueLe,
ValueGt,
ValueGe,
Is,
Before,
After,
Add,
Sub,
Mul,
Div,
IDiv,
Mod,
Union,
Intersect,
Except,
}
#[derive(Debug, Clone)]
pub struct BinaryOpNode {
pub kind: BinaryOpKind,
pub left: AstNodeId,
pub right: AstNodeId,
pub span: SourceSpan,
pub flags: OpFlags,
}
impl BinaryOpNode {
pub fn new(kind: BinaryOpKind, left: AstNodeId, right: AstNodeId, span: SourceSpan) -> Self {
Self {
kind,
left,
right,
span,
flags: OpFlags::default(),
}
}
}