[antlr-interest] Token Streams, multiple lexers - how does
lexer access selector?
David Penton
djplists at arrowsash.com
Thu Dec 19 04:49:46 PST 2002
Thanks Ric. That is what I was looking for. Eventually I shall get
familiar with the documentation. I find it a little hard to find things
in it so far, but antlr is so useful that I intend to stick with it.
- Dave -
On Thu, 2002-12-19 at 05:05, Ric Klaren wrote:
> On Wed, Dec 18, 2002 at 11:52:53PM -0500, David Penton wrote:
> > My question is: how does the lexer java class generated by antlr know
> > about selector, which is an antlr.TokenStreamSelector? I mean, other
> > than editing the generated lexer class source files manually. I don't
> > see anything that is intended to do this automatically, nor do I see a
> > way to embed code in the generated parser or lexer files. Thus the
> > reference the method call "selector.push(...)" prevents my lexer class
> > from compiling unless I edit it manually to have a selector instance
> > variable and an accessor method to set it.
>
> See the multiLexer example, that lists one way. If you want to add code to
> the generated classes, make them look like this:
>
> header {
> // into the generated header file..
> }
>
> {
> // for c++ mode this goes into the generated cpp file. For java I don't
> // know of hand.
> }
> class DemoJavaLexer extends Lexer;
> options {
> k=2;
> importVocab = Common;
> exportVocab = Java;
> }
> tokens {
> INT="int";
> }
> {
> // this gets inserted into the class.. so here you can add custom
> // constructors, methods, attributes. etc.
> }
>
> START: .... ;
>
> This is also hidden somewhere in the docs...
>
> HTH,
>
> Ric
> --
> -----+++++*****************************************************+++++++++-------
> ---- Ric Klaren ----- klaren at cs.utwente.nl ----- +31 53 4893722 ----
> -----+++++*****************************************************+++++++++-------
> "You know how to use that thing?" [pointing to the sword]
> "Sure.. The pointy end goes into the other guy."
> --- The Mask of Zorro
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list