I am new to use the ANTLR. I have the ANTLR grammar which creates an AST. I want to check that if ComparisonExpr contains the FuzzyExpr then I want to delete this ComparisonExpr node and conjunction (“and”, “or”) in front of this ComparisonExpr(if it has) from the AST. Please suggest me how to do it. I don’t know that I can do by normal rewrite rule of ANTLR or not?
For example
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")
This is some part of my grammar.
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;
Thank you. Pannipa
output=ASTin the options suggests the OP is using v3. - Bart Kiers