/** \brief Create a new corpconfParser parser and return a context for it. * * \param[in] instream Pointer to an input stream interface. * * \return Pointer to new parser context upon success. */ ANTLR3_API pcorpconfParser corpconfParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) { pcorpconfParser ctx; /* Context structure we will build and return */ ctx = (pcorpconfParser) ANTLR3_CALLOC(1, sizeof(corpconfParser)); if (ctx == NULL) { // Failed to allocate memory for parser context // return NULL; } /* ------------------------------------------------------------------- * Memory for basic structure is allocated, now to fill in * the base ANTLR3 structures. We initialize the function pointers * for the standard ANTLR3 parser function set, but upon return * from here, the programmer may set the pointers to provide custom * implementations of each function. * * We don't use the macros defined in corpconfParser.h here, in order that you can get a sense * of what goes where. */ /* Create a base parser/recognizer, using the supplied token stream */ ctx->pParser = antlr3ParserNewStream(ANTLR3_SIZE_HINT, instream->tstream, state); /* Install the implementation of our corpconfParser interface */ ctx->config = config; ctx->block = block; ctx->line = line; ctx->value = value; ctx->free = corpconfParserFree; ctx->getGrammarFileName = getGrammarFileName; /* Install the scope pushing methods. */ ADAPTOR = ANTLR3_TREE_ADAPTORNew(instream->tstream->tokenSource->strFactory); ctx->vectors = antlr3VectorFactoryNew(0); /* Install the token table */ PSRSTATE->tokenNames = corpconfParserTokenNames; /* Return the newly built parser to the caller */ return ctx; }
/** \brief Create a new filter_expressionParser parser and return a context for it. * * \param[in] instream Pointer to an input stream interface. * * \return Pointer to new parser context upon success. */ ANTLR3_API pfilter_expressionParser filter_expressionParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) { pfilter_expressionParser ctx; /* Context structure we will build and return */ ctx = (pfilter_expressionParser) ANTLR3_CALLOC(1, sizeof(filter_expressionParser)); if (ctx == NULL) { // Failed to allocate memory for parser context // return NULL; } /* ------------------------------------------------------------------- * Memory for basic structure is allocated, now to fill in * the base ANTLR3 structures. We initialize the function pointers * for the standard ANTLR3 parser function set, but upon return * from here, the programmer may set the pointers to provide custom * implementations of each function. * * We don't use the macros defined in filter_expressionParser.h here, in order that you can get a sense * of what goes where. */ /* Create a base parser/recognizer, using the supplied token stream */ ctx->pParser = antlr3ParserNewStream(ANTLR3_SIZE_HINT, instream->tstream, state); /* Install the implementation of our filter_expressionParser interface */ ctx->start_point = start_point; ctx->filter_expr = filter_expr; ctx->boolean_expr = boolean_expr; ctx->boolean_term = boolean_term; ctx->boolean_value = boolean_value; ctx->parenthesized_boolean = parenthesized_boolean; ctx->nonparentherized_boolean = nonparentherized_boolean; ctx->unary_expr = unary_expr; ctx->xpath_expr = xpath_expr; ctx->constant_expr = constant_expr; ctx->operand_expr = operand_expr; ctx->free = filter_expressionParserFree; ctx->reset = filter_expressionParserReset; ctx->getGrammarFileName = getGrammarFileName; /* Install the scope pushing methods. */ RECOGNIZER->displayRecognitionError = displayRecognitionErrorNew; // RECOGNIZER->reportError = reportOverride; // RECOGNIZER->antlr3RecognitionExceptionNew = antlr3RecognitionExceptionNewNew; // RECOGNIZER->mismatch = mismatchNew; /* Install the token table */ PSRSTATE->tokenNames = filter_expressionParserTokenNames; /* Return the newly built parser to the caller */ return ctx; }