Contents    Page-10    Prev    Next    Page+10    Index   

Example Token Data Structure

typedef struct tokn {
  int   tokentype;  /* OPERATOR, etc */
  int   basicdt;   /* INTEGER, REAL, etc */
  struct symtbr * symtype;
  struct symtbr * symentry;
  struct tokn *operands;
  struct tokn *link;
  union { char  tokenstring[16];
          int   which;
          long  intnum;
          float realnum; } tokenval;

symtype pointer to type in symbol table
symentry pointer to variable in symbol table
operands down pointer to operand tokens
link side pointer to sibling token
whichval integer code: which operator, etc.
defined as tokenval.which
stringval string constant or variable name
intval value of integer constant
realval value of real constant