[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New Lexer



Etienne Gagnon wrote:

> > So my question, what must I do to write my own lexer?
>
> The easiest way to write your own lexer is to let SableCC write most of
> it for you;-) Let me explain.
>
> You write your grammar as usual, but you leave the right-hand side of
> your token definitions empty.

This is a very good idea !

>
> In reality, I should have made the "getToken" method "protected". This
> is the methods that you really need to override. I will do this today.
> So, you won't need to override next and peek. Only getToken;-)
>
> Does it all make sense to you?
>

Yes it does.

Another question: Why do you use a pushback reader?

This is to say ABC is Token_ABC, ABD is Token_ABD. So when reading a Token
with the Tocken_ABC (for the "ABD" text"), SableCC must bactrak and try the
Tocken_ABD rule?

I want to be sure that I do not need a pushback reader (because this will
be difficult to install on a network link).

Thanks for the new release.

Philippe.