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

Re: ignored tokens

> Thomas Leonhardt wrote:
> the parser uses an object of type AnalysisAdapter to store the
> ignored tokens. Why's that?
> As I understand it the object is never realy used as a visitor, or
> am I wrong??
> If I'm right, I would suggest to use a dedicated class to store
> the ignored tokens. Which has only the two hashtables and
> the methods to set and get the ignored tokens.

You are right.  We should definitely do as you suggest.  I will put that
on my todo list:) [Some people will hate me for it, it'll break their
code, when I do it... Ah! backward compatibility...]

> I had another thought.
> In my project it would be nicve to be able to tell the parser
> which object it should use to store the ignored tokens.
> Something like:
>  Parser oParser = new Parser( oSomeLexer, oIgnoredTokensManager )
> Where the IgnoredTokensManager has the same methods and attributes
> as the AnalysisAdapter except for the visitor methods.

I like this idea of passing the "ignored token" container to the parser
constructor.  I would use an "interface" with just the necessary access
method(s).  This would solve the problem where, currently, ignored
tokens are kept in memory, even if you don't use them.  With the
constructor approach, a "null" parameter would indicate "get rid of
them".  I like it.

Added to the todo-list. :)

Etienne M. Gagnon, M.Sc.                     e-mail: egagnon@j-meg.com
Author of SableCC:                             http://www.sablecc.org/
and SableVM:                                   http://www.sablevm.org/