Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
I have a situation wherein I have defined lexer tokens as below and respective parser rule calling the same:
 
 TOK: 'IF' (.)* 'END_IF';
 BLOCK: 'FUNCTION_BLOCK';
 START: 'BEGIN';
 END: 'END_BLOCK';
 TRY:  (options {greedy=true;}: .)* ;
 
For Inputs like:
Input 1: IF a>b END_IF    - ANTLR works fine

But for Inputs like
Input 2: FUNCTION_BLOCK BEGIN  END_BLOCK      -  ANTLR lexer goes to the token TRY instead of BLOCK token.
NOTE: I am using ANTLR3.


What I have tried:

I tried creating the TRY: (options{greedy}: .)* token for handling the invalid input but it's breaking the existing flow.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900