sevenmark_parser/ast/
expression.rs1use serde::Serialize;
2
3use super::{Element, Span};
4
5#[derive(Debug, Clone, Serialize, PartialEq)]
7pub enum LogicalOperatorKind {
8 Or, And, Not, }
12
13#[derive(Debug, Clone, Serialize)]
15pub struct LogicalOperator {
16 #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
17 pub span: Span,
18 pub kind: LogicalOperatorKind,
19}
20
21#[derive(Debug, Clone, Serialize, PartialEq)]
23pub enum ComparisonOperatorKind {
24 Equal, NotEqual, GreaterThan, LessThan, GreaterEqual, LessEqual, }
31
32#[derive(Debug, Clone, Serialize)]
34pub struct ComparisonOperator {
35 #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
36 pub span: Span,
37 pub kind: ComparisonOperatorKind,
38}
39
40#[derive(Debug, Clone, Serialize)]
42pub enum Expression {
43 Or {
45 #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
46 span: Span,
47 operator: LogicalOperator,
48 left: Box<Expression>,
49 right: Box<Expression>,
50 },
51 And {
53 #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
54 span: Span,
55 operator: LogicalOperator,
56 left: Box<Expression>,
57 right: Box<Expression>,
58 },
59 Not {
61 #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
62 span: Span,
63 operator: LogicalOperator,
64 inner: Box<Expression>,
65 },
66 Comparison {
68 #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
69 span: Span,
70 left: Box<Expression>,
71 operator: ComparisonOperator,
72 right: Box<Expression>,
73 },
74 FunctionCall {
76 #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
77 span: Span,
78 name: String,
79 arguments: Vec<Expression>,
80 },
81 StringLiteral {
83 #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
84 span: Span,
85 value: Vec<Element>,
86 },
87 NumberLiteral {
89 #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
90 span: Span,
91 value: i64,
92 },
93 BoolLiteral {
95 #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
96 span: Span,
97 value: bool,
98 },
99 Null {
101 #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
102 span: Span,
103 },
104 Group {
106 #[cfg_attr(not(feature = "include_locations"), serde(skip_serializing))]
107 span: Span,
108 inner: Box<Expression>,
109 },
110 Element(Box<Element>),
112}