MCPcopy Create free account
hub / github.com/alibaba/zvec / parse_factor

Method parse_factor

src/db/index/segment/sql_expr_parser.cc:95–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93 }
94
95 arrow::Result<Expression> parse_factor() {
96 skip_whitespace();
97
98 if ((size_t)pos_ >= expr_.size()) {
99 return arrow::Status::Invalid("Unexpected end of expression.");
100 }
101
102 char c = expr_[pos_];
103
104 // Parenthetical expression
105 if (c == '(') {
106 ++pos_;
107 skip_whitespace();
108 ARROW_ASSIGN_OR_RAISE(auto inner, parse_expression());
109 skip_whitespace();
110 if ((size_t)pos_ >= expr_.size() || expr_[pos_] != ')') {
111 return arrow::Status::Invalid("Mismatched parentheses.");
112 }
113 ++pos_;
114 skip_whitespace();
115 return inner;
116 }
117
118 // Unary minus operator
119 if (c == '-') {
120 ++pos_; // Skip the minus sign
121 skip_whitespace();
122 ARROW_ASSIGN_OR_RAISE(auto operand, parse_factor());
123 return call("negate", {operand});
124 }
125
126 // Unary plus operator (optional support)
127 if (c == '+') {
128 ++pos_; // Skip the plus sign
129 skip_whitespace();
130 return parse_factor();
131 }
132
133 // Numeric literal (integer or floating point)
134 if (std::isdigit(c)) {
135 return parse_number();
136 }
137
138 // Column name (starts with letter or _)
139 if (std::isalpha(c) || c == '_') {
140 return parse_column_name();
141 }
142
143 return arrow::Status::Invalid("Unexpected character: '", std::string(1, c),
144 "'");
145 }
146
147 arrow::Result<Expression> parse_number() {
148 int start = pos_;

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected