更新时间:2023-11-26 20:18:29
从以下内容开始将消耗最少的资源:
The minimal resources would be consumed by starting with the following:
parser.removeErrorListeners();
parser.setErrorStrategy(new BailErrorStrategy());
try {
parser.ruleName();
System.out.println("The sentence was contained in the grammar.");
} catch (ParseCancellationException) {
System.out.println("The sentence was not contained in the grammar.");
}
然后将其更新为也可以使用ANTLR 4本书中介绍的两阶段解析策略.
And then updating this to also use the two-stage parsing strategy descibed in the ANTLR 4 book.