[antlr-interest] calling parser from c++, correct way?

Jim Idle jimi at temporal-wave.com
Tue Jun 15 10:54:50 PDT 2010


Try copying the examples and see where your issue is or use valgrind.  
I am yravellling this week so difficult to spend more time looking.

Jim

On Jun 15, 2010, at 2:00, Anders.Karlsson at sybase.com wrote:

> Hi,
>
> Is this the correct way to call the antlr-runtime from C++? (It  
> seems I
> have some memory overwrite issues so that is why I am asking)
>
> I have a string with the content I want to parse (e.g. string s =  
> "1+1")
>
>
>      pANTLR3_INPUT_STREAM input = antlr3NewAsciiStringInPlaceStream(
> reinterpret_cast<pANTLR3_UINT8>(const_cast<char*>(s.c_str())),
> (ANTLR3_UINT64)s.length(), NULL);
>      pMAExpressionLexer lxr = MAExpressionLexerNew(input);
>      pANTLR3_COMMON_TOKEN_STREAM tstream =
> antlr3CommonTokenStreamSourceNew(ANTLR3_SIZE_HINT, TOKENSOURCE(lxr));
>      pMAExpressionParser psr = MAExpressionParserNew(tstream);
>      MAExpressionParser_ma_expression_return r = psr->ma_expression 
> (psr);
> // calling the start rule for parsing
>
> when I later free psr it crashes
>
>        psr->free(psr); psr = NULL;
> Has anybody an idea what I am doing wrong?
> Thank you and kind regards,
> Anders
>
> 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