How to use COMMON_TREE_NODE_STREAM

33 Views Asked by At

I'm following http://antlr3.org/api/C/buildrec.html tutorial.

It's my understanding that in order to remove/alter tokens before they are consumed by the parser I have to use none buffered stream COMMON_TREE_NODE_STREAM

In this view, how should i feed the parser ?

currently I use tstream=antlr3CommonTokenStreamSourceNew(ANTLR3_SIZE_HINT,TOKENSOURCE(lxr)); to "feed" the parser.

Appreciate every advice

1

There are 1 best solutions below

1
On

No, the COMMON_TREE_NODE_STREAM is the source for a tree parser, not the normal parser. The ANTLR_TOKEN_STREAM is the input stream for that which has a default implementation in the C runtime known as ANTLR3_COMMON_TOKEN_STREAM_struct. Look up its implementation to learn how to create your own token stream.