[antlr-interest] printing of tokens and output of parser!!

Jim Idle jimi at temporal-wave.com
Thu Aug 7 10:32:14 PDT 2008


On Thu, 2008-08-07 at 12:44 -0400, mark twain wrote:
> Hi, 
>  
> I am new-bie to ANTLR, so just trying to run example: SimpleCalc code.
> I am bit confused as which C runtime library function to use for print
> the token stream
>  
>     tokens = antlr3CommonTokenStreamSourceNew  (ANTLR3_SIZE_HINT, 
> 
> lex->pLexer->tokSource);

Please see the 3.1 examples - this is not the way to access the token
streams any more.
>  
>      /* Here I want to print the stream of token produced by lexer:
> what API Code shoud I use??*/
>  
>      parser = SimpleCalcParserNew               (tokens);
> 
>      parser  ->expr(parser);
>  
>    /* Here I want to print the output of parser, say for addition(3+5)
> I want to see parser ouput:
>     what API should I use?? */
>  
> Similary, if I take any example grammar for generating AST using C
> runtime, please let me know how to display nodes of AST....
> Sorry for such stupid doubts but I would be extremely thankful!


If you use the 3.1 examples, rather than the 3.0 examples you will see
that there are examples of printing the tree and also that the Java
main.c talks about consuming the token stream. I will be adding more
examples in the API docs (please read these) over the next few weeks as
3.1 C runtime is now finished (with some known bugs such as teh debugger
that I might be able to fix before official release).

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080807/069e580b/attachment.html 


More information about the antlr-interest mailing list