src/antlr3collections.c(3)
๐ธ NAME ๐ธ
src/antlr3collections.c โ that's the file, bestie, and it lives in the ANTLR3C manual (section 3).
Okay so what does it do? It hands you a whole lil grab-bag of useful functions that are roughly equivalent to java HashTable and List, for the purposes of the Antlr 3 C runtime. That's the whole vibe. ๐
โจ SYNOPSIS โจ
#include <antlr3.h>
#include 'antlr3collections.h'
๐ฆ Functions ๐ฆ
static void addEdge (pANTLR3_TOPO topo, ANTLR3_UINT32 edge, ANTLR3_UINT32 dependency)static void antlr3EnumFree (pANTLR3_HASH_ENUM en)โ Frees up the memory structures that represent a hash table enumeration.pANTLR3_HASH_ENUM antlr3EnumNew (pANTLR3_HASH_TABLE table)โ Creates an enumeration structure to traverse the hash table.static int antlr3EnumNext (pANTLR3_HASH_ENUM en, pANTLR3_HASH_KEY *key, void **data)โ Return the next entry in the hashtable being traversed by the supplied enumeration.static void antlr3EnumNextEntry (pANTLR3_HASH_ENUM en)โ Local function to advance the entry pointer of an enumeration structure to the next valid entry (if there is one).ANTLR3_API ANTLR3_UINT32 antlr3Hash (void *key, ANTLR3_UINT32 keylen)โ Given an input key of arbitrary length, return a hash value of it.static void antlr3HashDelete (pANTLR3_HASH_TABLE table, void *key)โ Takes the element with the supplied key out of the list, and deletes the data calling the suppliedfree()routine if any.static void antlr3HashDeleteI (pANTLR3_HASH_TABLE table, ANTLR3_INTKEY key)โ Takes the element with the supplied key out of the list, and deletes the data calling the suppliedfree()routine if any.static void antlr3HashFree (pANTLR3_HASH_TABLE table)static void * antlr3HashGet (pANTLR3_HASH_TABLE table, void *key)โ Return the element pointer in the hash table for a particular key value, orNULLif it don't exist (or was itselfNULL).static void * antlr3HashGetI (pANTLR3_HASH_TABLE table, ANTLR3_INTKEY key)โ Return the element pointer in the hash table for a particular key value, orNULLif it don't exist (or was itselfNULL).static ANTLR3_INT32 antlr3HashPut (pANTLR3_HASH_TABLE table, void *key, void *element, void(ANTLR3_CDECL *freeptr)(void *))โ Add the element pointer in to the table, based upon the hash of the provided key.static ANTLR3_INT32 antlr3HashPutI (pANTLR3_HASH_TABLE table, ANTLR3_INTKEY key, void *element, void(ANTLR3_CDECL *freeptr)(void *))โ Add the element pointer in to the table, based upon the hash of the provided key.static pANTLR3_HASH_ENTRY antlr3HashRemove (pANTLR3_HASH_TABLE table, void *key)โ Remove the element in the hash table for a particular key value, if it exists โ no error if it does not.static pANTLR3_HASH_ENTRY antlr3HashRemoveI (pANTLR3_HASH_TABLE table, ANTLR3_INTKEY key)โ Remove a numeric keyed entry from a hash table if it exists, no error if it does not exist.static ANTLR3_UINT32 antlr3HashSize (pANTLR3_HASH_TABLE table)โ return the current size of the hash tablepANTLR3_HASH_TABLE antlr3HashTableNew (ANTLR3_UINT32 sizeHint)pANTLR3_INT_TRIE antlr3IntTrieNew (ANTLR3_UINT32 depth)static ANTLR3_INT32 antlr3ListAdd (pANTLR3_LIST list, void *element, void(ANTLR3_CDECL *freeptr)(void *))โ Add the supplied element to the list, at the next available key.static void antlr3ListDelete (pANTLR3_LIST list, ANTLR3_INTKEY key)static void antlr3ListFree (pANTLR3_LIST list)static void * antlr3ListGet (pANTLR3_LIST list, ANTLR3_INTKEY key)ANTLR3_API pANTLR3_LIST antlr3ListNew (ANTLR3_UINT32 sizeHint)static ANTLR3_INT32 antlr3ListPut (pANTLR3_LIST list, ANTLR3_INTKEY key, void *element, void(ANTLR3_CDECL *freeptr)(void *))static void * antlr3ListRemove (pANTLR3_LIST list, ANTLR3_INTKEY key)โ Remove from the list, but don't free the element, just send it back to the caller.static ANTLR3_UINT32 antlr3ListSize (pANTLR3_LIST list)ANTLR3_API void antlr3SetVectorApi (pANTLR3_VECTOR vector, ANTLR3_UINT32 sizeHint)static void antlr3StackFree (pANTLR3_STACK stack)static void * antlr3StackGet (pANTLR3_STACK stack, ANTLR3_INTKEY key)ANTLR3_API pANTLR3_STACK antlr3StackNew (ANTLR3_UINT32 sizeHint)static void * antlr3StackPeek (pANTLR3_STACK stack)static void * antlr3StackPop (pANTLR3_STACK stack)static ANTLR3_BOOLEAN antlr3StackPush (pANTLR3_STACK stack, void *element, void(ANTLR3_CDECL *freeptr)(void *))static ANTLR3_UINT32 antlr3StackSize (pANTLR3_STACK stack)ANTLR3_API pANTLR3_TOPO antlr3TopoNew ()โ Allocate and initialize a newANTLR3topological sorter, which can be used to define edges that identify numerical node indexes that depend on other numerical node indexes, which can then be sorted topologically such that any node is sorted after all its dependent nodes.static ANTLR3_UINT32 antlr3VectorAdd (pANTLR3_VECTOR vector, void *element, void(ANTLR3_CDECL *freeptr)(void *))โ Add the supplied pointer and freeing function pointer to the list, expanding the vector if needed.static void antlr3VectorClear (pANTLR3_VECTOR vector)static void antlr3VectorDel (pANTLR3_VECTOR vector, ANTLR3_UINT32 entry)ANTLR3_API pANTLR3_VECTOR_FACTORY antlr3VectorFactoryNew (ANTLR3_UINT32 sizeHint)โ Vector factory creation.static void ANTLR3_CDECL antlr3VectorFree (pANTLR3_VECTOR vector)static void * antlr3VectorGet (pANTLR3_VECTOR vector, ANTLR3_UINT32 entry)ANTLR3_API pANTLR3_VECTOR antlr3VectorNew (ANTLR3_UINT32 sizeHint)static ANTLR3_BOOLEAN antlr3VectorResize (pANTLR3_VECTOR vector, ANTLR3_UINT32 hint)static ANTLR3_UINT32 antlr3VectorSet (pANTLR3_VECTOR vector, ANTLR3_UINT32 entry, void *element, void(ANTLR3_CDECL *freeptr)(void *), ANTLR3_BOOLEAN freeExisting)โ Replace the element at the specified entry point with the supplied entry.static ANTLR3_UINT32 antlr3VectorSize (pANTLR3_VECTOR vector)static ANTLR3_BOOLEAN antlr3VectorSwap (pANTLR3_VECTOR vector, ANTLR3_UINT32 entry1, ANTLR3_UINT32 entry2)โ Replace the element at the specified entry point with the supplied entry.static void * antrl3VectorRemove (pANTLR3_VECTOR vector, ANTLR3_UINT32 entry)โ Remove the entry from the vector, but do not free any entry, even if it has a free pointer.static void closeVectorFactory (pANTLR3_VECTOR_FACTORY factory)static void DFS (pANTLR3_TOPO topo, ANTLR3_UINT32 node)โ Given a starting node, descend its dependent nodes (ones that it has edges to) until we find one without edges.static void freeIntNode (pANTLR3_INT_TRIE_NODE node)โ Release memory allocated to this tree.static void freeTopo (pANTLR3_TOPO topo)static ANTLR3_BOOLEAN intTrieAdd (pANTLR3_INT_TRIE trie, ANTLR3_INTKEY key, ANTLR3_UINT32 type, ANTLR3_INTKEY intVal, void *data, void(ANTLR3_CDECL *freeptr)(void *))โ Add an entry into the INT trie.static ANTLR3_BOOLEAN intTrieDel (pANTLR3_INT_TRIE trie, ANTLR3_INTKEY key)static void intTrieFree (pANTLR3_INT_TRIE trie)โ Called to free all nodes and the structure itself.static pANTLR3_TRIE_ENTRY intTrieGet (pANTLR3_INT_TRIE trie, ANTLR3_INTKEY key)โ Search the int Trie and return a pointer to the first bucket indexed by the key if it is contained in the trie, otherwiseNULL.static ANTLR3_BOOLEAN newPool (pANTLR3_VECTOR_FACTORY factory)static pANTLR3_VECTOR newVector (pANTLR3_VECTOR_FACTORY factory)static void returnVector (pANTLR3_VECTOR_FACTORY factory, pANTLR3_VECTOR vector)static pANTLR3_UINT32 sortToArray (pANTLR3_TOPO topo)static void sortVector (pANTLR3_TOPO topo, pANTLR3_VECTOR v)
๐ Variables ๐
static ANTLR3_UINT8 bitIndex [256]โ Array of left most significant bit positions for an 8 bit element provides an efficient way to find the highest bit that is set in an n byte value (n>0).static ANTLR3_UINT64 bitMask [64]โ Rather than use the bit index of a trie node to shift0x01left that many times, then&with the result, it is faster to use the bit index as an index into this table which holds precomputed masks for any of the 64 bits we need to mask off singly.
๐ Detailed Description ๐
Provides a number of useful functions that are roughly equivalent to java HashTable and List for the purposes of Antlr 3 C runtime.
Also useable by the C programmer for things like symbol tables pointers and so on. ๐ซถ
๐ฅ Function Documentation ๐ฅ
โจ void addEdge (pANTLR3_TOPO topo, ANTLR3_UINT32 edge, ANTLR3_UINT32 dependency) [static] โจ
References ANTLR3_BITSET_struct::add, antlr3BitsetNew(), ANTLR3_TOPO_struct::edges, and ANTLR3_TOPO_struct::limit.
Referenced by antlr3TopoNew().
๐ธ void antlr3EnumFree (pANTLR3_HASH_ENUM en) [static] ๐ธ
Frees up the memory structures that represent a hash table enumeration.
๐ Parameters
- enum โ Pointer to
ANTLR3enumeration structure returned byantlr3EnumNew()
Referenced by antlr3EnumNew().
๐ฆ pANTLR3_HASH_ENUM antlr3EnumNew (pANTLR3_HASH_TABLE table) ๐ฆ
Creates an enumeration structure to traverse the hash table.
๐ Parameters
- table โ Table to enumerate
๐ซ Returns
Pointer to enumeration structure.
๐ References
ANTLR3_ERR_NOMEM, ANTLR3_FUNC_PTR, antlr3EnumFree(), antlr3EnumNext(), antlr3EnumNextEntry(), ANTLR3_HASH_ENUM_struct::bucket, ANTLR3_HASH_TABLE_struct::buckets, ANTLR3_HASH_BUCKET_struct::entries, ANTLR3_HASH_ENUM_struct::entry, ANTLR3_HASH_ENUM_struct::free, ANTLR3_HASH_ENUM_struct::next, and ANTLR3_HASH_ENUM_struct::table.
Referenced by antlr3BitsetList().
โญ int antlr3EnumNext (pANTLR3_HASH_ENUM en, pANTLR3_HASH_KEY * key, void ** data) [static] โญ
Return the next entry in the hashtable being traversed by the supplied enumeration.
๐ Parameters
- en โ Pointer to the enumeration tracking structure
- key โ Pointer to void pointer, where the key pointer is returned.
- data โ Pointer to void pointer where the data pointer is returned.
๐ซ Returns
ANTLR3_SUCCESSif there was a next keyANTLR3_FAILif there were no more keys
๐จ Remarks
No checking of input structure is performed!
๐ References
ANTLR3_FAIL, ANTLR3_SUCCESS, antlr3EnumNextEntry(), ANTLR3_HASH_ENUM_struct::bucket, ANTLR3_HASH_ENTRY_struct::data, ANTLR3_HASH_ENUM_struct::entry, ANTLR3_HASH_ENTRY_struct::keybase, ANTLR3_HASH_TABLE_struct::modulo, and ANTLR3_HASH_ENUM_struct::table.
Referenced by antlr3EnumNew().
๐ void antlr3EnumNextEntry (pANTLR3_HASH_ENUM en) [static] ๐
Local function to advance the entry pointer of an enumeration structure to the next valid entry (if there is one).
๐ Parameters
- enum โ Pointer to
ANTLR3enumeration structure returned byantlr3EnumNew()
๐จ Remarks
-a,--allโ wait no bestie that's not it, let me get back in the zone ๐ญ
okay so the function always leaves the pointers pointing at a valid entry if there is one, so if the entry pointer is NULL when this function exits, there were no more entries in the table. periodt. ๐
References ANTLR3_HASH_ENUM_struct::bucket, ANTLR3_HASH_TABLE_struct::buckets, ANTLR3_HASH_BUCKET_struct::entries, ANTLR3_HASH_ENUM_struct::entry, ANTLR3_HASH_TABLE_struct::modulo, ANTLR3_HASH_ENTRY_struct::nextEntry, and ANTLR3_HASH_ENUM_struct::table.
Referenced by antlr3EnumNew(), and antlr3EnumNext().
๐ฆ ANTLR3_API ANTLR3_UINT32 antlr3Hash (void * key, ANTLR3_UINT32 keylen)
okay so you hand it a key of literally any length and it gives you back a hash value of it. then you can use that (with suitable modulo, iykyk) to index other structures. it's giving hashing main character energy fr fr โจ
Referenced by antlr3HashGet(), antlr3HashPut(), and antlr3HashRemove().
๐ void antlr3HashDelete (pANTLR3_HASH_TABLE table, void * key) [static]
takes the element with the supplied key out of the list, and deletes the data โ calling the supplied free() routine if any. no cap, it cleans up after itself ๐งน
References antlr3HashRemove(), and ANTLR3_HASH_ENTRY_struct::data.
Referenced by antlr3HashTableNew().
๐ธ void antlr3HashDeleteI (pANTLR3_HASH_TABLE table, ANTLR3_INTKEY key) [static]
same vibe as the one above bestie โ takes the element with the supplied key out of the list, and deletes the data calling the supplied free() routine if any. just with an ANTLR3_INTKEY this time ๐
References antlr3HashRemoveI(), and ANTLR3_HASH_ENTRY_struct::data.
Referenced by antlr3HashTableNew().
๐ void antlr3HashFree (pANTLR3_HASH_TABLE table) [static]
okay so this one is just the refs, no lil description, but it's still iconic:
References ANTLR3_HASH_TYPE_STR, ANTLR3_HASH_TABLE_struct::buckets, ANTLR3_HASH_ENTRY_struct::data, ANTLR3_HASH_BUCKET_struct::entries, ANTLR3_HASH_KEY_struct::key, ANTLR3_HASH_ENTRY_struct::keybase, ANTLR3_HASH_TABLE_struct::modulo, ANTLR3_HASH_ENTRY_struct::nextEntry, ANTLR3_HASH_KEY_struct::sKey, and ANTLR3_HASH_KEY_struct::type.
Referenced by antlr3HashTableNew().
๐ฅ void * antlr3HashGet (pANTLR3_HASH_TABLE table, void * key) [static]
returns the element pointer in the hash table for a particular key value, or NULL if it don't exist (or was itself NULL). so like, if you get nothing back, it's not ghosting you, it's just literally not there ๐
References antlr3Hash(), ANTLR3_HASH_TABLE_struct::buckets, ANTLR3_HASH_ENTRY_struct::data, ANTLR3_HASH_BUCKET_struct::entries, ANTLR3_HASH_KEY_struct::key, ANTLR3_HASH_ENTRY_struct::keybase, ANTLR3_HASH_TABLE_struct::modulo, ANTLR3_HASH_ENTRY_struct::nextEntry, and ANTLR3_HASH_KEY_struct::sKey.
Referenced by antlr3HashTableNew().
โจ void * antlr3HashGetI (pANTLR3_HASH_TABLE table, ANTLR3_INTKEY key) [static]
return the element pointer in the hash table for a particular key value, or NULL if it don't exist (or was itself NULL). same energy, int key edition ๐ซถ
References ANTLR3_HASH_TABLE_struct::buckets, ANTLR3_HASH_ENTRY_struct::data, ANTLR3_HASH_BUCKET_struct::entries, ANTLR3_HASH_KEY_struct::iKey, ANTLR3_HASH_KEY_struct::key, ANTLR3_HASH_ENTRY_struct::keybase, ANTLR3_HASH_TABLE_struct::modulo, and ANTLR3_HASH_ENTRY_struct::nextEntry.
Referenced by antlr3HashTableNew().
๐ ANTLR3_INT32 antlr3HashPut (pANTLR3_HASH_TABLE table, void * key, void * element, void(ANTLR3_CDECL *freeptr)(void *) ) [static]
add the element pointer in to the table, based upon the hash of the provided key. simple as that bestie, slay ๐
References ANTLR3_HASH_TABLE_struct::allowDups, ANTLR3_CDECL, ANTLR3_ERR_HASHDUP, ANTLR3_ERR_NOMEM, ANTLR3_FALSE, ANTLR3_HASH_TYPE_STR, ANTLR3_SUCCESS, ANTLR3_TRUE, antlr3Hash(), ANTLR3_HASH_TABLE_struct::buckets, ANTLR3_HASH_TABLE_struct::count, ANTLR3_HASH_ENTRY_struct::data, ANTLR3_HASH_TABLE_struct::doStrdup, ANTLR3_HASH_BUCKET_struct::entries, ANTLR3_HASH_KEY_struct::key, ANTLR3_HASH_ENTRY_struct::keybase, ANTLR3_HASH_TABLE_struct::modulo, ANTLR3_HASH_ENTRY_struct::nextEntry, ANTLR3_HASH_KEY_struct::sKey, and ANTLR3_HASH_KEY_struct::type.
Referenced by antlr3HashTableNew().
๐ ANTLR3_INT32 antlr3HashPutI (pANTLR3_HASH_TABLE table, ANTLR3_INTKEY key, void * element, void(ANTLR3_CDECL *freeptr)(void *) ) [static]
add the element pointer in to the table, based upon the hash of the provided key. literally the same thing but int key, we love consistency โจ
References ANTLR3_HASH_TABLE_struct::allowDups, ANTLR3_CDECL, ANTLR3_ERR_HASHDUP, ANTLR3_ERR_NOMEM, ANTLR3_FALSE, ANTLR3_HASH_TYPE_INT, ANTLR3_SUCCESS, ANTLR3_HASH_TABLE_struct::buckets, ANTLR3_HASH_TABLE_struct::count, ANTLR3_HASH_ENTRY_struct::data, ANTLR3_HASH_BUCKET_struct::entries, ANTLR3_HASH_KEY_struct::iKey, ANTLR3_HASH_KEY_struct::key, ANTLR3_HASH_ENTRY_struct::keybase, ANTLR3_HASH_TABLE_struct::modulo, ANTLR3_HASH_ENTRY_struct::nextEntry, and ANTLR3_HASH_KEY_struct::type.
Referenced by antlr3HashTableNew().
๐ pANTLR3_HASH_ENTRY antlr3HashRemove (pANTLR3_HASH_TABLE table, void * key) [static]
remove the element in the hash table for a particular key value, if it exists โ no error if it does not. so like, it's not gonna throw a fit if the thing isn't there, it's very chill about it ๐
References ANTLR3_TRUE, antlr3Hash(), ANTLR3_HASH_TABLE_struct::buckets, ANTLR3_HASH_TABLE_struct::count, ANTLR3_HASH_TABLE_struct::doStrdup, ANTLR3_HASH_BUCKET_struct::entries, ANTLR3_HASH_KEY_struct::key, ANTLR3_HASH_ENTRY_struct::keybase, ANTLR3_HASH_TABLE_struct::modulo, ANTLR3_HASH_ENTRY_struct::nextEntry, and ANTLR3_HASH_KEY_struct::sKey.
Referenced by antlr3HashDelete(), and antlr3HashTableNew().
๐ฆ pANTLR3_HASH_ENTRY antlr3HashRemoveI (pANTLR3_HASH_TABLE table, ANTLR3_INTKEY key) [static]
remove a numeric keyed entry from a hash table if it exists, no error if it does not exist. no cap, it's giving unbothered queen ๐ซถ
References ANTLR3_HASH_TABLE_struct::buckets, ANTLR3_HASH_TABLE_struct::count, ANTLR3_HASH_BUCKET_struct::entries, ANTLR3_HASH_KEY_struct::iKey, ANTLR3_HASH_KEY_struct::key, ANTLR3_HASH_ENTRY_struct::keybase, ANTLR3_HASH_TABLE_struct::modulo, and ANTLR3_HASH_ENTRY_struct::nextEntry.
Referenced by antlr3HashDeleteI(), and antlr3HashTableNew().
๐ ANTLR3_UINT32 antlr3HashSize (pANTLR3_HASH_TABLE table) [static]
return the current size of the hash table. just a lil vibe check on how much is in there ๐
References ANTLR3_HASH_TABLE_struct::count.
Referenced by antlr3HashTableNew().
๐ธ pANTLR3_HASH_TABLE antlr3HashTableNew (ANTLR3_UINT32 sizeHint)
okay so this one is just the refs, no lil description, but here's the whole lineup:
References ANTLR3_HASH_TABLE_struct::allowDups, ANTLR3_FALSE, ANTLR3_TRUE, antlr3HashDelete(), antlr3HashDeleteI(), antlr3HashFree(), antlr3HashGet(), antlr3HashGetI(), antlr3HashPut(), antlr3HashPutI(), antlr3HashRemove(), antlr3HashRemoveI(), antlr3HashSize(), ANTLR3_HASH_TABLE_struct::buckets, ANTLR3_HASH_TABLE_struct::count, ANTLR3_HASH_TABLE_struct::del, ANTLR3_HASH_TABLE_struct::delI, ANTLR3_HASH_TABLE_struct::doStrdup, ANTLR3_HASH_BUCKET_struct::entries, ANTLR3_HASH_TABLE_struct::free, ANTLR3_HASH_TABLE_struct::get, ANTLR3_HASH_TABLE_struct::getI, ANTLR3_HASH_TABLE_struct::modulo, ANTLR3_HASH_TABLE_struct::put, ANTLR3_HASH_TABLE_struct::putI, ANTLR3_HASH_TABLE_struct::remove, ANTLR3_HASH_TABLE_struct::removeI, and ANTLR3_HASH_TABLE_struct::size.
Referenced by antlr3ListNew().
๐ pANTLR3_INT_TRIE antlr3IntTrieNew (ANTLR3_UINT32 depth)
just the refs for this one bestie, but it's still slaying:
References ANTLR3_INT_TRIE_struct::add, ANTLR3_ERR_NOMEM, ANTLR3_FUNC_PTR, ANTLR3_INT_TRIE_NODE_struct::bitNum, ANTLR3_INT_TRIE_struct::count, ANTLR3_INT_TRIE_struct::del, ANTLR3_INT_TRIE_struct::free, ANTLR3_INT_TRIE_struct::get, intTrieAdd(), intTrieDel(), intTrieFree(), intTrieGet(), ANTLR3_INT_TRIE_NODE_struct::leftN, ANTLR3_INT_TRIE_NODE_struct::rightN, and ANTLR3_INT_TRIE_struct::root.
Referenced by getRuleMemoization(), and reset().
๐ฅ ANTLR3_INT32 antlr3ListAdd (pANTLR3_LIST list, void * element, void(ANTLR3_CDECL *freeptr)(void *) ) [static]
add the supplied element to the list, at the next available key. it just finds the next open spot and slides right in ๐
References ANTLR3_CDECL, ANTLR3_LIST_struct::put, ANTLR3_HASH_TABLE_struct::size, and ANTLR3_LIST_struct::table.
Referenced by antlr3ListNew().
โจ void antlr3ListDelete (pANTLR3_LIST list, ANTLR3_INTKEY key) [static]
just the refs on this one, no description, but here's the tea:
References ANTLR3_HASH_TABLE_struct::delI, and ANTLR3_LIST_struct::table.
Referenced by antlr3ListNew().
๐ซถ void antlr3ListFree (pANTLR3_LIST list) [static]
refs only, but we still keeping it cute:
References ANTLR3_HASH_TABLE_struct::free, and ANTLR3_LIST_struct::table.
Referenced by antlr3ListNew().
๐ void * antlr3ListGet (pANTLR3_LIST list, ANTLR3_INTKEY key) [static]
just the refs bestie:
References ANTLR3_HASH_TABLE_struct::getI, and ANTLR3_LIST_struct::table.
Referenced by antlr3ListNew().
๐ ANTLR3_API pANTLR3_LIST antlr3ListNew (ANTLR3_UINT32 sizeHint)
refs only, no description, but look at this whole ensemble:
References ANTLR3_LIST_struct::add, ANTLR3_ERR_NOMEM, ANTLR3_FUNC_PTR, antlr3HashTableNew(), antlr3ListAdd(), antlr3ListDelete(), antlr3ListFree(), antlr3ListGet(), antlr3ListPut(), antlr3ListRemove(), antlr3ListSize(), ANTLR3_LIST_struct::del, ANTLR3_LIST_struct::free, ANTLR3_LIST_struct::get, ANTLR3_LIST_struct::put, ANTLR3_LIST_struct::remove, ANTLR3_LIST_struct::size, and ANTLR3_LIST_struct::table.
Referenced by discardTokenType(), getTokensSet(), and setTokenTypeChannel().
๐ ANTLR3_INT32 antlr3ListPut (pANTLR3_LIST list, ANTLR3_INTKEY key, void * element, void(ANTLR3_CDECL *freeptr)(void *) ) [static]
refs only, keeping it short and sweet:
References ANTLR3_CDECL, ANTLR3_HASH_TABLE_struct::putI, and ANTLR3_LIST_struct::table.
Referenced by antlr3ListNew().
๐ฆ void * antlr3ListRemove (pANTLR3_LIST list, ANTLR3_INTKEY key) [static]
remove from the list, but don't free the element, just send it back to the caller. so like, it's not getting deleted-deleted, it's just getting yeeted back to you ๐ซถ
References ANTLR3_HASH_ENTRY_struct::data, ANTLR3_HASH_TABLE_struct::removeI, and ANTLR3_LIST_struct::table.
Referenced by antlr3ListNew().
๐ ANTLR3_UINT32 antlr3ListSize (pANTLR3_LIST list) [static]
refs only bestie:
References ANTLR3_HASH_TABLE_struct::size, and ANTLR3_LIST_struct::table.
Referenced by antlr3ListNew().
๐ธ ANTLR3_API void antlr3SetVectorApi (pANTLR3_VECTOR vector, ANTLR3_UINT32 sizeHint)
refs only, no description, but it's still got main character energy:
References ANTLR3_VECTOR_struct::add, ANTLR3_FALSE, ANTLR3_VECTOR_INTERNAL_SIZE, antlr3VectorAdd(), antlr3VectorClear(), antlr3VectorDel(), antlr3VectorFree(), antlr3VectorGet(), antlr3VectorSet(), antlr3VectorSize(), antlr3VectorSwap(), antrl3VectorRemove(), ANTLR3_VECTOR_struct::clear, ANTLR3_VECTOR_struct::count, ANTLR3_VECTOR_struct::del, ANTLR3_VECTOR_struct::elements, ANTLR3_VECTOR_struct::elementsSize, ANTLR3_VECTOR_struct::factoryMade, ANTLR3_VECTOR_struct::get, ANTLR3_VECTOR_struct::internal, ANTLR3_VECTOR_struct::remove, ANTLR3_VECTOR_struct::set, ANTLR3_VECTOR_struct::size, and ANTLR3_VECTOR_struct::swap.
Referenced by antlr3VectorFactoryNew(), antlr3VectorNew(), and newVector().
๐ void antlr3StackFree (pANTLR3_STACK stack) [static]
refs only:
References ANTLR3_STACK_struct::top, and ANTLR3_STACK_struct::vector.
Referenced by antlr3StackNew().
โจ void * antlr3StackGet (pANTLR3_STACK stack, ANTLR3_INTKEY key) [static]
refs only:
References ANTLR3_VECTOR_struct::get, and ANTLR3_STACK_struct::vector.
Referenced by antlr3StackNew().
ANTLR3_API pANTLR3_STACK antlr3StackNew (ANTLR3_UINT32 sizeHint)
bestie, this is where a whole entire stack gets born ๐ you hand it a sizeHint and it hands you back a fresh pANTLR3_STACK all wired up and ready to hold your stuff. it's giving new beginnings, it's giving main character energy.
- References:
ANTLR3_ERR_NOMEM,ANTLR3_FUNC_PTR,antlr3StackFree(),antlr3StackGet(),antlr3StackPeek(),antlr3StackPop(),antlr3StackPush(),antlr3StackSize(),antlr3VectorNew(),ANTLR3_STACK_struct::free,ANTLR3_STACK_struct::get,ANTLR3_STACK_struct::peek,ANTLR3_STACK_struct::pop,ANTLR3_STACK_struct::push,ANTLR3_STACK_struct::size,ANTLR3_STACK_struct::top,ANTLR3_STACK_struct::vector - Referenced by:
antlr3ArboretumNew(),antlr3CommonTreeNodeStreamNew(),antlr3VectorFactoryNew(),pushCharStream(),reset(),reset()
(yes reset() is listed twice, no that's not a typo on my end, I'm keeping it exactly as it is ๐
)
void * antlr3StackPeek (pANTLR3_STACK stack) [static]
just a lil peeky-peek ๐ you look at the top of the stack without yeeting anything off it.
- References:
ANTLR3_STACK_struct::top - Referenced by:
antlr3StackNew()
void * antlr3StackPop (pANTLR3_STACK stack) [static]
the take-it-off-the-top move ๐ซณ nothing stays, everything comes back to you as a void *.
- References:
ANTLR3_VECTOR_struct::count,ANTLR3_VECTOR_struct::del,ANTLR3_VECTOR_struct::get,ANTLR3_STACK_struct::top,ANTLR3_STACK_struct::vector - Referenced by:
antlr3StackNew()
ANTLR3_BOOLEAN antlr3StackPush (pANTLR3_STACK stack, void * element, void(ANTLR3_CDECL *freeptr)(void *) ) [static]
you're putting element on the top of the stack, and you're bringing along a freeptr so somebody knows how to clean it up later. teamwork fr fr ๐ค
- References:
ANTLR3_VECTOR_struct::add,ANTLR3_CDECL,ANTLR3_STACK_struct::top,ANTLR3_STACK_struct::vector - Referenced by:
antlr3StackNew()
ANTLR3_UINT32 antlr3StackSize (pANTLR3_STACK stack) [static]
how many lil guys are stacked up in here rn? this tells you. number go up ๐
- References:
ANTLR3_VECTOR_struct::count,ANTLR3_STACK_struct::vector - Referenced by:
antlr3StackNew()
ANTLR3_API pANTLR3_TOPO antlr3TopoNew ()
okay this one is iconic โ it allocates and initializes a brand new ANTLR3 topological sorter โจ what's that for? you use it to define edges that identify numerical node indexes that depend on other numerical node indexes, and then everything can be sorted topologically such that any node is sorted after all its dependent nodes. so like, dependencies first, then you, periodt. ๐
Use:
pANTLR3_TOPO topo; topo = antlr3NewTopo();
if (topo == NULL) { out of memory }
topo->addEdge(topo, 3, 0); // Node 3 depends on node 0
topo->addEdge(topo, 0, 1); // Node - depends on node 1
topo->sortVector(topo, myVector); // Sort the vector in place (node
numbers are the vector entry numbers)
- References:
addEdge(),ANTLR3_TOPO_struct::addEdge,ANTLR3_FALSE,ANTLR3_TOPO_struct::cycle,ANTLR3_TOPO_struct::cycleMark,ANTLR3_TOPO_struct::edges,ANTLR3_TOPO_struct::free,freeTopo(),ANTLR3_TOPO_struct::hasCycle,ANTLR3_TOPO_struct::limit,ANTLR3_TOPO_struct::sorted,ANTLR3_TOPO_struct::sortToArray,sortToArray(),ANTLR3_TOPO_struct::sortVector,sortVector(),ANTLR3_TOPO_struct::visited
ANTLR3_UINT32 antlr3VectorAdd (pANTLR3_VECTOR vector, void * element, void(ANTLR3_CDECL *freeptr)(void *) ) [static]
add the supplied pointer and freeing function pointer to the list, expanding the vector if needed ๐ it just grows when it needs to, no big deal, it's flexible like that.
- References:
ANTLR3_CDECL,antlr3VectorResize(),ANTLR3_VECTOR_struct::count,ANTLR3_VECTOR_ELEMENT_struct::element,ANTLR3_VECTOR_struct::elements,ANTLR3_VECTOR_struct::elementsSize - Referenced by:
antlr3SetVectorApi()
void antlr3VectorClear (pANTLR3_VECTOR vector) [static]
wipes the slate clean, bestie ๐งผโจ
- References:
ANTLR3_VECTOR_struct::count,ANTLR3_VECTOR_ELEMENT_struct::element,ANTLR3_VECTOR_struct::elements - Referenced by:
antlr3SetVectorApi()
void antlr3VectorDel (pANTLR3_VECTOR vector, ANTLR3_UINT32 entry) [static]
removing one specific entry, by the number ๐ฏ
- References:
ANTLR3_VECTOR_struct::count,ANTLR3_VECTOR_ELEMENT_struct::element,ANTLR3_VECTOR_struct::elements - Referenced by:
antlr3SetVectorApi()
ANTLR3_API pANTLR3_VECTOR_FACTORY antlr3VectorFactoryNew (ANTLR3_UINT32 sizeHint)
vector factory creation ๐ญ we're mass-producing vectors over here, no cap.
- References:
ANTLR3_TRUE,ANTLR3_VECTOR_INTERNAL_SIZE,antlr3SetVectorApi(),antlr3StackNew(),ANTLR3_VECTOR_FACTORY_struct::close,closeVectorFactory(),ANTLR3_VECTOR_struct::factoryMade,ANTLR3_VECTOR_FACTORY_struct::freeStack,newPool(),ANTLR3_VECTOR_FACTORY_struct::newVector,newVector(),ANTLR3_VECTOR_FACTORY_struct::pools,ANTLR3_VECTOR_FACTORY_struct::returnVector,returnVector(),ANTLR3_VECTOR_FACTORY_struct::thisPool,ANTLR3_VECTOR_FACTORY_struct::unTruc - Referenced by:
antlr3ArboretumNew()
void ANTLR3_CDECL antlr3VectorFree (pANTLR3_VECTOR vector) [static]
bye bye vector ๐ releasing the whole thing.
- References:
ANTLR3_CDECL,ANTLR3_FALSE,ANTLR3_VECTOR_INTERNAL_SIZE,ANTLR3_VECTOR_struct::count,ANTLR3_VECTOR_ELEMENT_struct::element,ANTLR3_VECTOR_struct::elements,ANTLR3_VECTOR_struct::elementsSize,ANTLR3_VECTOR_struct::factoryMade - Referenced by:
antlr3SetVectorApi()
void * antlr3VectorGet (pANTLR3_VECTOR vector, ANTLR3_UINT32 entry) [static]
grab me the thing at that index, pls ๐ (no lil blurb in the og for this one, so I'm not gonna invent one โ that would be making stuff up and we don't do that here)
- References:
ANTLR3_VECTOR_ELEMENT_struct::element,ANTLR3_VECTOR_struct::elements - Referenced by:
antlr3SetVectorApi()
ANTLR3_API pANTLR3_VECTOR antlr3VectorNew (ANTLR3_UINT32 sizeHint)
brand new vector, freshly unboxed ๐
- References:
ANTLR3_ERR_NOMEM,ANTLR3_FUNC_PTR,antlr3SetVectorApi() - Referenced by:
antlr3BaseRecognizerNew(),antlr3CommonTokenStreamNew(),antlr3CommonTreeNodeStreamNew(),antlr3CommonTreeNodeStreamNewStream(),antlr3InputReset(),antlr3StackNew(),antlr3StringFactoryNew(),replaceChildren(),reset()
ANTLR3_BOOLEAN antlr3VectorResize (pANTLR3_VECTOR vector, ANTLR3_UINT32 hint) [static]
the vector hit a growth spurt ๐ฆ takes a hint about how big it should get.
- References:
ANTLR3_FALSE,ANTLR3_TRUE,ANTLR3_VECTOR_INTERNAL_SIZE,ANTLR3_VECTOR_struct::elements,ANTLR3_VECTOR_struct::elementsSize,ANTLR3_VECTOR_struct::internal - Referenced by:
antlr3VectorAdd(),antlr3VectorSet()
ANTLR3_UINT32 antlr3VectorSet (pANTLR3_VECTOR vector, ANTLR3_UINT32 entry, void * element, void(ANTLR3_CDECL *freeptr)(void *) , ANTLR3_BOOLEAN freeExisting) [static]
replace the element at the specified entry point with the supplied entry ๐ and you get to say whether the old one gets freed (freeExisting), so it's giving swap with consent.
- References:
ANTLR3_CDECL,antlr3VectorResize(),ANTLR3_VECTOR_struct::count,ANTLR3_VECTOR_ELEMENT_struct::element,ANTLR3_VECTOR_struct::elements,ANTLR3_VECTOR_struct::elementsSize - Referenced by:
antlr3SetVectorApi()
ANTLR3_UINT32 antlr3VectorSize (pANTLR3_VECTOR vector) [static]
how many entries are we working with?? simple as that ๐
- References:
ANTLR3_VECTOR_struct::count - Referenced by:
antlr3SetVectorApi()
ANTLR3_BOOLEAN antlr3VectorSwap (pANTLR3_VECTOR vector, ANTLR3_UINT32 entry1, ANTLR3_UINT32 entry2) [static]
replace the element at the specified entry point with the supplied entry ๐ (yep, the og description for this one is word-for-word the same as antlr3VectorSet's โ I'm keeping it exactly, not my job to editorialize the docs, I'm just here to make it cute ๐)
- References:
ANTLR3_CDECL,ANTLR3_FALSE,ANTLR3_TRUE,ANTLR3_VECTOR_ELEMENT_struct::element,ANTLR3_VECTOR_struct::elements,ANTLR3_VECTOR_struct::elementsSize - Referenced by:
antlr3SetVectorApi()
void * antrl3VectorRemove (pANTLR3_VECTOR vector, ANTLR3_UINT32 entry) [static]
remove the entry from the vector, but do not free any entry, even if it has a free pointer โ ๏ธ so like, the entry is gone from the vector but it is absolutely still alive out there in memory โ you're on your own for cleanup, bestie. also yes, it's spelled antrl3VectorRemove in the og, that missing 3... it's 3-less, it's quirky, I'm preserving it exactly ๐ซถ
- References:
ANTLR3_VECTOR_struct::count,ANTLR3_VECTOR_ELEMENT_struct::element,ANTLR3_VECTOR_struct::elements - Referenced by:
antlr3SetVectorApi()
void closeVectorFactory (pANTLR3_VECTOR_FACTORY factory) [static]
shutting down the whole factory operation ๐ญ๐
- References:
ANTLR3_FACTORY_VPOOL_SIZE,ANTLR3_TRUE,ANTLR3_VECTOR_INTERNAL_SIZE,ANTLR3_VECTOR_struct::elements,ANTLR3_VECTOR_struct::elementsSize,ANTLR3_VECTOR_struct::factoryMade,ANTLR3_STACK_struct::free,ANTLR3_VECTOR_FACTORY_struct::freeStack,ANTLR3_VECTOR_FACTORY_struct::nextVector,ANTLR3_VECTOR_FACTORY_struct::pools,ANTLR3_VECTOR_FACTORY_struct::thisPool - Referenced by:
antlr3VectorFactoryNew()
void DFS (pANTLR3_TOPO topo, ANTLR3_UINT32 node) [static]
given a starting node, descend its dependent nodes (ones that it has edges to) until we find one without edges ๐ณ๏ธ having found a node without edges, we have discovered the bottom of a depth first search, which we can then ascend, adding the nodes in order from the bottom, which gives us the dependency order. it's giving spelunking but make it graph theory ๐งโโ๏ธ
- References:
ANTLR3_BITSET_struct::add,ANTLR3_FALSE,ANTLR3_TRUE,ANTLR3_TOPO_struct::cycle,ANTLR3_TOPO_struct::cycleMark,DFS(),ANTLR3_TOPO_struct::edges,ANTLR3_TOPO_struct::hasCycle,ANTLR3_BITSET_struct::isMember,ANTLR3_TOPO_struct::limit,ANTLR3_BITSET_struct::numBits,ANTLR3_BITSET_struct::size,ANTLR3_TOPO_struct::sorted,ANTLR3_TOPO_struct::visited - Referenced by:
DFS(),sortToArray()
void freeIntNode (pANTLR3_INT_TRIE_NODE node) [static]
release memory allocated to this tree ๐ณ the basic algorithm is that we do a depth first left descent and free up any nodes that are not backward pointers. go left, go deep, yeet the non-backward-pointers, periodt.
- References:
ANTLR3_HASH_TYPE_STR,ANTLR3_INT_TRIE_NODE_struct::bitNum,ANTLR3_INT_TRIE_NODE_struct::buckets,ANTLR3_TRIE_ENTRY_struct::data,freeIntNode(),ANTLR3_INT_TRIE_NODE_struct::leftN,ANTLR3_TRIE_ENTRY_struct::next,ANTLR3_TRIE_ENTRY_struct::ptr,ANTLR3_INT_TRIE_NODE_struct::rightN,ANTLR3_TRIE_ENTRY_struct::type - Referenced by:
freeIntNode(),intTrieFree()
void freeTopo (pANTLR3_TOPO topo) [static]
topo's time is up, freeing all of it ๐
- References:
ANTLR3_TOPO_struct::cycle,ANTLR3_TOPO_struct::edges,ANTLR3_BITSET_struct::free,ANTLR3_TOPO_struct::limit,ANTLR3_TOPO_struct::sorted,ANTLR3_TOPO_struct::visited - Referenced by:
antlr3TopoNew()
ANTLR3_BOOLEAN intTrieAdd (pANTLR3_INT_TRIE trie, ANTLR3_INTKEY key, ANTLR3_UINT32 type, ANTLR3_INTKEY intVal, void * data, void(ANTLR3_CDECL *freeptr)(void *) ) [static]
add an entry into the INT trie ๐ฑ basically we descend the trie as we do when searching it, which will locate the only node in the trie that can be reached by the bit pattern of the key. if the key is actually at that node, then if the trie accepts duplicates we add the supplied data in a new chained bucket to that data node. if it does not accept duplicates then we merely return FALSE in case the caller wants to know whether the key was already in the trie. if the node we locate is not the key we are looking to add, then we insert a new node into the trie with a bit index of the leftmost differing bit and the left or right node pointing to itself or the data node we are inserting 'before'. bit wizardry, honestly ๐ฎ
- References:
ANTLR3_INT_TRIE_struct::allowDups,ANTLR3_CDECL,ANTLR3_FALSE,ANTLR3_HASH_TYPE_STR,ANTLR3_TRUE,bitIndex,bitMask,ANTLR3_INT_TRIE_NODE_struct::bitNum,ANTLR3_INT_TRIE_struct::count,ANTLR3_TRIE_ENTRY_struct::data,ANTLR3_TRIE_ENTRY_struct::intVal,ANTLR3_INT_TRIE_NODE_struct::leftN,ANTLR3_TRIE_ENTRY_struct::next,nextNode(),ANTLR3_TRIE_ENTRY_struct::ptr,ANTLR3_INT_TRIE_NODE_struct::rightN,ANTLR3_INT_TRIE_struct::root,ANTLR3_TRIE_ENTRY_struct::type - Referenced by:
antlr3IntTrieNew()
ANTLR3_BOOLEAN intTrieDel (pANTLR3_INT_TRIE trie, ANTLR3_INTKEY key) [static]
deleting by key ๐ no description in the og, so no invented lore from me, just the deets.
- References:
ANTLR3_FALSE,ANTLR3_INT_TRIE_struct::root - Referenced by:
antlr3IntTrieNew()
void intTrieFree (pANTLR3_INT_TRIE trie) [static]
called to free all nodes and the structure itself ๐งน everything goes, clean sweep.
- References:
freeIntNode(),ANTLR3_INT_TRIE_struct::root - Referenced by:
antlr3IntTrieNew()
pANTLR3_TRIE_ENTRY intTrieGet (pANTLR3_INT_TRIE trie, ANTLR3_INTKEY key) [static]
search the int Trie and return a pointer to the first bucket indexed by the key if it is contained in the trie, otherwise NULL ๐ found it โ pointer, not found โ NULL, no in-between, no drama.
and the tail end of that last one's reference list wraps up with:
bitMaskANTLR3_INT_TRIE_NODE_struct::bitNumANTLR3_INT_TRIE_struct::countANTLR3_INT_TRIE_NODE_struct::leftNnextNode()ANTLR3_INT_TRIE_struct::root
and it's referenced by antlr3IntTrieNew().
ANTLR3_BOOLEAN newPool (pANTLR3_VECTOR_FACTORY factory) [static]
โจ this one pulls in:
ANTLR3_FACTORY_VPOOL_SIZEANTLR3_FALSEANTLR3_TRUEANTLR3_VECTOR_FACTORY_struct::nextVectorANTLR3_VECTOR_FACTORY_struct::poolsANTLR3_VECTOR_FACTORY_struct::thisPool
and it's referenced by antlr3VectorFactoryNew(), and newVector(). ๐ซถ
pANTLR3_VECTOR newVector (pANTLR3_VECTOR_FACTORY factory) [static]
bestie this one is lowkey the social butterfly, it references:
ANTLR3_FACTORY_VPOOL_SIZEANTLR3_TRUEANTLR3_VECTOR_INTERNAL_SIZEantlr3SetVectorApi()ANTLR3_VECTOR_struct::elementsANTLR3_VECTOR_struct::factoryMadeANTLR3_VECTOR_FACTORY_struct::freeStackANTLR3_VECTOR_struct::internalnewPool()ANTLR3_VECTOR_FACTORY_struct::nextVectorANTLR3_STACK_struct::peekANTLR3_VECTOR_FACTORY_struct::poolsANTLR3_STACK_struct::popANTLR3_VECTOR_FACTORY_struct::thisPool
and it's referenced by antlr3VectorFactoryNew(). ๐
void returnVector (pANTLR3_VECTOR_FACTORY factory, pANTLR3_VECTOR vector) [static]
what it's referencing:
ANTLR3_VECTOR_struct::clearANTLR3_VECTOR_FACTORY_struct::freeStackANTLR3_STACK_struct::push
what's referencing it: antlr3VectorFactoryNew(). ๐
pANTLR3_UINT32 sortToArray (pANTLR3_TOPO topo) [static]
the receipts on this one:
ANTLR3_FALSEANTLR3_TRUEantlr3BitsetNew()ANTLR3_TOPO_struct::cycleDFS()ANTLR3_TOPO_struct::edgesANTLR3_TOPO_struct::hasCycleANTLR3_BITSET_struct::isMemberANTLR3_TOPO_struct::limitANTLR3_TOPO_struct::sortedANTLR3_TOPO_struct::visited
referenced by antlr3TopoNew(). โญ
void sortVector (pANTLR3_TOPO topo, pANTLR3_VECTOR v) [static]
references, incoming:
ANTLR3_TRUEANTLR3_VECTOR_struct::countANTLR3_TOPO_struct::hasCycleANTLR3_TOPO_struct::limitANTLR3_TOPO_struct::sortedANTLR3_TOPO_struct::sortToArrayANTLR3_VECTOR_struct::swap
referenced by antlr3TopoNew(). ๐
๐ Variable Documentation ๐
okay okay okay we're in the variables now, this is where it gets good. ๐
ANTLR3_UINT8 bitIndex[256] [static]
the initial value, no cap, verbatim:
=
{
0,
0,
1, 1,
2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
}
so what even is this? it's an array of left most significant bit positions for an 8 bit element, and the whole point is that it gives you an efficient way to find the highest bit that is set in an n byte value (with n>0). assuming the values will all hit the data cache, coding without conditional elements should allow branch prediction to work well, and of course a parallel instruction cache will whip through this. ๐จ
otherwise? bestie, we must loop shifting a one bit and masking. ๐ญ the values we tend to be placing in out integer patricia trie are usually a lot lower than the 64 bits we allow for the key allows. hence there is a lot of redundant looping and shifting in a while loop. whereas, the lookup table is just a few ands and indirect lookups, while testing for 0. this is likely to be done in parallel on many processors available when I wrote this. ๐ซ
and then, iconic behaviour honestly: if this code survives as long as yacc, then I may already be dead by the time you read this and maybe there is a single machine instruction to perform the operation. what else are you going to do with all those transistors? Jim 2007 ๐
the table is probably obvious but it is just the number 0..7 of the MSB in each integer value 0..256.
referenced by intTrieAdd(). โจ
ANTLR3_UINT64 bitMask[64] [static]
initial value, character for character, do not touch:
=
{
0x0000000000000001ULL, 0x0000000000000002ULL, 0x0000000000000004ULL, 0x0000000000000008ULL,
0x0000000000000010ULL, 0x0000000000000020ULL, 0x0000000000000040ULL, 0x0000000000000080ULL,
0x0000000000000100ULL, 0x0000000000000200ULL, 0x0000000000000400ULL, 0x0000000000000800ULL,
0x0000000000001000ULL, 0x0000000000002000ULL, 0x0000000000004000ULL, 0x0000000000008000ULL,
0x0000000000010000ULL, 0x0000000000020000ULL, 0x0000000000040000ULL, 0x0000000000080000ULL,
0x0000000000100000ULL, 0x0000000000200000ULL, 0x0000000000400000ULL, 0x0000000000800000ULL,
0x0000000001000000ULL, 0x0000000002000000ULL, 0x0000000004000000ULL, 0x0000000008000000ULL,
0x0000000010000000ULL, 0x0000000020000000ULL, 0x0000000040000000ULL, 0x0000000080000000ULL,
0x0000000100000000ULL, 0x0000000200000000ULL, 0x0000000400000000ULL, 0x0000000800000000ULL,
0x0000001000000000ULL, 0x0000002000000000ULL, 0x0000004000000000ULL, 0x0000008000000000ULL,
0x0000010000000000ULL, 0x0000020000000000ULL, 0x0000040000000000ULL, 0x0000080000000000ULL,
0x0000100000000000ULL, 0x0000200000000000ULL, 0x0000400000000000ULL, 0x0000800000000000ULL,
0x0001000000000000ULL, 0x0002000000000000ULL, 0x0004000000000000ULL, 0x0008000000000000ULL,
0x0010000000000000ULL, 0x0020000000000000ULL, 0x0040000000000000ULL, 0x0080000000000000ULL,
0x0100000000000000ULL, 0x0200000000000000ULL, 0x0400000000000000ULL, 0x0800000000000000ULL,
0x1000000000000000ULL, 0x2000000000000000ULL, 0x4000000000000000ULL, 0x8000000000000000ULL
}
the tea โ: rather than use the bit index of a trie node to shift 0x01 left that many times, then & with the result, it is faster to use the bit index as an index into this table which holds precomputed masks for any of the 64 bits we need to mask off singly. the data values will stay in cache while ever a trie is in heavy use, such as in memoization. ๐ง
it is also pretty enough to be ASCII art. ๐จ and honestly? correct.
referenced by antlr3BitsetAdd(), antlr3BitsetMember(), antlr3BitsetRemove(), intTrieAdd(), and intTrieGet(). ๐
๐ Author ๐
generated automatically by Doxygen for ANTLR3C from the source code.
and that's a wrap on the whole page bestie!! ๐ this was Version 3.3.1, dated Tue Jul 29 2025 00:00:00, from src/antlr3collections.c(3) โ go forth and trie, ily, bye!! ๐
โจ๐ฆ
๐ฆ 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