src/antlr3rewritestreams.c(3)
π NAME π
src/antlr3rewritestreams.c β bestie, this is the implementation of the token/tree streams that the tree re-write rules use to manipulate the tokens and trees produced by rules that are subject to rewrite directives. It's from the ANTLR3C manual, section 3, and we're only doing part 1 rn so stay with me π
β¨ SYNOPSIS β¨
#include <antlr3rewritestreams.h>
π Functions π
static void * _next (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)β Do the work of getting the next element, making sure that it's a tree node or subtree.static void add (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream, void *el, void(ANTLR3_CDECL *freePtr)(void *))β adds an element, obvs π«Άstatic pANTLR3_REWRITE_RULE_ELEMENT_STREAM antlr3RewriteRuleElementStreamNewAE (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description)static pANTLR3_REWRITE_RULE_ELEMENT_STREAM antlr3RewriteRuleElementStreamNewAEE (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, void *oneElement)static pANTLR3_REWRITE_RULE_ELEMENT_STREAM antlr3RewriteRuleElementStreamNewAEV (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, pANTLR3_VECTOR vector)ANTLR3_API pANTLR3_REWRITE_RULE_NODE_STREAM antlr3RewriteRuleNODEStreamNewAE (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description)ANTLR3_API pANTLR3_REWRITE_RULE_NODE_STREAM antlr3RewriteRuleNODEStreamNewAEE (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, void *oneElement)ANTLR3_API pANTLR3_REWRITE_RULE_NODE_STREAM antlr3RewriteRuleNODEStreamNewAEV (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, pANTLR3_VECTOR vector)ANTLR3_API pANTLR3_REWRITE_RULE_SUBTREE_STREAM antlr3RewriteRuleSubtreeStreamNewAE (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description)ANTLR3_API pANTLR3_REWRITE_RULE_SUBTREE_STREAM antlr3RewriteRuleSubtreeStreamNewAEE (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, void *oneElement)ANTLR3_API pANTLR3_REWRITE_RULE_SUBTREE_STREAM antlr3RewriteRuleSubtreeStreamNewAEV (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, pANTLR3_VECTOR vector)ANTLR3_API pANTLR3_REWRITE_RULE_TOKEN_STREAM antlr3RewriteRuleTOKENStreamNewAE (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description)ANTLR3_API pANTLR3_REWRITE_RULE_TOKEN_STREAM antlr3RewriteRuleTOKENStreamNewAEE (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, void *oneElement)ANTLR3_API pANTLR3_REWRITE_RULE_TOKEN_STREAM antlr3RewriteRuleTOKENStreamNewAEV (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, pANTLR3_VECTOR vector)static void * dupTok (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream, void *el)β When constructing trees, sometimes we need to dup a token or AST subtree.static void * dupTree (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream, void *element)β When constructing trees, sometimes we need to dup a token or AST subtree.static void * dupTreeNode (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream, void *element)β When constructing trees, sometimes we need to dup a token or AST subtree.static void expungeRS (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)static void freeNodeRS (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)β Do special nilNode reuse detection for node streams.static void freeRS (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)static void * getDescription (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)β Returns the description string if there is one available (check for NULL).static ANTLR3_BOOLEAN hasNext (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)β ReturnsANTLR3_TRUEif there is a next element available.static void * next (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)β Return the next element in the stream.static pANTLR3_BASE_TREE nextNode (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)β Treat next element as a single node even if it's a subtree.static pANTLR3_BASE_TREE nextNodeNode (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)static pANTLR3_BASE_TREE nextNodeToken (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)β Get the next token from the list and create a node for it. This is the implementation for token streams.static void * nextToken (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)β Return the next element for a caller that wants just the token.static pANTLR3_BASE_TREE nextTree (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)β Return the next element in the stream.static void reset (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)β Reset the condition of this stream so that it appears we have not consumed any of its elements.static ANTLR3_UINT32 size (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)β Number of elements available in the stream.static pANTLR3_BASE_TREE toTree (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream, void *element)β We don;t explicitly convert to a tree unless the call goes tonextTree, which means rewrites are heterogeneous.static pANTLR3_BASE_TREE toTreeNode (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream, void *element)β Ensure stream emits trees; tokens must be converted to AST nodes.
πΈ Detailed Description πΈ
Implementation of token/tree streams that are used by the tree re-write rules to manipulate the tokens and trees produced by rules that are subject to rewrite directives. No cap, that's the whole vibe. β¨
π Function Documentation π
π¦ void * _next (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream) [static]
Do the work of getting the next element, making sure that it's a tree node or subtree. Deal with the optimization of single-element list versus list of size > 1. Throw an exception (or something similar) if the stream is empty or we're out of elements and size>1. You can override in a 'subclass' if necessary. π
References ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::cursor, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::elements, ANTLR3_VECTOR_struct::get, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::singleElement, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::size, and ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::toTree.
Referenced by antlr3RewriteRuleElementStreamNewAE().
π¦ void add (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream, void * el, void(ANTLR3_CDECL *freePtr)(void *) ) [static]
References ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::adaptor, ANTLR3_VECTOR_struct::add, ANTLR3_CDECL, ANTLR3_TRUE, ANTLR3_VECTOR_struct::count, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::elements, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::freeElements, ANTLR3_VECTOR_FACTORY_struct::newVector, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::singleElement, and ANTLR3_BASE_TREE_ADAPTOR_struct::super.
Referenced by antlr3RewriteRuleElementStreamNewAE().
π¦ pANTLR3_REWRITE_RULE_ELEMENT_STREAM antlr3RewriteRuleElementStreamNewAE (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description) [static]
References _next(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::_next, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::adaptor, add(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::add, ANTLR3_FALSE, ANTLR3_VECTOR_struct::count, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::cursor, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::dirty, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::elementDescription, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::elements, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::free, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::freeElements, freeRS(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::getDescription, getDescription(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::hasNext, hasNext(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::next, next(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::nextNode, nextNode(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::nextToken, nextToken(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::nextTree, nextTree(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::rec, ANTLR3_VECTOR_struct::remove, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::reset, reset(), ANTLR3_RECOGNIZER_SHARED_STATE_struct::rStreams, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::singleElement, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::size, size(), ANTLR3_BASE_RECOGNIZER_struct::state, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::toTree, and toTree().
Referenced by antlr3RewriteRuleElementStreamNewAEE(), antlr3RewriteRuleElementStreamNewAEV(), antlr3RewriteRuleNODEStreamNewAE(), antlr3RewriteRuleSubtreeStreamNewAE(), and antlr3RewriteRuleTOKENStreamNewAE().
π¦ pANTLR3_REWRITE_RULE_ELEMENT_STREAM antlr3RewriteRuleElementStreamNewAEE (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, void * oneElement) [static]
References ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::add, and antlr3RewriteRuleElementStreamNewAE().
Referenced by antlr3RewriteRuleNODEStreamNewAEE(), antlr3RewriteRuleSubtreeStreamNewAEE(), and antlr3RewriteRuleTOKENStreamNewAEE().
π¦ pANTLR3_REWRITE_RULE_ELEMENT_STREAM antlr3RewriteRuleElementStreamNewAEV (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, pANTLR3_VECTOR vector) [static]
References ANTLR3_FALSE, ANTLR3_TRUE, antlr3RewriteRuleElementStreamNewAE(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::elements, ANTLR3_VECTOR_struct::factoryMade, and ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::freeElements.
Referenced by antlr3RewriteRuleNODEStreamNewAEV(), antlr3RewriteRuleSubtreeStreamNewAEV(), and antlr3RewriteRuleTOKENStreamNewAEV().
π¦ ANTLR3_API pANTLR3_REWRITE_RULE_NODE_STREAM antlr3RewriteRuleNODEStreamNewAE (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description)
References antlr3RewriteRuleElementStreamNewAE(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::dup, dupTreeNode(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::free, freeNodeRS(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::nextNode, nextNodeNode(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::toTree, and toTreeNode().
okay bestie that's part 1, more coming, don't go anywhere π
πΈ antlr3RewriteRuleNODEStreamNewAEE
ANTLR3_API pANTLR3_REWRITE_RULE_NODE_STREAM
antlr3RewriteRuleNODEStreamNewAEE (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, void *
oneElement)
okay so this one is the node-stream builder that takes a single starting element, bestie. π
References: antlr3RewriteRuleElementStreamNewAEE(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::dup, dupTreeNode(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::free, freeNodeRS(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::nextNode, nextNodeNode(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::toTree, toTreeNode().
π¦ antlr3RewriteRuleNODEStreamNewAEV
ANTLR3_API pANTLR3_REWRITE_RULE_NODE_STREAM
antlr3RewriteRuleNODEStreamNewAEV (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, pANTLR3_VECTOR
vector)
same vibe as above except instead of one lonely element you're handing it a whole pANTLR3_VECTOR to snack on. β¨
References: antlr3RewriteRuleElementStreamNewAEV(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::dup, dupTreeNode(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::free, freeNodeRS(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::nextNode, nextNodeNode(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::toTree, toTreeNode().
π antlr3RewriteRuleSubtreeStreamNewAE
ANTLR3_API pANTLR3_REWRITE_RULE_SUBTREE_STREAM
antlr3RewriteRuleSubtreeStreamNewAE (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description)
the subtree stream constructor, no starting element, just the adaptor, recognizer and description. it's giving minimal-effort-but-make-it-valid. π
References: antlr3RewriteRuleElementStreamNewAE(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::dup, dupTree(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::free, freeNodeRS(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::nextNode, nextNode().
π§ antlr3RewriteRuleSubtreeStreamNewAEE
ANTLR3_API pANTLR3_REWRITE_RULE_SUBTREE_STREAM
antlr3RewriteRuleSubtreeStreamNewAEE (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, void *
oneElement)
subtree stream, but it starts you off with oneElement already in the mix. lowkey the friendliest one. π«Ά
References: antlr3RewriteRuleElementStreamNewAEE(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::dup, dupTree(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::free, freeNodeRS(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::nextNode, nextNode().
π antlr3RewriteRuleSubtreeStreamNewAEV
ANTLR3_API pANTLR3_REWRITE_RULE_SUBTREE_STREAM
antlr3RewriteRuleSubtreeStreamNewAEV (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, pANTLR3_VECTOR
vector)
and the vector-flavoured subtree stream, for when your elements are already chilling in a pANTLR3_VECTOR. β
References: antlr3RewriteRuleElementStreamNewAEV(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::dup, dupTree(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::free, freeNodeRS(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::nextNode, nextNode().
π antlr3RewriteRuleTOKENStreamNewAE
ANTLR3_API pANTLR3_REWRITE_RULE_TOKEN_STREAM
antlr3RewriteRuleTOKENStreamNewAE (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description)
token stream time! π no elements up front, just the basics.
References: antlr3RewriteRuleElementStreamNewAE(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::dup, dupTok(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::nextNode, nextNodeToken().
π antlr3RewriteRuleTOKENStreamNewAEE
ANTLR3_API pANTLR3_REWRITE_RULE_TOKEN_STREAM
antlr3RewriteRuleTOKENStreamNewAEE (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, void *
oneElement)
token stream, one element to start. simple, iconic, no notes. π
References: antlr3RewriteRuleElementStreamNewAEE(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::dup, dupTok(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::nextNode, nextNodeToken().
π antlr3RewriteRuleTOKENStreamNewAEV
ANTLR3_API pANTLR3_REWRITE_RULE_TOKEN_STREAM
antlr3RewriteRuleTOKENStreamNewAEV (pANTLR3_BASE_TREE_ADAPTOR adaptor,
pANTLR3_BASE_RECOGNIZER rec, pANTLR3_UINT8 description, pANTLR3_VECTOR
vector)
token stream but you brought a whole vector of elements. main character energy fr fr. π₯
References: antlr3RewriteRuleElementStreamNewAEV(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::dup, dupTok(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::nextNode, nextNodeToken().
π dupTok [static]
void * dupTok (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream, void * el)
okay bestie listen up, this is important lore: when you're constructing trees, sometimes you gotta dup a token or an AST subtree. dup'ing a token just means creating another AST node around it. for trees you have to call adaptor.dupTree(). that's the rule, no cap. β¨
Referenced by: antlr3RewriteRuleTOKENStreamNewAE(), antlr3RewriteRuleTOKENStreamNewAEE(), antlr3RewriteRuleTOKENStreamNewAEV().
πΈ dupTree [static]
void * dupTree (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream, void * element)
same energy as dupTok but for trees β when constructing trees sometimes you need to dup a token or AST subtree. dup'ing a token means just creating another AST node around it. for trees, you must call the adaptor.dupTree(). π¦
References: ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::adaptor, ANTLR3_BASE_TREE_ADAPTOR_struct::dupNode.
π dupTreeNode [static]
void * dupTreeNode (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream, void *
element)
yep, same deal once more: when constructing trees sometimes we need to dup a token or AST subtree. dup'ing a token means just creating another AST node around it. for trees, you must call the adaptor.dupTree(). π
Referenced by: antlr3RewriteRuleNODEStreamNewAE(), antlr3RewriteRuleNODEStreamNewAEE(), antlr3RewriteRuleNODEStreamNewAEV().
π§ expungeRS [static]
void expungeRS (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)
References: ANTLR3_TRUE, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::elements, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::freeElements.
Referenced by: freeNodeRS(), freeRS().
π freeNodeRS [static]
void freeNodeRS (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)
does special nilNode reuse detection for node streams. π«Ά yes, that's a real job and it's doing it.
References: ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::adaptor, ANTLR3_VECTOR_struct::add, ANTLR3_FALSE, ANTLR3_TRUE, ANTLR3_VECTOR_struct::clear, ANTLR3_VECTOR_struct::count, ANTLR3_VECTOR_ELEMENT_struct::element, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::elements, ANTLR3_VECTOR_struct::elements, expungeRS(), ANTLR3_VECTOR_struct::factoryMade, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::freeElements, ANTLR3_BASE_TREE_struct::isNilNode, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::rec, ANTLR3_VECTOR_FACTORY_struct::returnVector, ANTLR3_RECOGNIZER_SHARED_STATE_struct::rStreams, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::singleElement, ANTLR3_BASE_RECOGNIZER_struct::state, ANTLR3_BASE_TREE_ADAPTOR_struct::super.
Referenced by: antlr3RewriteRuleNODEStreamNewAE(), antlr3RewriteRuleNODEStreamNewAEE(), antlr3RewriteRuleNODEStreamNewAEV(), antlr3RewriteRuleSubtreeStreamNewAE(), antlr3RewriteRuleSubtreeStreamNewAEE(), antlr3RewriteRuleSubtreeStreamNewAEV().
β freeRS [static]
void freeRS (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)
References: ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::adaptor, ANTLR3_VECTOR_struct::add, ANTLR3_FALSE, ANTLR3_TRUE, ANTLR3_VECTOR_struct::clear, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::elements, expungeRS(), ANTLR3_VECTOR_struct::factoryMade, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::freeElements, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::rec, ANTLR3_VECTOR_FACTORY_struct::returnVector, ANTLR3_RECOGNIZER_SHARED_STATE_struct::rStreams, ANTLR3_BASE_RECOGNIZER_struct::state, ANTLR3_BASE_TREE_ADAPTOR_struct::super.
Referenced by: antlr3RewriteRuleElementStreamNewAE().
π getDescription [static]
void * getDescription (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)
hands you the description string if there's one available β and yeah it checks for NULL first, because of course it does. safety first bestie. π
References: ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::elementDescription.
Referenced by: antlr3RewriteRuleElementStreamNewAE().
π hasNext [static]
ANTLR3_BOOLEAN hasNext (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)
gives you back ANTLR3_TRUE if there's a next element waiting for you. vibe check passed = there's more to consume. β¨
References: ANTLR3_FALSE, ANTLR3_TRUE, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::cursor, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::elements, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::singleElement, ANTLR3_VECTOR_struct::size.
Referenced by: antlr3RewriteRuleElementStreamNewAE().
π₯ next [static]
void * next (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)
returns the next element in the stream. if you're out of elements it throws an exception β unless size()==1. and if the size is 1, it just returns elements[0]. that's the whole bit. π
References: ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::_next, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::cursor, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::dup, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::size.
Referenced by: antlr3ExceptionFree(), antlr3RewriteRuleElementStreamNewAE().
π nextNode [static]
pANTLR3_BASE_TREE nextNode (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)
treats the next element as a single node even if it's actually a subtree. you use this instead of next() when the result has to be a tree root node. it also stops us from duplicating recently-added children β for example ^(type ID)+ adds ID to type and then the 2nd iteration has to dup the type node, but ID has already been added. π
referencing a rule result twice is ok; dup the entire tree because we can't be adding trees. e.g. expr expr.
References: ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::_next, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::adaptor, ANTLR3_TRUE, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::cursor, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::dirty, ANTLR3_BASE_TREE_ADAPTOR_struct::dupNode, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::size.
Referenced by: antlr3RewriteRuleElementStreamNewAE(), antlr3RewriteRuleSubtreeStreamNewAE(), antlr3RewriteRuleSubtreeStreamNewAEE(), antlr3RewriteRuleSubtreeStreamNewAEV(), intTrieAdd(), intTrieGet().
π¦ nextNodeNode [static]
pANTLR3_BASE_TREE nextNodeNode (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)
References: ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::_next.
Referenced by: antlr3RewriteRuleNODEStreamNewAE(), antlr3RewriteRuleNODEStreamNewAEE(), antlr3RewriteRuleNODEStreamNewAEV().
π nextNodeToken [static]
pANTLR3_BASE_TREE nextNodeToken (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)
grabs the next token from the list and creates a node for it β this is the implementation for token streams, iykyk. π
References: ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::_next, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::adaptor, ANTLR3_BASE_TREE_ADAPTOR_struct::create.
Referenced by: antlr3RewriteRuleTOKENStreamNewAE(), antlr3RewriteRuleTOKENStreamNewAEE(), antlr3RewriteRuleTOKENStreamNewAEV().
π§ nextToken [static]
void * nextToken (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)
returns the next element for a caller that wants just the token, nothing extra. minimal, clean, iconic. β¨
References: ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::_next.
π nextTree [static]
pANTLR3_BASE_TREE nextTree (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)
returns the next element in the stream. if you're out of elements it throws an exception unless size()==1, and if the size is 1 it returns elements[0]. it also returns a duplicate node/subtree if the stream is out of elements and size==1. and if we've already used that element, it dups it (dirty bit set). π₯ so much happening, all of it necessary.
References: ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::_next, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::cursor, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::dirty, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::dup, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::size.
Referenced by: antlr3RewriteRuleElementStreamNewAE().
π reset [static]
void reset (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)
resets the condition of this stream so it looks like we never consumed any of its elements in the first place. the elements themselves stay completely untouched β we're just gaslighting the cursor. π
...and it's pulling in ANTLR3_TRUE, plus ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::cursor and ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::dirty. bestie said "cite your sources" and this manpage DID. π
ANTRL3_UINT32 size (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream) [static]
okay so this one tells you how many elements are actually available in the stream β a headcount, a lil roll call, if you will. πΈ
and here's the plot twist: if singleElement is set, this should come back as a count of one. that's it. that's the vibe.
ngl the author straight-up admits they copied this logic from the java implementation, and their theory is that java was just out here guarding against someone setting singleElement and then forgetting to NULL it out. π iconic self-aware behavior honestly.
it's referencing ANTLR3_VECTOR_struct::count, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::elements, and ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::singleElement. π¦
pANTLR3_BASE_TREE toTree (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream, void * element) [static]
so like β we do NOT explicitly convert to a tree here unless the call actually goes through to nextTree. which means, and I cannot stress this enough, rewrites are heterogeneous. it's giving "mixed company," it's giving "we contain multitudes." β¨
it's referenced by antlr3RewriteRuleElementStreamNewAE(). π
pANTLR3_BASE_TREE toTreeNode (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream, void * element) [static]
this is the "make sure the stream is actually emitting trees" girlie. π
the deal is: tokens must be converted into AST nodes, but AST nodes can just be passed straight through unmolested. no touching, no transforming, they're already perfect, leave them be. π
it references ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::adaptor and ANTLR3_BASE_TREE_ADAPTOR_struct::dupNode.
and it's referenced by antlr3RewriteRuleNODEStreamNewAE(), antlr3RewriteRuleNODEStreamNewAEE(), and antlr3RewriteRuleNODEStreamNewAEV(). three whole callers, we love a popular function fr fr. π
π Author
Generated automatically by Doxygen for ANTLR3C from the source code. (yes the docs wrote themselves, slay, no notes. π«Ά)
and that's a wrap on src/antlr3rewritestreams.c(3), bestie!! π you just read the whole thing β this page is from ANTLR3C version 3.3.1, dated Tue Jul 29 2025 00:00, and yeah the source/version line at the bottom was giving very much "footer that ate," so we're honoring it here instead. go forth and rewrite those streams, main character. π
β¨πΈ
π¦ 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