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

AW: Token.toString vs. Token.getText() (Was RE: Serialization of parse trees)



Title: AW: Token.toString vs. Token.getText() (Was RE: Serialization of parse trees)

The best (?) solution I've found by now is the following.
I added a static attribute which is use by the toString method
to separate the tokens. The code is below.

I'm not sure if anybody apart from me needs stuff like that. So
I would suggest that you just kick it out of tzhe macro files.

But that brings me back to a question I posted before. Is there
a possibility to tell sablecc which macro files to use? If I want to
create the lexer and parser I might want to be able to decide  if the
serialization stuff should be in it or not.


    private static String zTokenSeparator = " ";

    public static String getTokenSeparator()
    {
        return zTokenSeparator;
    }

    public static void setTokenSeparator(String zTokenSeparator)
    {
        Token.zTokenSeparator = zTokenSeparator;
    }

    public String toString()
    {
      return text + zTokenSeparator;
    }


Thomas