[antlr-interest] Matching fragments

Sam Barnett-Cormack s.barnett-cormack at lancaster.ac.uk
Mon Sep 7 10:31:10 PDT 2009


Hi all,

Now, I know that there's no difference between the rule one wants to be 
start rule and any other - you can call any of them as a function to 
parse a token stream.

However, it's usual to put EOF at the end of the start rule, so it makes 
sure it matches the whole file. However, I'm doing some delayed parsing 
of certain constructs (as detectable context cannot determine manner of 
parsing, but using ANTLR should be easier than hand-coding a parser for 
these token sequences), and I store a list of tokens and have written a 
wrapper to make them a token stream. However, the rules I'll pass them 
to won't match EOF.

It strikes me that all I need to do is make the token stream wrapper 
*not* return an EOF. However, the docs seem to specify that it *should* 
return an EOF. How, practically or ideally, should I resolve this?

-- 
Sam Barnett-Cormack


More information about the antlr-interest mailing list