Exemplo n.º 1
0
/** \brief Create a new lexer called belle_sdpLexer
 *
 * \param[in]    instream Pointer to an initialized input stream
 * \param[state] state Previously created shared recognizer stat
 * \return 
 *     - Success pbelle_sdpLexer initialized for the lex start
 *     - Fail NULL
 */
ANTLR3_API pbelle_sdpLexer belle_sdpLexerNewSSD         
(pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
{
    pbelle_sdpLexer ctx; // Context structure we will build and return

    ctx = (pbelle_sdpLexer) ANTLR3_CALLOC(1, sizeof(belle_sdpLexer));

    if  (ctx == NULL)
    {
        // Failed to allocate memory for lexer context
        return  NULL;
    }

    /* -------------------------------------------------------------------
     * Memory for basic structure is allocated, now to fill in
     * in base ANTLR3 structures. We initialize the function pointers
     * for the standard ANTLR3 lexer 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 belle_sdpLexer.h here so you can get a sense
     * of what goes where.
     */
    
    /* Create a base lexer, using the supplied input stream
     */
    ctx->pLexer	= antlr3LexerNewStream(ANTLR3_SIZE_HINT, instream, state);
    
    /* Check that we allocated the memory correctly
     */
    if	(ctx->pLexer == NULL)
    {
		ANTLR3_FREE(ctx);
		return  NULL;
    }
    /* Install the implementation of our belle_sdpLexer interface
     */
    ctx->mT__20	= mT__20;
    ctx->mT__21	= mT__21;
    ctx->mT__22	= mT__22;
    ctx->mT__23	= mT__23;
    ctx->mT__24	= mT__24;
    ctx->mT__25	= mT__25;
    ctx->mT__26	= mT__26;
    ctx->mT__27	= mT__27;
    ctx->mDIGIT	= mDIGIT;
    ctx->mZERO	= mZERO;
    ctx->mPOS_DIGIT	= mPOS_DIGIT;
    ctx->mCOMMON_CHAR	= mCOMMON_CHAR;
    ctx->mHEX_CHAR	= mHEX_CHAR;
    ctx->mSPACE	= mSPACE;
    ctx->mLQUOTE	= mLQUOTE;
    ctx->mRQUOTE	= mRQUOTE;
    ctx->mCR	= mCR;
    ctx->mLF	= mLF;
    ctx->mDOT	= mDOT;
    ctx->mEQUAL	= mEQUAL;
    ctx->mCOLON	= mCOLON;
    ctx->mSLASH	= mSLASH;
    ctx->mDASH	= mDASH;
    ctx->mANY_EXCEPT_CR_LF	= mANY_EXCEPT_CR_LF;
    ctx->mTokens	= mTokens;
    
    /** When the nextToken() call is made to this lexer's pANTLR3_TOKEN_SOURCE
     *  it will call mTokens() in this generated code, and will pass it the ctx
     * pointer of this lexer, not the context of the base lexer, so store that now.
     */
    ctx->pLexer->ctx	    = ctx;
    
    /**Install the token matching function
     */
    ctx->pLexer->mTokens = (void (*) (void *))(mTokens);
    
    ctx->getGrammarFileName	= getGrammarFileName;
    ctx->free		= belle_sdpLexerFree;

    
    


    /* Return the newly built lexer to the caller
     */
    return  ctx;
}
Exemplo n.º 2
0
/** \brief Create a new lexer called ExprCppTreeLexer
 *
 * \param[in]    instream Pointer to an initialized input stream
 * \param[state] state Previously created shared recognizer stat
 * \return 
 *     - Success pExprCppTreeLexer initialized for the lex start
 *     - Fail NULL
 */
ANTLR3_API pExprCppTreeLexer ExprCppTreeLexerNewSSD         
(pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
{
    pExprCppTreeLexer ctx; // Context structure we will build and return

    ctx = (pExprCppTreeLexer) ANTLR3_CALLOC(1, sizeof(ExprCppTreeLexer));

    if  (ctx == NULL)
    {
        // Failed to allocate memory for lexer context
        return  NULL;
    }

    /* -------------------------------------------------------------------
     * Memory for basic structure is allocated, now to fill in
     * in base ANTLR3 structures. We initialize the function pointers
     * for the standard ANTLR3 lexer 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 ExprCppTreeLexer.h here so you can get a sense
     * of what goes where.
     */
    
    /* Create a base lexer, using the supplied input stream
     */
    ctx->pLexer	= antlr3LexerNewStream(ANTLR3_SIZE_HINT, instream, state);
    
    /* Check that we allocated the memory correctly
     */
    if	(ctx->pLexer == NULL)
    {
		ANTLR3_FREE(ctx);
		return  NULL;
    }
    /* Install the implementation of our ExprCppTreeLexer interface
     */
    ctx->mT__12	= mT__12;
    ctx->mT__13	= mT__13;
    ctx->mPLUS	= mPLUS;
    ctx->mMINUS	= mMINUS;
    ctx->mTIMES	= mTIMES;
    ctx->mASSIGN	= mASSIGN;
    ctx->mID	= mID;
    ctx->mINT	= mINT;
    ctx->mNEWLINE	= mNEWLINE;
    ctx->mWS	= mWS;
    ctx->mTokens	= mTokens;
    
    /** When the nextToken() call is made to this lexer's pANTLR3_TOKEN_SOURCE
     *  it will call mTokens() in this generated code, and will pass it the ctx
     * pointer of this lexer, not the context of the base lexer, so store that now.
     */
    ctx->pLexer->ctx	    = ctx;
    
    /**Install the token matching function
     */
    ctx->pLexer->mTokens = (void (*) (void *))(mTokens);
    
    ctx->getGrammarFileName	= getGrammarFileName;
    ctx->free		= ExprCppTreeLexerFree;
    ctx->reset          = ExprCppTreeLexerReset;

    
    


    /* Return the newly built lexer to the caller
     */
    return  ctx;
}