4

This does not compile in ANTLR 4:

Number options { backtrack=true; }
  : (IntegerLiteral Range)=> IntegerLiteral { $type = IntegerLiteral; }
  | (FloatLiteral)=> FloatLiteral { $type = FloatLiteral; }
  | IntegerLiteral { $type = IntegerLiteral; }
  ;

because of backtrace= true... What happened to it?

WHat should I use in ANTLR 4 instread of it?

Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
Aftershock
  • 5,205
  • 4
  • 51
  • 64

1 Answers1

5

At the moment, there are no rule-level options in ANTLR v4. Note that backtrack=true is no longer needed since the new parsing algorithm has no need for backtracking. Also note that in ANTLR v3, backtrack=true was not valid inside lexer rules, only parser rules.

Sam Harwell
  • 97,721
  • 20
  • 209
  • 280
Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
  • "... the new parsing algorithm has no need for backtracking": Hi, I am reading the book "Language Implementation Patterns". Pattern 5 is about backtracking and Pattern 6 is about memoization. Did you mean that the new parsing algorithm does not use these two patterns anymore? What is the new parsing algorithm? Could you please share with me some references? Thanks. – hengxin Nov 25 '21 at 03:01
  • 1
    @hengxin see: https://groups.google.com/g/antlr-discussion/c/eNlRXD1M1nk?pli=1 – Bart Kiers Nov 25 '21 at 07:17