这个问题会让我发疯。我有一个生成的类,可以解析这样的表达式:
'is_container AND custom_application_name IN ("myasp.com","fraworks")'
,它将被评估为:
'is_container AND ((application_name CONTAINS "fraworks" IGNORECASE) OR (application_name CONTAINS "myasp.com" IGNORECASE))'
但我需要这样做:
'is_container AND ((application_name IS "fraworks" IGNORECASE) OR (application_name IS "myasp.com" IGNORECASE))'
问题是jjTree在处理“IN”文字时如何遍历变量数组(“myasp.com”,“fraworks”),找到它使用“CONTAINS”的位置并将其放在那里“IS”。
我的.jjt文件的一部分描述了这个:
将解析整个表达式的函数
void DiscreteRangeExpression()#DiscreteRangeExpression(true):
{
Token t=null;
}
{
((Variable() TerminalIn() SetLiteral())|(SetLiteral() TerminalIn() Variable()))
//Variable() TerminalIn() SetLiteral()
(
TerminalIgnorecase()
{
jjtThis.setIgnorecase(true);
}
)?
{
jjtThis.setOccurType(OCCURSANY);
}
(
<ALL>
{
jjtThis.setOccurType(OCCURSALL);
}
|
<ANY>
|
(
<OCCURS>
t=<INTEGER_LITERAL>
{
jjtThis.setOccurType(OCCURSEQUAL);
jjtThis.setOccurNum(t.image);
}
(
<PLUS>
{
jjtThis.setOccurType(OCCURSMORE);
}
|
<MINUS>
{
jjtThis.setOccurType(OCCURSLESS);
}
)?
)
)?
}
终端“IN”:
void TerminalIn() :
{}
{
<IN>
}
保留字:
TOKEN :
{
< ALL: ["a","A"]["l","L"]["l","L"] >
| < AND: ["a","A"]["n","N"]["d","D"] >
| < ANY: ["a","A"]["n","N"]["y","Y"] >
| < BETWEEN: ["b","B"]["e","E"]["t","T"]["w","W"]["e","E"]["e","E"]["n","N"] >
| < CONTAINS: ["c","C"]["o","O"]["n","N"]["t","T"]["a","A"]["i","I"]["n","N"]["s","S"]>
| < ENDSWITH: ["e","E"]["n","N"]["d","D"]["s","S"]["w","W"]["i","I"]["t","T"]["h","H"] >
| < HASKEY: ["h","H"]["a","A"]["s","S"]["k","K"]["e","E"]["y","Y"] >
| < IGNORECASE: ["i","I"]["g","G"]["n","N"]["o","O"]["r","R"]["e","E"]["c","C"]["a","A"]["s","S"]["e","E"] >
| < IN: ["i","I"]["n","N"] >
| < IS: ["i","I"]["s","S"] >
| < MATCH: ["m","M"]["a","A"]["t","T"]["c","C"]["h","H"] >
| < MASK: ["m","M"]["a","A"]["s","S"]["k","K"] >
| < NOT: ["n","N"]["o","O"]["t","T"] >
| < NULL: ["n","N"]["u","U"]["l","L"]["l","L"] >
| < OCCURS: ["o","O"]["c","C"]["c","C"]["u","U"]["r","R"]["s","S"] >
| < OR: ["o","O"]["r","R"] >
| < REGEX: ["r","R"]["e","E"]["g","G"]["e","E"]["x","X"]>
| < STARTSWITH: ["s","S"]["t","T"]["a","A"]["r","R"]["t","T"]["s","S"]["w","W"]["i","I"]["t","T"]["h","H"]>
| < LAST: ["l","L"]["a","A"]["s","S"]["t","T"]>
}
请帮我解决这个问题。如果需要更多信息,请询问。谢谢!