ANTLR3_COMMON_TOKEN_struct(3)
๐ ANTLR3_COMMON_TOKEN_struct ๐
okay bestie, sit down, hydrate, because this is ANTLR3_COMMON_TOKEN_struct(3) โ straight outta the ANTLR3C manual, section 3, and it is lowkey a whole personality. This is the struct page. The big one. The main character. โจ
๐ NAME ๐
ANTLR3_COMMON_TOKEN_struct โ the definition of an ANTLR3 common token structure, which all implementations of a token stream should provide, installing any further structures in the custom pointer element of this structure. ๐
๐ธ SYNOPSIS ๐ธ
#include <antlr3commontoken.h>
๐ฆ Data Fields ๐ฆ
ANTLR3_UINT32 channelโ the virtual channel that this token exists in. ๐กANTLR3_INT32 charPositionโ the character position in the line that this token was derived from.void * customโ pointer to a custom element that the ANTLR3 programmer may define and install. it's giving "bring your own struct" ๐ซถANTLR3_BOOLEAN factoryMadeโ indicates that a token was produced from the token factory, and therefore thefreeToken()method should not do anything itself, because the token factory is responsible for deleting it. no cap.void(* freeCustom )(void *custom)โ pointer to a function that knows how to free the custom structure when the token is destroyed. ๐งนANTLR3_UINT32(* getChannel )(struct ANTLR3_COMMON_TOKEN_struct *token)โ pointer to a function that gets the channel that this token was placed in (parsers can 'tune' to these channels. โ ๏ธ yes, that parenthesis is the original's, it never closes, we love her anywayANTLR3_INT32(* getCharPositionInLine )(struct ANTLR3_COMMON_TOKEN_struct *token)โ pointer to a function that gets the offset in the line where this token exists.ANTLR3_UINT32(* getLine )(struct ANTLR3_COMMON_TOKEN_struct *token)โ pointer to a function that gets the'line'number where this token resides.ANTLR3_MARKER(* getStartIndex )(struct ANTLR3_COMMON_TOKEN_struct *token)โ pointer to a function that gets the start index in the input stream for this token.ANTLR3_MARKER(* getStopIndex )(struct ANTLR3_COMMON_TOKEN_struct *token)โ pointer to a function that gets the stop index in the input stream for this token.pANTLR3_STRING(* getText )(struct ANTLR3_COMMON_TOKEN_struct *token)โ pointer to function that returns the text pointer of a token, usetoString()if you want apANTLR3_STRINGversion of the token. (note: it's "pointer to function", not "pointer to a function. we respect the typo. ๐)ANTLR3_MARKER(* getTokenIndex )(struct ANTLR3_COMMON_TOKEN_struct *token)โ pointer to a function that returns an index0...n-1of the token in the token input stream.ANTLR3_UINT32(* getType )(struct ANTLR3_COMMON_TOKEN_struct *token)โ pointer to a function that returns the token type of this token.ANTLR3_MARKER indexโ what the index of this token is:0, 1, .., n-2, n-1tokens. ๐ขpANTLR3_INPUT_STREAM inputโ pointer to the input stream that this token originated in.ANTLR3_UINT32 lineโ the line number in the input stream where this token was derived from.void * lineStartโ the offset into the input stream that the line in which this token resides starts.void(* setChannel )(struct ANTLR3_COMMON_TOKEN_struct *token, ANTLR3_UINT32 channel)โ pointer to a function that sets the channel that this token should belong to.void(* setCharPositionInLine )(struct ANTLR3_COMMON_TOKEN_struct *token, ANTLR3_INT32 pos)โ pointer to a function that sets the offset in the line where this token exists.void(* setLine )(struct ANTLR3_COMMON_TOKEN_struct *token, ANTLR3_UINT32 line)โ pointer to a function that sets the'line'number where this token reside. (yes. "reside". iconic. ๐)void(* setStartIndex )(struct ANTLR3_COMMON_TOKEN_struct *token, ANTLR3_MARKER index)โ pointer to a function that sets the start index in the input stream for this token.void(* setStopIndex )(struct ANTLR3_COMMON_TOKEN_struct *token, ANTLR3_MARKER index)โ pointer to a function that sets the stop index in the input stream for this token.void(* setText )(struct ANTLR3_COMMON_TOKEN_struct *token, pANTLR3_STRING text)โ pointer to a function that'might'be able to set the text associated with a token. might!! she's not making promises!!void(* setText8 )(struct ANTLR3_COMMON_TOKEN_struct *token, pANTLR3_UINT8 text)โ pointer to a function that'might'be able to set the text associated with a token.void(* setTokenIndex )(struct ANTLR3_COMMON_TOKEN_struct *token, ANTLR3_MARKER)โ pointer to a function that can set the token index of this token in the token input stream.void(* setType )(struct ANTLR3_COMMON_TOKEN_struct *token, ANTLR3_UINT32 ttype)โ pointer to a function that sets the type of this token.ANTLR3_MARKER startโ the character offset in the input stream where the text for this token starts.ANTLR3_MARKER stopโ the character offset in the input stream where the text for this token stops.pANTLR3_STRING_FACTORY strFactoryโ a string factory that we can use if we ever need the text of a token and need to manufacture apANTLR3_STRING.ANTLR3_UINT32 textStateโ indicates whether this token is carrying:- the union
tokText, and inside her:
union {
pANTLR3_UCHAR chars
pANTLR3_STRING text
} tokText
pANTLR3_UCHAR charsโ pointer that is used when the token just has a pointer to achar *, such as when a rewrite of an imaginary token supplies a string in the grammar.pANTLR3_STRING textโ some token types actually do carry around their associated text, hence(*getText)()will return this pointer if it is notNULL.
pANTLR3_STRING(* toString )(struct ANTLR3_COMMON_TOKEN_struct *token)โ pointer to a function that returns this token as a text representation that can be printed with embedded control codes such as\nreplaced with the printable sequence"\\n". This also yields a string structure that can be used more easily than the pointer to the input stream in certain situations."(the stray quote at the end is literally in the original, I'm just the messenger ๐ซก)ANTLR3_UINT32 typeโ the actual type of this token.ANTLR3_UINT32 user1โ because it is a bit more of a hassle to override anANTLR3_COMMON_TOKENas the standard structure for a token, a number of user programmable elements are allowed in a token. ๐ซถANTLR3_UINT32 user2โ same energy, same reason, different field. because it is a bit more of a hassle to override anANTLR3_COMMON_TOKENas the standard structure for a token, a number of user programmable elements are allowed in a token.ANTLR3_UINT32 user3โ and the third one, for the same reason: because it is a bit more of a hassle to override anANTLR3_COMMON_TOKENas the standard structure for a token, a number of user programmable elements are allowed in a token.
๐ Detailed Description ๐
The definition of an ANTLR3_COMMON_TOKEN structure, which all implementations of a token stream should provide, installing any further structures in the custom pointer element of this structure. periodt.
๐ Remarks ๐
Token streams are in essence provided by lexers or other programs that serve as lexers. โจ
๐ง Field Documentation ๐ง
okay this is the part where every single field gets her own little spotlight. obsessed. ๐
๐ ANTLR3_UINT32 ANTLR3_COMMON_TOKEN_struct::channel
The virtual channel that this token exists in.
Referenced by emit(), getChannel(), setChannel(), skipOffTokenChannels(), and skipOffTokenChannelsReverse().
๐ ANTLR3_INT32 ANTLR3_COMMON_TOKEN_struct::charPosition
The character position in the line that this token was derived from.
Referenced by emit(), getCharPositionInLine(), and setCharPositionInLine().
๐ pANTLR3_UCHAR ANTLR3_COMMON_TOKEN_struct::chars
Pointer that is used when the token just has a pointer to a char *, such as when a rewrite of an imaginary token supplies a string in the grammar. No sense in constructing a pANTLR3_STRING just for that, as mostly the text will not be accessed โ if it is, then we will build a pANTLR3_STRING for it a that point. (fr fr, lazy is efficient ๐
)
Referenced by antlr3CommonTreeNodeStreamNew(), createTokenFromToken(), getText(), newDownNode(), newUpNode(), and setText8().
๐ void* ANTLR3_COMMON_TOKEN_struct::custom
Pointer to a custom element that the ANTLR3 programmer may define and install.
Referenced by antlr3LexerNew(), emit(), factoryClose(), and getMissingSymbol().
๐ ANTLR3_BOOLEAN ANTLR3_COMMON_TOKEN_struct::factoryMade
Indicates that a token was produced from the token factory and therefore the the freeToken() method should not do anything itself because token factory is responsible for deleting it.
Referenced by antlr3LexerNew(), antlr3TokenFactoryNew(), newPoolToken(), newToken(), and nextTokenStr().
๐ void(* ANTLR3_COMMON_TOKEN_struct::freeCustom) (void *custom)
Pointer to a function that knows how to free the custom structure when the token is destroyed.
Referenced by factoryClose().
๐ ANTLR3_UINT32(* ANTLR3_COMMON_TOKEN_struct::getChannel) (struct ANTLR3_COMMON_TOKEN_struct *token)
Pointer to a function that gets the channel that this token was placed in (parsers can 'tune' to these channels.
Referenced by antlr3SetTokenAPI(), createTokenFromToken(), fillBuffer(), serializeToken(), and toString().
๐ ANTLR3_INT32(* ANTLR3_COMMON_TOKEN_struct::getCharPositionInLine) (struct ANTLR3_COMMON_TOKEN_struct *token)
Pointer to a function that gets the offset in the line where this token exists.
Referenced by antlr3SetTokenAPI(), createTokenFromToken(), getCharPositionInLine(), getMissingSymbol(), serializeNode(), serializeToken(), and toString().
๐ ANTLR3_UINT32(* ANTLR3_COMMON_TOKEN_struct::getLine) (struct ANTLR3_COMMON_TOKEN_struct *token)
Pointer to a function that gets the 'line' number where this token resides.
Referenced by antlr3SetTokenAPI(), createTokenFromToken(), getLine(), getMissingSymbol(), serializeNode(), serializeToken(), and toString().
๐ ANTLR3_MARKER(* ANTLR3_COMMON_TOKEN_struct::getStartIndex) (struct ANTLR3_COMMON_TOKEN_struct *token)
Pointer to a function that gets the start index in the input stream for this token.
Referenced by antlr3SetTokenAPI(), getText(), and toString().
๐ ANTLR3_MARKER(* ANTLR3_COMMON_TOKEN_struct::getStopIndex) (struct ANTLR3_COMMON_TOKEN_struct *token)
Pointer to a function that gets the stop index in the input stream for this token.
Referenced by antlr3SetTokenAPI(), getText(), and toString().
๐ pANTLR3_STRING(* ANTLR3_COMMON_TOKEN_struct::getText) (struct ANTLR3_COMMON_TOKEN_struct *token)
Pointer to function that returns the text pointer of a token, use toString() if you want a pANTLR3_STRING version of the token.
Referenced by antlr3SetTokenAPI(), createTokenFromToken(), getMissingSymbol(), getMissingSymbol(), serializeToken(), toString(), and toStringSS(). (yes, getMissingSymbol() is listed twice. the original said it twice, so I say it twice ๐ซก)
๐ ANTLR3_MARKER(* ANTLR3_COMMON_TOKEN_struct::getTokenIndex) (struct ANTLR3_COMMON_TOKEN_struct *token)
Pointer to a function that returns an index 0...n-1 of the token in the token input stream.
Referenced by antlr3SetTokenAPI(), createNodeTok(), createTokenFromToken(), dbgSetTokenBoundaries(), serializeToken(), setTokenBoundaries(), toString(), and toStringTT().
๐ ANTLR3_UINT32(* ANTLR3_COMMON_TOKEN_struct::getType) (struct ANTLR3_COMMON_TOKEN_struct *token)
Pointer to a function that returns the token type of this token.
โญ to be continued, bestie โ part 2 has the rest of the field docs and she's just as loud โญ
๐บ๏ธ ANTLR3_MARKER ANTLR3_COMMON_TOKEN_struct::index
What the index of this token is, fr โ like 0, 1, .., n-2, n-1 tokens. It's giving roll-call energy ๐
Referenced by getTokenIndex(), and setTokenIndex().
๐ pANTLR3_INPUT_STREAM ANTLR3_COMMON_TOKEN_struct::input
Pointer to the input stream that this token originated in. Where it came from, bestie, its whole origin story ๐ฆ
Referenced by antlr3RecognitionExceptionNew(), getMissingSymbol(), getStartIndex(), getText(), newPoolToken(), and setInputStream().
๐ ANTLR3_UINT32 ANTLR3_COMMON_TOKEN_struct::line
The line number in the input stream where this token was derived from. Yes literally the line, like line 47 of ur file ๐
Referenced by emit(), getLine(), and setLine().
โฌ
๏ธ void* ANTLR3_COMMON_TOKEN_struct::lineStart
The offset into the input stream that the line in which this token resides starts. So where the line began, not where the token began, ok subtle but important โจ
Referenced by emit(), and getMissingSymbol().
๐ก void(* ANTLR3_COMMON_TOKEN_struct::setChannel) (struct ANTLR3_COMMON_TOKEN_struct *token, ANTLR3_UINT32 channel)
Pointer to a function that sets the channel that this token should belong to. Pick ur channel bestie, default or hidden ๐บ
Referenced by antlr3SetTokenAPI(), fillBuffer(), and getMissingSymbol().
๐ void(* ANTLR3_COMMON_TOKEN_struct::setCharPositionInLine) (struct ANTLR3_COMMON_TOKEN_struct *token, ANTLR3_INT32 pos)
Pointer to a function that sets the offset in the line where this token exists. Column vibes ๐ฏ
Referenced by antlr3SetTokenAPI(), and getMissingSymbol().
๐งพ void(* ANTLR3_COMMON_TOKEN_struct::setLine) (struct ANTLR3_COMMON_TOKEN_struct *token, ANTLR3_UINT32 line)
Pointer to a function that sets the 'line' number where this token reside. Reside. It said reside. Iconic word choice fr fr ๐
Referenced by antlr3SetTokenAPI(), getMissingSymbol(), and nextTokenStr().
๐ฉ void(* ANTLR3_COMMON_TOKEN_struct::setStartIndex) (struct ANTLR3_COMMON_TOKEN_struct *token, ANTLR3_MARKER index)
Pointer to a function that sets the start index in the input stream for this token.
Referenced by antlr3SetTokenAPI(), newPoolToken(), nextTokenStr(), and tokLT().
๐ void(* ANTLR3_COMMON_TOKEN_struct::setStopIndex) (struct ANTLR3_COMMON_TOKEN_struct *token, ANTLR3_MARKER index)
Pointer to a function that sets the stop index in the input stream for this token.
Referenced by antlr3SetTokenAPI(), nextTokenStr(), and tokLT().
โ๏ธ void(* ANTLR3_COMMON_TOKEN_struct::setText) (struct ANTLR3_COMMON_TOKEN_struct *token, pANTLR3_STRING text)
Pointer to a function that 'might' be able to set the text associated with a token. Read that "might" twice, bestie, it's doing a LOT of heavy lifting ๐ Imaginary tokens such as an ANTLR3_CLASSIC_TOKEN may actually do this, however many tokens such as ANTLR3_COMMON_TOKEN do not actully have strings associated with them but just point into the current input stream. These tokens will implement this function with a function that errors out (probably drastically. Yeah. Drastically. No cap, do not test this ๐
Referenced by antlr3SetTokenAPI().
โ๏ธ void(* ANTLR3_COMMON_TOKEN_struct::setText8) (struct ANTLR3_COMMON_TOKEN_struct *token, pANTLR3_UINT8 text)
Pointer to a function that 'might' be able to set the text associated with a token. Imaginary tokens such as an ANTLR3_CLASSIC_TOKEN may actually do this, however many tokens such as ANTLR3_COMMON_TOKEN do not actully have strings associated with them but just point into the current input stream. These tokens will implement this function with a function that errors out (probably drastically.
Referenced by antlr3SetTokenAPI(), createTypeTokenText(), getMissingSymbol(), and getMissingSymbol().
Not me noticing getMissingSymbol() is listed twice โ that's what the original says, so we keep it, no editing, periodt ๐
๐ข void(* ANTLR3_COMMON_TOKEN_struct::setTokenIndex) (struct ANTLR3_COMMON_TOKEN_struct *token, ANTLR3_MARKER)
Pointer to a function that can set the token index of this token in the token input stream.
Referenced by antlr3SetTokenAPI(), and fillBuffer().
๐ท๏ธ void(* ANTLR3_COMMON_TOKEN_struct::setType) (struct ANTLR3_COMMON_TOKEN_struct *token, ANTLR3_UINT32 ttype)
Pointer to a function that sets the type of this token.
Referenced by antlr3CommonTokenNew(), antlr3LexerNew(), antlr3SetTokenAPI(), createTypeToken(), createTypeTokenText(), and getMissingSymbol().
๐ฌ ANTLR3_MARKER ANTLR3_COMMON_TOKEN_struct::start
The character offset in the input stream where the text for this token starts.
Referenced by emit(), getStartIndex(), and setStartIndex().
๐ ANTLR3_MARKER ANTLR3_COMMON_TOKEN_struct::stop
The character offset in the input stream where the text for this token stops.
Referenced by emit(), getStopIndex(), and setStopIndex().
๐ญ pANTLR3_STRING_FACTORY ANTLR3_COMMON_TOKEN_struct::strFactory
A string factory that we can use if we ever need the text of a token and need to manufacture a pANTLR3_STRING. We're literally building the string on demand, custom order, artisanal โจ
Referenced by ANTLR3_TREE_ADAPTORNew(), antlr3CommonTreeNodeStreamNew(), antlr3CommonTreeNodeStreamNewStream(), antlr3LexerNew(), getText(), newPoolToken(), setCharStream(), and setInputStream().
๐ฌ pANTLR3_STRING ANTLR3_COMMON_TOKEN_struct::text
Some token types actually do carry around their associated text, hence (*getText)() will return this pointer if it is not NULL. Some tokens are self-sufficient like that ๐
Referenced by emit(), getText(), setText(), and setText8().
๐ฎ ANTLR3_UINT32 ANTLR3_COMMON_TOKEN_struct::textState
Indicates whether this token is carrying:
0| Nothing (neither rewrite text, nor setText)1|char *to user supplied rewrite text2|pANTLR3_STRINGbecause of setText or similar action
Affects the union structure tokText below (uses 32 bit so alignment is always good) alignment stays blessed, we love to see it ๐
Referenced by antlr3CommonTreeNodeStreamNew(), antlr3LexerNew(), createTokenFromToken(), emit(), getText(), newDownNode(), newUpNode(), setText(), and setText8().
๐งบ union { ... } ANTLR3_COMMON_TOKEN_struct::tokText
Referenced by antlr3CommonTreeNodeStreamNew(), createTokenFromToken(), emit(), getText(), newDownNode(), newUpNode(), setText(), and setText8().
๐จ๏ธ pANTLR3_STRING(* ANTLR3_COMMON_TOKEN_struct::toString) (struct ANTLR3_COMMON_TOKEN_struct *token)
Pointer to a function that returns this token as a text representation that can be printed with embedded control codes such as replaced with the printable sequence "\\n" This also yields a string structure that can be used more easily than the pointer to the input stream in certain situations. Making ugly control codes printable so ur terminal doesn't have a meltdown ๐ซถ
Referenced by antlr3SetTokenAPI(), createTokenFromToken(), and displayRecognitionError().
๐ญ ANTLR3_UINT32 ANTLR3_COMMON_TOKEN_struct::type
The actual type of this token. The real one. The main character ๐
Referenced by displayRecognitionError(), emit(), fillBuffer(), getText(), getType(), nextToken(), setType(), and toString().
๐งโ๐ป ANTLR3_UINT32 ANTLR3_COMMON_TOKEN_struct::user1
Because it is a bit more of a hassle to override an ANTLR3_COMMON_TOKEN as the standard structure for a token, a number of user programmable elements are allowed in a token. This is one of them. Ur little corner of the struct, do whatever, it's urs ๐
Referenced by antlr3LexerNew(), emit(), and getMissingSymbol().
๐งโ๐ป ANTLR3_UINT32 ANTLR3_COMMON_TOKEN_struct::user2
Because it is a bit more of a hassle to override an ANTLR3_COMMON_TOKEN as the standard structure for a token, a number of user programmable elements are allowed in a token. This is one of them.
Referenced by antlr3LexerNew(), emit(), and getMissingSymbol().
๐งโ๐ป ANTLR3_UINT32 ANTLR3_COMMON_TOKEN_struct::user3
Because it is a bit more of a hassle to override an ANTLR3_COMMON_TOKEN as the standard structure for a token, a number of user programmable elements are allowed in a token. This is one of them.
Referenced by antlr3LexerNew(), emit(), and getMissingSymbol().
๐ AUTHOR
Generated automatically by Doxygen for ANTLR3C from the source code. No human wrote this one, it just appeared, fully formed, like a biblically accurate manpage ๐ง
And that's the whole page, bestie โ you read all of it, which honestly? Iconic behaviour. ๐ธ
This was Version 3.3.1, dated Tue Jul 29 2025 00:00, and it's the ANTLR3_COMMON_TOKEN_struct(3) page ๐ Go forth and tokenize, mwah ๐ซถโจ
๐ฆ 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