[antlr-interest] How to retrieve free-form text between delimiters?

Andrew Lentvorski bsder at allcaps.org
Mon Jul 23 02:21:29 PDT 2007


Thomas Brandon wrote:
> On 7/23/07, Andrew Lentvorski <bsder at allcaps.org> wrote:
>> Any advice for solving this?
> A . does match anything but in a parser this means any token not any
> character, so as the only thing your lexer matches is digits and
> whitespace anything else is an error. You either need to move your
> date and comment rules to the lexer or make the lexer return tokens
> for any input that can occur in dates and comments. If you add a lexer
> rule after other rules like:
> ANY: .;
> Then your example should work. However, depending on how you want to
> process input moving the rules to the lexer may be a better option.

Are there any examples of this I could look at?

What are the up/downsides of using an ANY vs. moving this back further 
into the parser?

If it helps, the format of the file (complete with kinda funky grammar 
description as an image, of all things) is here:
http://www-ee.eng.hawaii.edu/~msmith/ASICs/HTML/Verilog/LRM/HTML/15/ch15.2.htm

It's not that complicated.  I have built hand/regex parsers for it 
before, but I wanted to actually try out ANTLRWorks and ANTLR on a real 
problem rather than just toy stuff.

-a


More information about the antlr-interest mailing list