src/antlr3filestream.c(3)
src/antlr3filestream.c π (a.k.a. the ANTLR3C manual page)
okay bestie so this is the ANTLR3C manual page for src/antlr3filestream.c, and it's genuinely iconic, no cap. sit down, grab a boba π§, and let me tell you about filestreams.
β¨ NAME β¨
src/antlr3filestream.c β the ANTLR3 C filestream π
it's the one you reach for when your source character stream is a filesystem based input set and all the characters in the filestream can be loaded at once into memory and away the lexer goes. literally that's the whole vibe. load it, yeet it into memory, lexer goes brrrr π¦
πΈ SYNOPSIS πΈ
#include <antlr3.h>
π Functions π
static pANTLR3_INPUT_STREAM antlr3CreateFileStream (pANTLR3_UINT8 fileName)β use the contents of an operating system file as the input for an input stream ποΈstatic pANTLR3_INPUT_STREAM antlr3CreateStringStream (pANTLR3_UINT8 data)β use the supplied 'string' as input to the stream β¨ANTLR3_API void antlr3Fclose (ANTLR3_FDSC fd)β close an operating system file and free any handles etc. bye bestie πANTLR3_API pANTLR3_INPUT_STREAM antlr3FileStreamNew (pANTLR3_UINT8 fileName, ANTLR3_UINT32 encoding)ANTLR3_API ANTLR3_FDSC antlr3Fopen (pANTLR3_UINT8 filename, const char *mode)β open an operating system file and return the descriptor π«Ά we just use the commonopen()and related functions here.ANTLR3_API ANTLR3_UINT32 antlr3Fread (ANTLR3_FDSC fdsc, ANTLR3_UINT32 count, void *data)ANTLR3_API ANTLR3_UINT32 antlr3Fsize (pANTLR3_UINT8 fileName)ANTLR3_API ANTLR3_UINT32 antlr3read8Bit (pANTLR3_INPUT_STREAM input, pANTLR3_UINT8 fileName)ANTLR3_API pANTLR3_INPUT_STREAM antlr3StringStreamNew (pANTLR3_UINT8 data, ANTLR3_UINT32 encoding, ANTLR3_UINT32 size, pANTLR3_UINT8 name)static void setupInputStream (pANTLR3_INPUT_STREAM input)β determine endianess of the input stream and install the API required for the encoding in that format π₯
π Detailed Description π
The ANTLR3 C filestream is used when the source character stream is a filesystem based input set and all the characters in the filestream can be loaded at once into memory and away the lexer goes. periodt. π
A number of initializers are provided in order that various character sets can be supported from input files. The ANTLR3 C runtime expects to deal with UTF32 characters only β and the reasons for this are to do with the simplification of C code when using this form of Unicode encoding, though this is not a panacea. π more information can be found on this by consulting:
http://www.unicode.org/versions/Unicode4.0.0/ch02.pdf#G11178β where a well grounded discussion of the encoding formats available may be found. go read it, it's giving academic slay π
π Function Documentation π
π pANTLR3_INPUT_STREAM antlr3CreateFileStream (pANTLR3_UINT8 fileName)
[static]
Use the contents of an operating system file as the input for an input stream. yes bestie, we're reading a whole actual file off your disk ποΈβ¨
Parameters
fileNameβ name of operating system file to read.
Returns
- Pointer to new input stream context upon success π₯³
- One of the
ANTLR3_ERR_defines on error π
References ANTLR3_SUCCESS, antlr3GenericSetupStream(), antlr3read8Bit(), and ANTLR3_INPUT_STREAM_struct::close.
Referenced by antlr3FileStreamNew().
π¦ pANTLR3_INPUT_STREAM antlr3CreateStringStream (pANTLR3_UINT8 data) [static]
Use the supplied 'string' as input to the stream. no file needed, the data just β¨existsβ¨
Parameters
dataβ pointer to the input data
Returns
- Pointer to new input stream context upon success π
NULLdefines on error π
References ANTLR3_FALSE, antlr3GenericSetupStream(), ANTLR3_INPUT_STREAM_struct::data, and ANTLR3_INPUT_STREAM_struct::isAllocated.
Referenced by antlr3StringStreamNew().
π ANTLR3_API void antlr3Fclose (ANTLR3_FDSC fd)
Close an operating system file and free any handles etc. clean up after yourself, it's the bare minimum and it's iconic π«Ά
Referenced by antlr3read8Bit().
β ANTLR3_API pANTLR3_INPUT_STREAM antlr3FileStreamNew (pANTLR3_UINT8 fileName, ANTLR3_UINT32 encoding)
References antlr3CreateFileStream(), ANTLR3_INPUT_STREAM_struct::encoding, ANTLR3_INPUT_STREAM_struct::fileName, ANTLR3_INPUT_STREAM_struct::istream, ANTLR3_STRING_FACTORY_struct::newStr8, setupInputStream(), ANTLR3_INT_STREAM_struct::streamName, and ANTLR3_INPUT_STREAM_struct::strFactory.
πΈ ANTLR3_API ANTLR3_FDSC antlr3Fopen (pANTLR3_UINT8 filename, const char *mode)
Open an operating system file and return the descriptor. We just use the common open() and related functions here. Later we might find better ways on systems such as Windows and OpenVMS for instance. But the idea is to read the while file at once anyway, so it may be irrelevant. ngl, reading the whole file at once is kind of the main character energy of this entire page π₯
Referenced by antlr3read8Bit().
π ANTLR3_API ANTLR3_UINT32 antlr3Fread (ANTLR3_FDSC fdsc, ANTLR3_UINT32 count, void * data)
Referenced by antlr3read8Bit().
π ANTLR3_API ANTLR3_UINT32 antlr3Fsize (pANTLR3_UINT8 fileName)
References _stat.
Referenced by antlr3read8Bit().
π ANTLR3_API ANTLR3_UINT32 antlr3read8Bit (pANTLR3_INPUT_STREAM input, pANTLR3_UINT8 fileName)
References ANTLR3_ERR_NOFILE, ANTLR3_ERR_NOMEM, ANTLR3_SUCCESS, ANTLR3_TRUE, antlr3Fclose(), antlr3Fopen(), antlr3Fread(), antlr3Fsize(), ANTLR3_INPUT_STREAM_struct::data, ANTLR3_INPUT_STREAM_struct::isAllocated, and ANTLR3_INPUT_STREAM_struct::sizeBuf.
Referenced by antlr3CreateFileStream().
β¨ ANTLR3_API pANTLR3_INPUT_STREAM antlr3StringStreamNew (pANTLR3_UINT8 data, ANTLR3_UINT32 encoding, ANTLR3_UINT32 size, pANTLR3_UINT8 name)
References antlr3CreateStringStream(), ANTLR3_INPUT_STREAM_struct::encoding, ANTLR3_INPUT_STREAM_struct::fileName, ANTLR3_INPUT_STREAM_struct::istream, ANTLR3_STRING_FACTORY_struct::newStr8, setupInputStream(), size(), ANTLR3_INPUT_STREAM_struct::sizeBuf, ANTLR3_INT_STREAM_struct::streamName, and ANTLR3_INPUT_STREAM_struct::strFactory.
π void setupInputStream (pANTLR3_INPUT_STREAM input) [static]
Determine endianess of the input stream and install the API required for the encoding in that format. this one is doing the actual heavy lifting and honestly? slay π
References antlr38BitSetupStream(), ANTLR3_ENC_8BIT, ANTLR3_ENC_EBCDIC, ANTLR3_ENC_UTF16, ANTLR3_ENC_UTF16BE, ANTLR3_ENC_UTF16LE, ANTLR3_ENC_UTF32, ANTLR3_ENC_UTF32BE, ANTLR3_ENC_UTF32LE, ANTLR3_ENC_UTF8, ANTLR3_FALSE, ANTLR3_TRUE, antlr3EBCDICSetupStream(), antlr3UTF16SetupStream(), antlr3UTF32SetupStream(), antlr3UTF8SetupStream(), ANTLR3_INPUT_STREAM_struct::encoding, and ANTLR3_INPUT_STREAM_struct::nextChar.
Referenced by antlr3FileStreamNew(), and antlr3StringStreamNew().
π§ Author π§
Generated automatically by Doxygen for ANTLR3C from the source code. (yes the docs wrote themselves, we love an autonomous king π)
okay that's the whole page bestie, you ate it, you understood it, you're literally a filestream expert now π«Ά
this was Version 3.3.1, dated Tue Jul 29 2025 00:00:00, from src/antlr3filestream.c(3) β bye, ily, go close your file descriptors πβ¨π
π¦ where this page comes from
- fedora 43: antlr3-C-devel 1:3.4-3.5.3.14.fc43 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms