[antlr-interest] CommonTreeNodeStream.size() get "streams are ofunknown size" exception

Sam Harwell sharwell at pixelminegames.com
Mon Mar 23 16:06:45 PDT 2009


You need to switch to use the new BufferedTreeNodeStream class instead.
The new CommonTreeNodeStream is unbuffered, so it can't know the size.

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Shaoting Cai
Sent: Monday, March 23, 2009 5:52 PM
To: ANTLR Interest
Subject: [antlr-interest] CommonTreeNodeStream.size() get "streams are
ofunknown size" exception

Hi,

I was using CommonTreeNodeStream.size() and it worked in antlr-3.1.1.
After I switch to 3.1.3, I get "streams are of unknown size" runtime
exception.
Is there any changes in the CommonTreeNodeStream class?

here's how I create the CommonTreeNodeStream:

        ....
        this.ast = (CommonTree) r.getTree();
        System.out.println(ast.toStringTree());  // <-- i can see the
tree string
        CommonTreeNodeStream nodes = new CommonTreeNodeStream(ast);
        System.out.println(nodes.size());  // <-- get exception here
        ....

Thanks in advance for any clue :)

Shaoting

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


More information about the antlr-interest mailing list