[antlr-interest] BOF or BOL (Beginning of file/line)

Kevin J. Cummings cummings at kjchome.homeip.net
Sun May 31 18:02:45 PDT 2009


Warren Falk wrote:
> For a grammar I'm working on, I need the lexer to output a token for
> the beginning of (almost) every line.  Adding an emit() to a custom
> NEWLINE rule is simple enough, but what is the correct way to emit the
> token at the beginning of the file?

Make sure that your start rule is only called once, and emit it in an 
action before your first alternative....

> Thanks in advance

-- 
Kevin J. Cummings
kjchome at rcn.com
cummings at kjchome.homeip.net
cummings at kjc386.framingham.ma.us
Registered Linux User #1232 (http://counter.li.org)


More information about the antlr-interest mailing list