Does ANTLR always backtrack if I use a syntactic predicates?

Terence Parr

No. ANTLR only backtracks if it cannot decide between the predicated alternative and the others in that alternative block. So if you have:

```stat : (decl)=>decl
| expr
| ifstat
;
```

then upon input "9", ANTLR will not backtrack as "9" cannot possibly start a decl--parsing will immediately proceed to the "expr" alternative without backtracking.

Comment and Contribute

(Maximum characters: 1200). You have 1200 characters left.