Hi Jim, It seems I have this issue only when running with VS2010, the main program is in C++ and the generated lexer/parser are kept as C-files (tried also compiling them as C++ files, same result).
The same parser/lexer seems to work under objective-c(and Java of course) however when running it from within VS2010 the function pointers in the CTX seem to either not be set or set to wrong functions during run-time, not sure if the debugger is showing wrong and this is just normal behavior or if what I am seeing is a memory overwrite that occurs inside the generated parser. Are there any particular switches when compiling the library that needs to be set, something specific when using VS2010? I've been fiddling with pragma pack(1) thinking it had something to do with the structures not aligning up on byte boundary but that didn't help as well, I have tried both unicode and multibyte same problem. Since I am running under Windows/VS2010 I don't have Valgrind but I will try and see if I can dig up Boundschecker today Another observation is that the problem seems to depend on the expression, so I was thinking maybe my grammar had broken some unwritten laws for how a grammar should look like :-) Thank you and kind regards, Anders Anders Karlsson | Staff SE II, Architect | Sybase Inc, Singapore, ( +65 6571 3125 | * [email protected] -- It takes a tonne of fact to overcome an ounce of opinion <[email protected]> wrote on 06/16/2010 01:54:50 AM: > Jim Idle <[email protected]> > Sent by: <[email protected]> > > 06/16/2010 01:54 AM > > To > > "[email protected]" <[email protected]> > > cc > > antlr-interest Interest <[email protected]> > > Subject > > Re: [antlr-interest] calling parser from c++, correct way? > > 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, [email protected] 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 > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/ > your-email-address > List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
