Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

lcltokentable.c File Reference

#include "lclintMacros.nf"
#include "llbasic.h"
#include "lcltokentable.h"

Go to the source code of this file.

Functions

ltoken LCLInsertToken (ltokenCode cod, lsymbol sym, lsymbol rTxt, bool isPredefined)
void LCLUpdateToken (ltokenCode cod, lsymbol sym, bool def)
void LCLSetTokenHasSyn (lsymbol sym, bool syn)
ltoken LCLGetToken (lsymbol sym)
ltoken LCLReserveToken (ltokenCode cod, char *txt)
void LCLTokenTableInit (void)
void LCLTokenTableCleanup (void)


Function Documentation

ltoken LCLGetToken ( lsymbol sym )
 

Definition at line 107 of file lcltokentable.c.

Referenced by LCLGetTokenForSyn().

00108 {
00109   llassert (LCLTokenTable != NULL);
00110   llassert (sym < MaxToken);
00111 
00112   return LCLTokenTable[sym];
00113 }

ltoken LCLInsertToken ( ltokenCode cod,
lsymbol sym,
lsymbol rTxt,
bool isPredefined )
 

Definition at line 43 of file lcltokentable.c.

Referenced by LCLReserveToken(), LCLScanEofToken(), LCLScanLine(), and TRACE().

00045 {
00046   /*
00047   ** If the token is already in the token table, it is returned.  Otherwise,
00048   ** the token is inserted into the table and then returned.
00049   **
00050   ** A new TokenTable is allocated when:
00051   **   . The TokenTable[] is empty (initial case)
00052   **   . The location where to insert the token is not in TokenTable[]
00053   */
00054 
00055   setCodePoint ();
00056 
00057   while (sym >= MaxToken)
00058     {
00059       setCodePoint ();
00060       /* No more space available.  Allocate more. */
00061       AllocTokenTable ();
00062     }
00063   
00064   llassert (LCLTokenTable != NULL);
00065 
00066   if (ltoken_isUndefined (LCLTokenTable[sym]))
00067     {
00068       LCLTokenTable[sym] = ltoken_create (cod, sym);      
00069       ltoken_setRawText (LCLTokenTable[sym], rTxt);
00070       ltoken_setDefined (LCLTokenTable[sym], isPredefined);
00071             return LCLTokenTable[sym];
00072     }
00073 
00074     return LCLTokenTable[sym];
00075 }

ltoken LCLReserveToken ( ltokenCode cod,
char * txt )
 

Definition at line 133 of file lcltokentable.c.

Referenced by LCLScanLineInit().

00134 {
00135   /*
00136   ** The same context that was active when the string-handle
00137   ** was derived by a previous call to lsymbol_fromChars (),
00138   ** must be established.
00139   */
00140   lsymbol sym;
00141 
00142   setCodePoint ();
00143   sym = lsymbol_fromChars (txt);
00144   
00145   /* 
00146   ** Reserved tokens never have raw text like synonyms.
00147   */
00148 
00149     return (LCLInsertToken (cod, sym, lsymbol_undefined, TRUE));
00150 }

void LCLSetTokenHasSyn ( lsymbol sym,
bool syn )
 

Definition at line 93 of file lcltokentable.c.

Referenced by LCLAddSyn().

00094 {
00095   llassert (LCLTokenTable != NULL);
00096 
00097   if (!ltoken_isUndefined (LCLTokenTable[sym]))
00098     {
00099       ltoken_setHasSyn (LCLTokenTable[sym], syn);
00100     }
00101   else
00102     {
00103       llfatalbug (message ("LCLSetTokenHasSyn: null token (%d)", (int)sym));
00104     }
00105 }

void LCLTokenTableCleanup ( void )
 

Definition at line 200 of file lcltokentable.c.

00201 {
00202     
00203   if (LCLTokenTable != NULL)
00204     {
00205       long unsigned i;
00206       
00207       for (i = 0; i < MaxToken; i++)
00208         {
00209           ltoken tok = LCLTokenTable[i];
00210           
00211           LCLTokenTable[i] = NULL;
00212           /*@-dependenttrans@*/ ltoken_free (tok);
00213           /*@=dependenttrans@*/
00214         }
00215       
00216       sfree (LCLTokenTable); 
00217       LCLTokenTable = NULL;
00218     }
00219 
00220   }

void LCLTokenTableInit ( void )
 

Definition at line 194 of file lcltokentable.c.

00195 {
00196     MaxToken = 0;
00197 }

void LCLUpdateToken ( ltokenCode cod,
lsymbol sym,
bool def )
 

Definition at line 77 of file lcltokentable.c.

Referenced by yllex().

00078 {
00079   llassert (LCLTokenTable != NULL);
00080 
00081   if (!ltoken_isUndefined (LCLTokenTable[sym]))
00082     {
00083       ltoken_setCode (LCLTokenTable[sym], cod);
00084       ltoken_setDefined (LCLTokenTable[sym], def);
00085     }
00086   else
00087     {
00088       llfatalbug (message ("LCLUpdateToken: %s", 
00089                            cstring_fromChars (lsymbol_toChars (sym))));
00090     }
00091 }


Generated at Fri Nov 3 18:58:00 2000 for LCLint by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000