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

Stanley Steel steel at kryas.com
Mon Jan 10 22:29:40 PST 2011


I don't know exactly what you are asking but here is an example on creating
and using a vector with the C API:

// Initialize vector factorypANTLR3_STRING_FACTORY str_factory =
antlr3StringFactoryNew();pANTLR3_VECTOR_FACTORY vec_factory = *
antlr3VectorFactoryNew*(1);
// create source vectorspANTLR3_VECTOR vector = *vec_factory*->*newVector*
(vec_factory);
// we must free this memory at some point
pANTLR3_STRING temp1 = str_factory->newStr8(str_factory, "one ");
pANTLR3_STRING
temp2 = str_factory->newStr8(str_factory, "two ");
vector->*add*(vector, (void *)temp1, NULL);  vector->*add*(vector, (void
*)temp2, NULL);
int i;for(i = 0; i < vector->size(vector); i++){  pANTLR3_STRING temp =
(pANTLR3_STRING) vector->*get*(vector, i);
  ANTLR3_PRINTF(temp->chars);  ANTLR3_PRINTF("\n");}


>
> 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.
>
>


More information about the antlr-interest mailing list