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

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



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

>
> > The change in the toString method of class Node was needed because
> > we're using it
> > to determine the name of the token. For this we can't have any
> > whitespaces coming with
> > the return value.
>
> Any reason not to be using "getText()"?

The problem is that we use toString to get other stuff as well, not only tokens.
Example:

   public void outAPackageDeclaration(APackageDeclaration node)
   {
      oPackagePath = new PackagePath();
      oPackagePath.appendDir(node.getName().toString());
   }

This toString() method gets routed through some classes and ends up in the
toString method of class Token. What happens is that we get a package string
with spaces between the dots and the sub-package name like this.

some . package . in_some . project

I'm not quite sure what to do about that. Any ideas?

Thanks, Thomas