[antlr-interest] Need help vector in C generated code

Jeffrey Newman jeffn at photorepo.com
Mon Jan 10 19:14:06 PST 2011


I'm trying to implement a SQL parser. 
I'm working from the SQLite grammar.

I need to return a column type. (e.g. var char)

The problem is that there is no vectors in the ctx structure.

I have not been able to find and example of using the vectors.

If I use name = ID+
then the name is just stomped with char, the var is gone.

Please help.
Please direct me where I see and example of using the C vectors.
How to include them, how to access them, how to make the generated code complie.

thanks

thanks

Jeffrey
\


type_name returns [ColumnTypeData ctd]
@init {
	int cnt;
	cnt = 0;
	
	ctd.name  = NULL;
	ctd.scale     = 0;
	ctd.precision = 0;
}
    : name+=ID+ (LPAREN size1=signed_number (COMMA size2=signed_number)? RPAREN)?
      {

      }
    ;


Generates (edited)

            	        {
            	            name = (pANTLR3_COMMON_TOKEN) MATCHT(ID, &FOLLOW_ID_in_type_name1283); 
            	            if  (HASEXCEPTION())
            	            {
            	                goto ruletype_nameEx;
            	            }

            	            if (list_name == NULL)
            	            {
            	                list_name=ctx->vectors->newVector(ctx->vectors);
            	            }
            	            list_name->add(list_name, name, NULL);

            	        }
            	        break;


More information about the antlr-interest mailing list