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; }
// --------------------------------------------------------------------- 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); }
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; }
IFFParser::IFFParser(ReadStream *stream, bool disposeStream) : _stream(stream), _disposeStream(disposeStream) { setInputStream(stream); }
Parser::Parser(std::istream* inputStream, const std::string& rootPath) { setInputStream(inputStream, rootPath); }