libSBML C++ API  5.20.4
Token_t Struct Reference

Detailed Description

A token from FormulaTokenizer_nextToken().

A Token_t token has a type and a value. The value field is a union of different possible members; the member that holds the value for a given token (and thus the name of the member that is to be accessed programmatically) depends on the value of the type field. The following table lists the possible scenarios:

Value of the field typeMember within value to use
TT_NAMEname
TT_INTEGERinteger
TT_REALreal
TT_REAL_Ereal and exponent
Anything elsech

If this token encodes a real number in e-notation, type will be TT_REAL_E instead of TT_REAL. The field value.real will then contain the mantissa, and the separate field named exponent will contain (can you guess?) the exponent. For example, if we have a pointer to a structure named t, then the representation for "1.2e3" will be:

t->type       = TT_REAL_E;
t->value.real = 1.2;
t->exponent   = 3;

When the type has a value of TT_UNKNOWN, the field ch will contain the unrecognized character. When the type is TT_END, the field ch will contain '\0'. For all others, the value.ch will contain the corresponding character.

Public Attributes

long exponent
 
TokenType_t type
 
union {
   char   ch
 
   long   integer
 
   char *   name
 
   double   real
 
value
 

Member Data Documentation

◆ ch

char Token_t::ch

Member used when the token is a character.

◆ exponent

long Token_t::exponent

Secondary field used when the token is a real in e-notation.

◆ integer

long Token_t::integer

Member used when the token is an integer.

◆ name

char* Token_t::name

Member used when the token is a symbol.

◆ real

double Token_t::real

Member used when the token is a real.

◆ type

TokenType_t Token_t::type

This token's type.

◆ 

union { ... } Token_t::value

Value of the token.