私はANTLRを初めて使用します。ASTを作成するANTLR文法があります。ComparisonExpr に FuzzyExpr が含まれているかどうかを確認したいのですが、AST から、この ComparisonExpr ノードと、この ComparisonExpr の前にある論理積 (「and」、「or」) を削除したいと考えています。それを行う方法を教えてください。ANTLRの通常の書き換えルールでできるかどうかわかりません。
例えば
Given the input: where $GPA = #high and age = 25
I want the output like this: where age = 25
(delete the conjunction "and" and ComparisonExpr=>"$GPA = #high") because it has the FuzzyExpr=>"#hight")
これは私の文法の一部です。
grammar Test;
options{
output=AST;
ASTLabelType=CommonTree;
}
WhereClause :="where" ExprSingle;
ExprSingle :OrExpr;
OrExpr :AndExpr ("or" AndExpr)*;
AndExpr :ComparisonExpr ("and" ComparisonExpr)*;
ComparisonExpr :ValueExpr((ValueComp)ValueExpr)?;
ValueExpr :ValidateExpr
|PathExpr
|ExtensionExpr
|FuzzyExpr;
FuzzyExpr :"#" Literal;
ありがとうございました。パニーパ