[antlr-interest] Re: crash on parsing filter condition

antlrlist antlrlist at yahoo.com
Tue Jun 17 10:08:24 PDT 2003


I only use ANTLR with java, but I did a lot of C++ (no ANTLR-C++) 
some time ago, so I'll try to help. Please forgive if what I say is 
stupid.

It seems to me that the problem is not raised by ANTLR code, but your 
code. If you are parsing something like "column1 = column2sum" then 
you'll likely have a syntax rule like this one:

assignation : IDENT ASSIG IDENT ;

Now both "column1" and "colum2sum" are perfectly valid identifiers in 
most implementations of IDENT, so I don't think the problem is in 
parsing these names, but in what you do with them: typically search 
two "FieldDefinition" instances in your current "TableDefinition" 
using "column1" and "column2sum" as hashcodes. Since there will be no 
FieldDefinitions named "column2sum" no "FieldDefinition" will be 
found. Maybe NULL is being returned, or maybe a not initialized 
pointer is returned, or maybe a very strange exception is raised?

I hope I could help!

Enrique



--- In antlr-interest at yahoogroups.com, "monaabs" <monaabs at y...> wrote:
> Greetings !!!
> 
> I am using 2.7.2 .. on parsing join and filter conditions i get 
> abnormal program termination .
> 
> Its a very strange situation cause this crash occurs only on 
> syntatically wrong conditions 
> 
> for eg if i type column1 = column2 .. no crash
> if i type column1 = column2sum  (junk at end) application crashes.
> 
> The crash call stack is 
> ETL_PARSERS! _CxxThrowException at 8 + 52 bytes
> SQL_Parser::r_BoolPrimary() line 7121
> 
> 
> Similarly i encounter the same crash on parsing transforms .
> 
> The stack in this case is 
> ETL_PARSERS! _CxxThrowException at 8 + 52 bytes
> COMPUTE_Parser::r_RHS() line 260
> 
> Any reason why this should happen . I have intialised the 
ASTFsctory 
> and it works great for parseColumn() but for parseJoinCondition() 
and 
> parseWhereCondition() it fails
> 
> My function looks like this
> 
> long ETL_PARSERS_API ETL_ParseSQL::parseWhereConditions( const char 
> *inBuf, bool bIgnoreSubSelects )
> {
>   ANTLR_USING_NAMESPACE(std)
>   ANTLR_USING_NAMESPACE(antlr)
>    etl_parser_buffer parserBuf;
>    parserBuf.init( inBuf );
>    
>    initGlobalPtr();
>    getMetaInfoPtr()->setIgnoreSubSelects( bIgnoreSubSelects );
>    saveInPtr( parserBuf.get_istream() );
> 
>    ASTFactory my_factory;
>    SQL_Lexer  lexer( *(parserBuf.get_istream()) );
>    SQL_Parser parser(lexer);
>    parser.initializeASTFactory(my_factory);
>    parser.setASTFactory(&my_factory);
> 
>    try
>    {
>      parser.r_ETL_Where();
>    }
>    catch(exception& e)
>    {
>      if ( isBlank( inBuf ) )
>        return( 0 );
>      setErrMsg( e.what() );
>      return( -1 );
>    }
>    return( 0 );
> }
> 
> Any input greatly appreciated .
> 
> Best Regards
> Mona


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list