[antlr-interest] Lexer Rule matching member variable (Java)

Frederic Beister azamir at azamir.de
Sun Aug 15 23:40:07 PDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

I want to write an ANTLR-Lexer and -Parser for a Literate Programming
language. The idea is to embed code fragments in various languages in a
LaTeX document and generate source files on-the-fly.

The languages allows to change the special character used to denote the
beginning of a code snippet and the special character used inside these
snippets to denote inclusion of other snippets. This is needed because
some "guest"-languages might need a pre-defined special character
themselves.

The special character can be changed anywhere in the source text by
using <OLDSPECIAL>=<NEWSPECIAL> where <OLDSPACIAL> is the old special
character and <NEWSPECIAL> is the new special character that should be
active after that instruction.

My idea was to modify the lexer such that it has a member variable "char
cur_special" that is set to the current special character and match
against it in a rule

"fragment SCHAR : cur_special"

such that the token stream abstracts from the different possible special
characters.

At the moment, the only way I see to accomplish this is to manually
modify the generated lexer in many places.

Is there perhaps a built-in functionality in ANTLR 3.2 i could use? I
couldn't find anything in the archives searching for "lexer match
member". I really don't need a full how-to but a gentle nudge in the
correct direction.

Thanks in advance
Frederic

P.S.
Sorry if this is/becomes a repost. My first mail didn't make it through
- - perhaps because it had a PGP signature attachment


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxo3UcACgkQOBEXShUwZO0hagCeNY82qTh5wRk7SmvCAxB9oAfk
1RwAni+IC77x5IBHbw2Tp4SQ4qv1RIS7
=U+NM
-----END PGP SIGNATURE-----


More information about the antlr-interest mailing list