[antlr-interest] Matching tokens only at certain places

Emond Papegaaij e.papegaaij at student.utwente.nl
Mon Jun 19 03:23:47 PDT 2006


Hello,

I'm trying to parse partially language independent input. The input is in fact 
similar to that of actions in ANTLR itself. The action tokens in ANTLR all 
have braces around them. My tokens don't. Here is some example input:

iface public String getString() ;
\___/ \_______________________/\_/

As can be seen in this example, the token can only follow a 'iface' token and 
will not contain a ';'. This second condition is straight forward to 
implement. The first however is more difficult. In the parser I know exactly 
when this token should occur, but not in the lexer. Is there any way to force 
the lexer to produce a certain token at that point and nowhere else? BTW, I'm 
using ANTLR v3.

Best regards,
Emond Papegaaij


More information about the antlr-interest mailing list