Functions

antlr3inputstream.c File Reference

Base functions to initialize and manipulate any input stream. More...

#include <antlr3input.h>
Include dependency graph for antlr3inputstream.c:

Functions

static void antlr3AsciiConsume (pANTLR3_INT_STREAM is)
 Consume the next character in an 8 bit ASCII input stream.
static ANTLR3_UINT32 antlr3AsciiGetCharPosition (pANTLR3_INPUT_STREAM input)
 Return the current offset in to the current line in the input stream.
static ANTLR3_UINT32 antlr3AsciiGetLine (pANTLR3_INPUT_STREAM input)
 Return the line number as understood by the 8 bit/ASCII input stream.
static void * antlr3AsciiGetLineBuf (pANTLR3_INPUT_STREAM input)
 Return a pointer into the input stream that points at the start of the current input line as triggered by the end of line character installed for the stream ('
' unless told differently).
static pANTLR3_STRING antlr3AsciiGetSourceName (pANTLR3_INT_STREAM is)
static ANTLR3_MARKER antlr3AsciiIndex (pANTLR3_INT_STREAM is)
 Calculate the current index in the output stream.
static ANTLR3_UCHAR antlr3AsciiLA (pANTLR3_INT_STREAM is, ANTLR3_INT32 la)
 Return the input element assuming an 8 bit ascii input.
static ANTLR3_UCHAR antlr3AsciiLA_ucase (pANTLR3_INT_STREAM is, ANTLR3_INT32 la)
 Return the input element assuming an 8 bit ASCII input and always return the UPPER CASE character.
static void * antlr3AsciiLT (pANTLR3_INPUT_STREAM input, ANTLR3_INT32 lt)
 Return the input element assuming an 8 bit ascii input.
static ANTLR3_MARKER antlr3AsciiMark (pANTLR3_INT_STREAM is)
 Mark the current input point in an Ascii 8 bit stream such as a file stream, where all the input is available in the buffer.
static void antlr3AsciiRelease (pANTLR3_INT_STREAM is, ANTLR3_MARKER mark)
 Rewind the lexer input to the state specified by the supplied mark.
static void antlr3AsciiRewind (pANTLR3_INT_STREAM is, ANTLR3_MARKER mark)
 Rewind the lexer input to the state specified by the supplied mark.
static void antlr3AsciiRewindLast (pANTLR3_INT_STREAM is)
 Rewind the lexer input to the state specified by the last produced mark.
static void antlr3AsciiSeek (pANTLR3_INT_STREAM is, ANTLR3_MARKER seekPoint)
 Rewind the lexer input to the state specified by the supplied mark.
static void antlr3AsciiSetCharPosition (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 position)
 Set the current offset in the current line to be a particular setting.
static void antlr3AsciiSetLine (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 line)
 Set the current line number as understood by the input stream.
static void antlr3AsciiSetNewLineChar (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 newlineChar)
 Set the newline trigger character in the input stream to the supplied parameter.
static void antlr3AsciiSetUcaseLA (pANTLR3_INPUT_STREAM input, ANTLR3_BOOLEAN flag)
void antlr3AsciiSetupStream (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 type)
 Common function to setup function interface for an 8 bit ASCII input stream.
static ANTLR3_UINT32 antlr3AsciiSize (pANTLR3_INPUT_STREAM input)
 Return the size of the current input stream, as an Ascii file which in this case is the total input.
static pANTLR3_STRING antlr3AsciiSubstr (pANTLR3_INPUT_STREAM input, ANTLR3_MARKER start, ANTLR3_MARKER stop)
 Return a substring of the ASCII (8 bit) input stream in newly allocated memory.
void antlr3GenericSetupStream (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 type)
static void antlr3InputClose (pANTLR3_INPUT_STREAM input)
 Close down an input stream and free any memory allocated by it.
static void antlr3InputReset (pANTLR3_INPUT_STREAM input)
 Reset a re-startable input stream to the start.

Detailed Description

Base functions to initialize and manipulate any input stream.


Function Documentation

static void antlr3AsciiConsume ( pANTLR3_INT_STREAM  is ) [static]
static ANTLR3_UINT32 antlr3AsciiGetCharPosition ( pANTLR3_INPUT_STREAM  input ) [static]

Return the current offset in to the current line in the input stream.

Parameters:
inputInput stream context pointer
Returns:
Current line offset

References ANTLR3_INPUT_STREAM_struct::charPositionInLine.

Referenced by antlr3GenericSetupStream().

Here is the caller graph for this function:

static ANTLR3_UINT32 antlr3AsciiGetLine ( pANTLR3_INPUT_STREAM  input ) [static]

Return the line number as understood by the 8 bit/ASCII input stream.

Parameters:
inputInput stream context pointer
Returns:
Line number in input stream that we believe we are working on.

References ANTLR3_INPUT_STREAM_struct::line.

Referenced by antlr3GenericSetupStream().

Here is the caller graph for this function:

static void * antlr3AsciiGetLineBuf ( pANTLR3_INPUT_STREAM  input ) [static]

Return a pointer into the input stream that points at the start of the current input line as triggered by the end of line character installed for the stream ('
' unless told differently).

Parameters:
[in]input

References ANTLR3_INPUT_STREAM_struct::currentLine.

Referenced by antlr3GenericSetupStream().

Here is the caller graph for this function:

static pANTLR3_STRING antlr3AsciiGetSourceName ( pANTLR3_INT_STREAM  is ) [static]

References ANTLR3_INT_STREAM_struct::streamName.

Referenced by antlr3GenericSetupStream().

Here is the caller graph for this function:

static ANTLR3_MARKER antlr3AsciiIndex ( pANTLR3_INT_STREAM  is ) [static]

Calculate the current index in the output stream.

Parameters:
[in]inputInput stream context pointer

References ANTLR3_INPUT_STREAM_struct::nextChar, and ANTLR3_INT_STREAM_struct::super.

Referenced by antlr3GenericSetupStream().

Here is the caller graph for this function:

static ANTLR3_UCHAR antlr3AsciiLA ( pANTLR3_INT_STREAM  is,
ANTLR3_INT32  la 
) [static]

Return the input element assuming an 8 bit ascii input.

Parameters:
[in]inputInput stream context pointer
[in]la1 based offset of next input stream element
Returns:
Next input character in internal ANTLR3 encoding (UTF32)

References ANTLR3_CHARSTREAM_EOF, ANTLR3_INPUT_STREAM_struct::data, ANTLR3_INPUT_STREAM_struct::nextChar, ANTLR3_INPUT_STREAM_struct::sizeBuf, and ANTLR3_INT_STREAM_struct::super.

Referenced by antlr3AsciiSetUcaseLA(), and antlr3GenericSetupStream().

Here is the caller graph for this function:

static ANTLR3_UCHAR antlr3AsciiLA_ucase ( pANTLR3_INT_STREAM  is,
ANTLR3_INT32  la 
) [static]

Return the input element assuming an 8 bit ASCII input and always return the UPPER CASE character.

Note that this is 8 bit and so we assume that the toupper function will use the correct locale for 8 bits.

Parameters:
[in]inputInput stream context pointer
[in]la1 based offset of next input stream element
Returns:
Next input character in internal ANTLR3 encoding (UTF32)

References ANTLR3_CHARSTREAM_EOF, ANTLR3_INPUT_STREAM_struct::data, ANTLR3_INPUT_STREAM_struct::nextChar, ANTLR3_INPUT_STREAM_struct::sizeBuf, and ANTLR3_INT_STREAM_struct::super.

Referenced by antlr3AsciiSetUcaseLA().

Here is the caller graph for this function:

static void * antlr3AsciiLT ( pANTLR3_INPUT_STREAM  input,
ANTLR3_INT32  lt 
) [static]

Return the input element assuming an 8 bit ascii input.

Parameters:
[in]inputInput stream context pointer
[in]lt1 based offset of next input stream element
Returns:
Next input character in internal ANTLR3 encoding (UTF32)

References ANTLR3_INT_STREAM_struct::_LA, ANTLR3_FUNC_PTR, and ANTLR3_INPUT_STREAM_struct::istream.

Referenced by antlr3GenericSetupStream().

Here is the caller graph for this function:

static ANTLR3_MARKER antlr3AsciiMark ( pANTLR3_INT_STREAM  is ) [static]
static void antlr3AsciiRelease ( pANTLR3_INT_STREAM  is,
ANTLR3_MARKER  mark 
) [static]

Rewind the lexer input to the state specified by the supplied mark.

Parameters:
[in]inputInput stream context pointer
Remarks:
Assumes ASCII (or at least, 8 Bit) input stream.

References ANTLR3_INPUT_STREAM_struct::markDepth, and ANTLR3_INT_STREAM_struct::super.

Referenced by antlr3GenericSetupStream().

Here is the caller graph for this function:

static void antlr3AsciiRewind ( pANTLR3_INT_STREAM  is,
ANTLR3_MARKER  mark 
) [static]
static void antlr3AsciiRewindLast ( pANTLR3_INT_STREAM  is ) [static]

Rewind the lexer input to the state specified by the last produced mark.

Parameters:
[in]inputInput stream context pointer
Remarks:
Assumes ASCII (or at least, 8 Bit) input stream.

References ANTLR3_INT_STREAM_struct::lastMarker, and ANTLR3_INT_STREAM_struct::rewind.

Referenced by antlr3GenericSetupStream().

Here is the caller graph for this function:

static void antlr3AsciiSeek ( pANTLR3_INT_STREAM  is,
ANTLR3_MARKER  seekPoint 
) [static]

Rewind the lexer input to the state specified by the supplied mark.

Parameters:
[in]inputInput stream context pointer
Remarks:
Assumes ASCII (or at least, 8 Bit) input stream.

References ANTLR3_FUNC_PTR, ANTLR3_INT_STREAM_struct::consume, ANTLR3_INPUT_STREAM_struct::nextChar, and ANTLR3_INT_STREAM_struct::super.

Referenced by antlr3AsciiRewind(), and antlr3GenericSetupStream().

Here is the caller graph for this function:

static void antlr3AsciiSetCharPosition ( pANTLR3_INPUT_STREAM  input,
ANTLR3_UINT32  position 
) [static]

Set the current offset in the current line to be a particular setting.

Parameters:
[in]inputInput stream context pointer
[in]positionNew setting for current offset.
Remarks:
This does not set the actual pointers in the input stream, it is purely for reporting purposes and so on as per antlr3AsciiSetLine();

References ANTLR3_INPUT_STREAM_struct::charPositionInLine.

Referenced by antlr3GenericSetupStream().

Here is the caller graph for this function:

static void antlr3AsciiSetLine ( pANTLR3_INPUT_STREAM  input,
ANTLR3_UINT32  line 
) [static]

Set the current line number as understood by the input stream.

Parameters:
inputInput stream context pointer
lineLine number to tell the input stream we are on
Remarks:
This function does not change any pointers, it just allows the programmer to set the line number according to some external criterion, such as finding a lexed directive like: nnn "file.c" for instance, such that error reporting and so on in is in sync with some original source format.

References ANTLR3_INPUT_STREAM_struct::line.

Referenced by antlr3GenericSetupStream().

Here is the caller graph for this function:

static void antlr3AsciiSetNewLineChar ( pANTLR3_INPUT_STREAM  input,
ANTLR3_UINT32  newlineChar 
) [static]

Set the newline trigger character in the input stream to the supplied parameter.

Parameters:
[in]inputInput stream context pointer
[in]newlineCharCharacter to set to be the newline trigger.
Remarks:
  • The supplied newLineChar is in UTF32 encoding (which means ASCII and latin1 etc are the same encodings), but the input stream catered to by this function is 8 bit only, so it is up to the programmer to ensure that the character supplied is valid.

References ANTLR3_INPUT_STREAM_struct::newlineChar.

Referenced by antlr3GenericSetupStream().

Here is the caller graph for this function:

static void antlr3AsciiSetUcaseLA ( pANTLR3_INPUT_STREAM  input,
ANTLR3_BOOLEAN  flag 
) [static]

References ANTLR3_INT_STREAM_struct::_LA, antlr3AsciiLA(), antlr3AsciiLA_ucase(), and ANTLR3_INPUT_STREAM_struct::istream.

Referenced by antlr3GenericSetupStream().

Here is the call graph for this function:

Here is the caller graph for this function:

void antlr3AsciiSetupStream ( pANTLR3_INPUT_STREAM  input,
ANTLR3_UINT32  type 
)

Common function to setup function interface for an 8 bit ASCII input stream.

Parameters:
inputInput stream context pointer
Remarks:
  • 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.

References antlr3GenericSetupStream(), antlr3StringFactoryNew(), and ANTLR3_INPUT_STREAM_struct::strFactory.

Referenced by antlr3AsciiFileStreamNew(), antlr3NewAsciiStringCopyStream(), and antlr3NewAsciiStringInPlaceStream().

Here is the call graph for this function:

Here is the caller graph for this function:

static ANTLR3_UINT32 antlr3AsciiSize ( pANTLR3_INPUT_STREAM  input ) [static]

Return the size of the current input stream, as an Ascii file which in this case is the total input.

Other implementations may provide more sophisticated implementations to deal with non-recoverable streams and so on.

Parameters:
[in]inputInput stream context pointer

References ANTLR3_INPUT_STREAM_struct::sizeBuf.

Referenced by antlr3GenericSetupStream().

Here is the caller graph for this function:

static pANTLR3_STRING antlr3AsciiSubstr ( pANTLR3_INPUT_STREAM  input,
ANTLR3_MARKER  start,
ANTLR3_MARKER  stop 
) [static]

Return a substring of the ASCII (8 bit) input stream in newly allocated memory.

Parameters:
inputInput stream context pointer
startOffset in input stream where the string starts
stopOffset in the input stream where the string ends.

References ANTLR3_STRING_FACTORY_struct::newPtr, and ANTLR3_INPUT_STREAM_struct::strFactory.

Referenced by antlr3GenericSetupStream().

Here is the caller graph for this function:

void antlr3GenericSetupStream ( pANTLR3_INPUT_STREAM  input,
ANTLR3_UINT32  type 
)

References ANTLR3_INT_STREAM_struct::_LA, ANTLR3_INPUT_STREAM_struct::_LT, ANTLR3_CHARSTREAM, antlr3AsciiConsume(), antlr3AsciiGetCharPosition(), antlr3AsciiGetLine(), antlr3AsciiGetLineBuf(), antlr3AsciiGetSourceName(), antlr3AsciiIndex(), antlr3AsciiLA(), antlr3AsciiLT(), antlr3AsciiMark(), antlr3AsciiRelease(), antlr3AsciiRewind(), antlr3AsciiRewindLast(), antlr3AsciiSeek(), antlr3AsciiSetCharPosition(), antlr3AsciiSetLine(), antlr3AsciiSetNewLineChar(), antlr3AsciiSetUcaseLA(), antlr3AsciiSize(), antlr3AsciiSubstr(), antlr3InputClose(), antlr3InputReset(), antlr3IntStreamNew(), ANTLR3_INPUT_STREAM_struct::charByteSize, ANTLR3_INPUT_STREAM_struct::close, ANTLR3_INT_STREAM_struct::consume, ANTLR3_INPUT_STREAM_struct::free, ANTLR3_INPUT_STREAM_struct::getCharPositionInLine, ANTLR3_INPUT_STREAM_struct::getLine, ANTLR3_INPUT_STREAM_struct::getLineBuf, ANTLR3_INT_STREAM_struct::getSourceName, ANTLR3_INT_STREAM_struct::index, ANTLR3_INPUT_STREAM_struct::istream, ANTLR3_INT_STREAM_struct::mark, ANTLR3_INPUT_STREAM_struct::markers, ANTLR3_INT_STREAM_struct::release, ANTLR3_INPUT_STREAM_struct::reset, ANTLR3_INT_STREAM_struct::rewind, ANTLR3_INT_STREAM_struct::rewindLast, ANTLR3_INT_STREAM_struct::seek, ANTLR3_INPUT_STREAM_struct::setCharPositionInLine, ANTLR3_INPUT_STREAM_struct::setLine, ANTLR3_INPUT_STREAM_struct::SetNewLineChar, ANTLR3_INPUT_STREAM_struct::setUcaseLA, ANTLR3_INPUT_STREAM_struct::size, ANTLR3_INPUT_STREAM_struct::substr, ANTLR3_INT_STREAM_struct::super, and ANTLR3_INT_STREAM_struct::type.

Referenced by antlr3AsciiSetupStream(), and antlr3UCS2SetupStream().

Here is the call graph for this function:

Here is the caller graph for this function:

static void antlr3InputClose ( pANTLR3_INPUT_STREAM  input ) [static]

Close down an input stream and free any memory allocated by it.

Parameters:
inputInput stream context pointer

References ANTLR3_FREE, ANTLR3_STRING_FACTORY_struct::close, ANTLR3_INPUT_STREAM_struct::data, ANTLR3_INT_STREAM_struct::free, ANTLR3_INPUT_STREAM_struct::isAllocated, ANTLR3_INPUT_STREAM_struct::istream, ANTLR3_INPUT_STREAM_struct::markers, and ANTLR3_INPUT_STREAM_struct::strFactory.

Referenced by antlr3GenericSetupStream().

Here is the caller graph for this function:

static void antlr3InputReset ( pANTLR3_INPUT_STREAM  input ) [static]

Reset a re-startable input stream to the start.

Parameters:
inputInput stream context pointer

References antlr3VectorNew(), ANTLR3_INPUT_STREAM_struct::charPositionInLine, ANTLR3_INPUT_STREAM_struct::currentLine, ANTLR3_INPUT_STREAM_struct::data, ANTLR3_INPUT_STREAM_struct::line, ANTLR3_INPUT_STREAM_struct::markDepth, ANTLR3_INPUT_STREAM_struct::markers, and ANTLR3_INPUT_STREAM_struct::nextChar.

Referenced by antlr3GenericSetupStream().

Here is the call graph for this function:

Here is the caller graph for this function: