2

この質問は私を夢中にさせます。そのような式を解析できる生成されたクラスがあります。

「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))'

問題は、「IN」リテラルを処理するときに jjTree がバリアントの配列 (「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"]>
}

これを解決するのを手伝ってください。さらに情報が必要な場合は、お問い合わせください。ありがとう!

4

0 に答える 0