-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_check_constraint.cpp
More file actions
46 lines (40 loc) · 2.13 KB
/
debug_check_constraint.cpp
File metadata and controls
46 lines (40 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include "utils/logic/logic_tokenizer.h"
#include "utils/logic/logic_parser.h"
int main() {
QString expr = "ssex IN ('男', '女')";
std::cout << "Testing expression: " << expr.toStdString() << std::endl;
auto tokenResult = logic::tokenizeLogicExpression(expr);
std::cout << "Tokenization success: " << tokenResult.success << std::endl;
if (!tokenResult.success) {
std::cout << "Error: " << tokenResult.error.message.toStdString() << std::endl;
return 1;
}
std::cout << "Number of tokens: " << tokenResult.tokens.size() << std::endl;
for (int i=0; i<tokenResult.tokens.size(); ++i) {
const auto &token = tokenResult.tokens[i];
QString typeStr;
switch (token.type) {
case logic::LogicTokenType::Identifier: typeStr = "Identifier"; break;
case logic::LogicTokenType::StringLiteral: typeStr = "StringLiteral"; break;
case logic::LogicTokenType::NumberLiteral: typeStr = "NumberLiteral"; break;
case logic::LogicTokenType::LeftParen: typeStr = "LeftParen"; break;
case logic::LogicTokenType::RightParen: typeStr = "RightParen"; break;
case logic::LogicTokenType::Comma: typeStr = "Comma"; break;
case logic::LogicTokenType::Keyword: typeStr = "Keyword"; break;
default: typeStr = "Other"; break;
}
std::cout << " Token " << i << ": " << typeStr.toStdString()
<< " = '" << token.rawText.toStdString() << "'"
<< ", pos=" << token.position << std::endl;
}
logic::LogicParserState state;
state.tokens = tokenResult.tokens;
state.index = 0;
auto parseResult = logic::parseLogicTokens(expr, tokenResult.tokens);
std::cout << "Parse success: " << parseResult.success << std::endl;
if (!parseResult.success) {
std::cout << "Error: " << parseResult.error.message.toStdString() << std::endl;
}
return 0;
}