I need to parse SQL Server if statements in ANTLR 3. SQL Server if statements are as:
IF expression BEGIN? statements END?
Since BEGIN and END are optional. I just need to add BEGIN and END tokens in ANTLR token stream at runtime if these are not specified in the token stream.
Solved the issue by adding predicates as:
IF expression {input.LA(1) == BEGIN}? => BEGIN statements_list END | statements_list