antlr3rewritestreams.c File Reference


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.

#include <antlr3rewritestreams.h>

Include dependency graph for antlr3rewritestreams.c:


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 *))
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 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)
 Returns ANTLR3_TRUE if 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 to nextTree, 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.

Function Documentation

static 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().

Here is the caller graph for this function:

static void add ( pANTLR3_REWRITE_RULE_ELEMENT_STREAM  stream,
void *  el,
void(ANTLR3_CDECL *freePtr)(void *)   
) [static]

static 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, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::add, ANTLR3_FALSE, ANTLR3_MALLOC, 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(), getDescription(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::getDescription, hasNext(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::hasNext, next(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::next, nextNode(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::nextNode, nextToken(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::nextToken, nextTree(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::nextTree, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::rec, ANTLR3_VECTOR_struct::remove, reset(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::reset, ANTLR3_RECOGNIZER_SHARED_STATE_struct::rStreams, ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::singleElement, size(), ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::size, ANTLR3_BASE_RECOGNIZER_struct::state, toTree(), and ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct::toTree.

Referenced by antlr3RewriteRuleElementStreamNewAEE(), antlr3RewriteRuleElementStreamNewAEV(), antlr3RewriteRuleNODEStreamNewAE(), antlr3RewriteRuleSubtreeStreamNewAE(), and antlr3RewriteRuleTOKENStreamNewAE().

Here is the call graph for this function:

Here is the caller graph for this function:

static 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().

Here is the call graph for this function:

Here is the caller graph for this function:

static pANTLR3_REWRITE_RULE_ELEMENT_STREAM antlr3RewriteRuleElementStreamNewAEV ( pANTLR3_BASE_TREE_ADAPTOR  adaptor,
pANTLR3_BASE_RECOGNIZER  rec,
pANTLR3_UINT8  description,
pANTLR3_VECTOR  vector 
) [static]

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 
)