ANTLR 是否可以根据我们在解析过程中的条件来更改 AST?
例如,在解析像 foo().dropLastBar(true).bar() 这样的字符串时,如果我们知道存在 dropLastBar(true),我们希望删除最后一次出现的栏。
现在我已经使用ANTLR中的“成员”来记录是否存在具有真值的dropLastBar。但是我不知道如何修改ANTLR的规则,使生成的AST根据我们拥有的字符串而有所不同。字符串可以是foo().dropLastBar(true).bar().bar().bar(),那么我们有没有可能得到foo().dropLastBar(true).bar()生成的AST。 bar() 没有解析两次?