Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Expression Tree build() problem  RSS feed

 
Nina Moore
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to build an infix expression tree from a tokenized string: "( ( ( 2 + 6 ) * 3 ) + ( 7 - 3))"

My build method is as follows, so far:

Private TreeNd build()
{
String s = tokenizer.nextToken();
TreeNd r = new TreeNd();
r.setLeft(build());
r.setElement(s);
r.setRight(build());
s = tokenizer.nextToken();

return r;
}

I am wracking my brain trying to figure out why this doesn't work,....any hints please?

Thanks a ton!
 
Nina Moore
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops, should have mentioned that the string my (non-working) build method gets sent doesn't have any )'s or ('s in it.

But it still doesn't work.

thanks again
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!