[antlr-interest] Fixed field

William Clodius wclodius at los-alamos.net
Fri Jul 30 19:39:40 PDT 2010


On Jul 30, 2010, at 11:26 AM, Jim Idle wrote:

> I think that you are barking up the wrong tree here. All your rules are
> completely ambiguous and if any of the fields do not exactly correspond to
> the number of letters, this will all fall over. ANTLR is not really meant
> for parsing fixed width fields where each field is just some arbitrary text.
> You should just use something like awk to do this, or even a very simple
> java class that just reads a buffered input stream line by line and picks
> out the fields.
> 
> Jim
<snip>

Ambiguity is not a problem here, per se. If the grammar were completely ambiguous I would expect ANTLR to report problems before he has a chance to parse a file. I suspect his specific problem can be fixed by requiring that agenda end with an end of file token. However you are correct that automated lexing tools such as ANTLR are not designed for fixed width fields and the convolutions required to handle such fields are as easily handed by handwritten lexers, which in turn are more amenable to error reporting.


More information about the antlr-interest mailing list