Esempio n. 1
0
pANTLR3_TOKEN_FACTORY
BoundedTokenFactoryNew(pANTLR3_INPUT_STREAM input,ANTLR3_UINT32 size)
{
    pANTLR3_TOKEN_FACTORY   factory;
    pANTLR3_COMMON_TOKEN tok;
    ANTLR3_UINT32 i;

    /* allocate memory
     */
    factory     = (pANTLR3_TOKEN_FACTORY) ANTLR3_MALLOC(sizeof(ANTLR3_TOKEN_FACTORY));

    if  (factory == NULL)
    {
        return  NULL;
    }

    /* Install factory API
     */
    factory->newToken       =  newPoolToken;
    factory->close          =  factoryClose;
    factory->setInputStream = setInputStream;

    /* Allocate the initial pool
     */
    factory->thisPool   = size;
    factory->nextToken  = 0;
    factory->pools      = (pANTLR3_COMMON_TOKEN*) ANTLR3_MALLOC(sizeof(pANTLR3_COMMON_TOKEN));
    factory->pools[0]  =
        (pANTLR3_COMMON_TOKEN)
        ANTLR3_MALLOC((size_t)(sizeof(ANTLR3_COMMON_TOKEN) * size));

    /* Set up the tokens once and for all */
    for( i=0; i < size; i++ ) {
      tok = factory->pools[0] + i;
      antlr3SetTokenAPI(tok);

      /* It is factory made, and we need to copy the string factory pointer
       */
      tok->factoryMade  = ANTLR3_TRUE;
      tok->strFactory   = input == NULL ? NULL : input->strFactory;
      tok->input        = input;
    }

    /* Factory space is good, we now want to initialize our cheating token
     * which one it is initialized is the model for all tokens we manufacture
     */
    antlr3SetTokenAPI(&factory->unTruc);

    /* Set some initial variables for future copying
     */
    factory->unTruc.factoryMade = ANTLR3_TRUE;

    // Input stream
    //
    setInputStream(factory, input);

    return  factory;

}
Esempio n. 2
0
 // ---------------------------------------------------------------------
 FileReader::FileReader(FileInputStream *inputStream, encoding::TextEncoding
 decoder, uint32_t sizeBuffer)
         : m_nInputBufferPos(0), m_nInputBufferLength(0)
 {
     setBufferSize(sizeBuffer);
     setDecoder(encoding::BaseDecoder::getDecoder(decoder));
     setInputStream(inputStream);
 }
Esempio n. 3
0
ANTLR3_API pANTLR3_TOKEN_FACTORY
antlr3TokenFactoryNew(pANTLR3_INPUT_STREAM input)
{
    pANTLR3_TOKEN_FACTORY   factory;

    /* allocate memory
     */
    factory     = (pANTLR3_TOKEN_FACTORY) ANTLR3_MALLOC((size_t)sizeof(ANTLR3_TOKEN_FACTORY));

    if  (factory == NULL)
    {
        return  NULL;
    }

    /* Install factory API
     */
    factory->newToken       = newPoolToken;
    factory->close          = factoryClose;
    factory->setInputStream = setInputStream;
    factory->reset          = factoryReset;

    /* Allocate the initial pool
     */
    factory->thisPool   = -1;
    factory->pools      = NULL;
    factory->maxPool    = -1;
    newPool(factory);

    /* Factory space is good, we now want to initialize our cheating token
     * which one it is initialized is the model for all tokens we manufacture
     */
    antlr3SetTokenAPI(&factory->unTruc);

    /* Set some initial variables for future copying
     */
    factory->unTruc.factoryMade = ANTLR3_TRUE;

    // Input stream
    //
    setInputStream(factory, input);

    return  factory;

}
Esempio n. 4
0
IFFParser::IFFParser(ReadStream *stream, bool disposeStream) : _stream(stream), _disposeStream(disposeStream) {
	setInputStream(stream);
}
Esempio n. 5
0
 Parser::Parser(std::istream* inputStream, const std::string& rootPath)
 {
     setInputStream(inputStream, rootPath);
 }