Example #1
0
/** Create a string factory that is UCS2 (16 bit) encoding based
 */
ANTLR3_API pANTLR3_STRING_FACTORY 
antlr3UCS2StringFactoryNew()
{
     pANTLR3_STRING_FACTORY  factory;

    /* Allocate an 8 bit factory, then override with 16 bit UCS2 functions where we 
     * need to.
     */
    factory	= antlr3StringFactoryNew();

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

    /* Override the 8 bit API with the UCS2 (mostly just 16 bit) API
     */
    factory->newRaw	=  newRaw16;
    factory->newSize	=  newSize16;

    factory->newPtr	=  newPtr16_16;
    factory->newPtr8	=  newPtr16_8;
    factory->newStr	=  newStr16_16;
    factory->newStr8	=  newStr16_8;
    factory->printable	=  printable16;

    factory->destroy	=  destroy;
    factory->destroy	=  destroy;
    factory->close	=  closeFactory;

    return  factory;
}
Example #2
0
/// \brief Common function to setup function interface for an 8 bit ASCII input stream.
///
/// \param input Input stream context pointer
///
/// \remark
///   - Many of the 8 bit ASCII oriented file stream handling functions will be usable
///     by any or at least some other input streams. Therefore it is perfectly acceptable
///     to call this function to install the ASCII handler then override just those functions
///     that would not work for the particular input encoding, such as consume for instance.
/// 
void 
antlr3AsciiSetupStream	(pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 type)
{
    // Build a string factory for this stream
     //
    input->strFactory	= antlr3StringFactoryNew();

    // Default stream set up is for ASCII, therefore there is nothing else
    // to do but set it up as such
    //
    antlr3GenericSetupStream(input, type);
}