[antlr-interest] Lexing troubles

Johannes Luber jaluber at gmx.de
Sat Aug 4 15:47:51 PDT 2007


Hello!

I've been finally testing my C#-Lexer and after changing some rules I've
got it working. But there are a few details I'm not happy about.

The first is that I have to use the filter option. Otherwise I can't get
the lexer to work. It seems to be the same issue as in the thread
"Understanding priorities in lexing (newbie)". Unfortunately I have to
use a catch-all EVERYTHING_ELSE rule. If no one has an idea how I can do
the lexer without filtering then I'd appreciate suggestions how I should
do error reporting here.

Another issue is that I have to change the constructor as I have to do
some additional initialization. Right now I have an extra function named
Init(), which I call after the object construction but this is clumsy. I
could use a static constructor but I don't really want to hardwire the
grammar name into the file. Should someone rename it the same grammar
will generate a failing file. At least now the dependency is obvious.
I'm missing a general mechanism to adapt constructors to the grammar
authors needs.

For those, who want to test the attached file themselves: The current C#
target doesn't support lexer scopes. I've transposed the Java fix so you
have to use a self-build ANTLR. Unless you manage to convince it
otherwise to use the fixed .stg. It may be possible that the C# target
is still broken in the newest sources (didn't test them) so I'd be
willing to send my local copy of the sources if the need arises.

Best regards,
Johannes Luber

-------------- next part --------------
A non-text attachment was scrubbed...
Name: CSharp3Lexer.zip
Type: application/x-zip
Size: 16926 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20070805/3d1edb73/attachment.bin 


More information about the antlr-interest mailing list