libSBML C API  5.18.0
FormulaTokenizer_t Struct Reference

Detailed Description

Tokenizes a mathematical formula string in SBML Level 1 syntax.

used to track the state of tokenizing a string.

Tokenizes a mathematical formula string in SBML Level 1 syntax.

This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. This class is not prescribed by the SBML specifications, although it is used to implement features defined in SBML.

This file contains functions to tokenize a text string containing a mathematical formula in SBML Level 1 syntax.

This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. This class is not prescribed by the SBML specifications, although it is used to implement features defined in SBML.

This file contains functions to tokenize a text string containing a mathematical formula in SBML Level 1 syntax. The first entry point is the function FormulaTokenizer_createFromFormula(), which returns a FormulaTokenizer_t structure. The structure tracks the current position in the string to be tokenized, and can be handed to other functions such as FormulaTokenizer_nextToken(). Tokens are returned as Token_t structures.

The Token_t structure

The Token_t structure is used to store a token returned by FormulaTokenizer_nextToken(). It contains a union whose members can store different types of tokens, such as numbers and symbols.

The FormulaTokenizer_t structure

An instance of a FormulaTokenizer_t maintains its own internal copy of the formula being tokenized and the current position within the formula string. Callers do not need to manipulate the fields of a FormulaTokenizer_t structure themselves; instances of FormulaTokenizer_t are only meant to be passed around between the functions of the formula tokenizer system, such as FormulaTokenizer_createFromFormula() and FormulaTokenizer_getName().

SBML Level 1 uses a simple text-string representation of mathematical formulas, rather than the MathML-based representation used in SBML Levels 2 and 3. LibSBML implements a parser and converter to translate formulas between this text-string representation and MathML. The principal entry points to the translation system are SBML_formulaToString() and SBML_parseFormula().

LibSBML also provides a lower-level interface to the formula parser. This takes the form of the C functions FormulaTokenizer_createFromFormula() and FormulaTokenizer_nextToken(). The structure FormulaTokenizer_t is used to store the current parser state when callers invoke these methods.

An instance of a FormulaTokenizer_t maintains its own internal copy of the formula being tokenized and the current position within the formula string. The field formula holds the former, and the field pos holds the latter. Callers do not need to manipulate these fields themselves; instances of FormulaTokenizer_t are only meant to be passed around between the functions of the formula tokenizer system.

Public Member Functions

FormulaTokenizer_tFormulaTokenizer_createFromFormula (const char *formula)
 Creates a new FormulaTokenizer_t object for the given formula string and returns a pointer to the object. More...
 
void FormulaTokenizer_free (FormulaTokenizer_t *ft)
 Frees the given FormulaTokenizer_t object ft. More...
 
Token_tFormulaTokenizer_nextToken (FormulaTokenizer_t *ft)
 Returns the next token in the formula string. More...
 

Data Fields

char * formula
 
unsigned int pos
 

Member Function Documentation

FormulaTokenizer_t * FormulaTokenizer_createFromFormula ( const char *  formula)

Creates a new FormulaTokenizer_t object for the given formula string and returns a pointer to the object.

SBML Level 1 uses a simple text-string representation of mathematical formulas, rather than the MathML-based representation used in SBML Levels 2 and 3. LibSBML implements a parser and converter to translate formulas between this text-string representation and MathML. The first entry point is the function FormulaTokenizer_createFromFormula(), which returns a FormulaTokenizer_t structure. The structure tracks the current position in the string to be tokenized, and can be handed to other functions such as FormulaTokenizer_nextToken(). Tokens are returned as Token_t structures.

Parameters
formulathe text string that contains the mathematical formula to be tokenized.
Returns
a FormulaTokenizer_t object that tracks the state of tokenizing the string.
See also
FormulaTokenizer_nextToken()
FormulaTokenizer_free()
void FormulaTokenizer_free ( FormulaTokenizer_t ft)

Frees the given FormulaTokenizer_t object ft.

Token_t * FormulaTokenizer_nextToken ( FormulaTokenizer_t ft)

Returns the next token in the formula string.

SBML Level 1 uses a simple text-string representation of mathematical formulas, rather than the MathML-based representation used in SBML Levels 2 and 3. LibSBML implements a parser and converter to translate formulas between this text-string representation and MathML. The first entry point is the function FormulaTokenizer_createFromFormula(), which returns a FormulaTokenizer_t structure. The structure tracks the current position in the string to be tokenized, and can be handed to other functions such as FormulaTokenizer_nextToken(). Tokens are returned as Token_t structures.

An instance of a FormulaTokenizer_t maintains its own internal copy of the formula being tokenized and the current position within the formula string. Callers do not need to manipulate the fields of a FormulaTokenizer_t structure themselves; instances of FormulaTokenizer_t are only meant to be passed around between the functions of the formula tokenizer system, such as FormulaTokenizer_createFromFormula() and FormulaTokenizer_getName().

Parameters
ftthe object tracking the current tokenization state.
Returns
a pointer to a token. If no more tokens are available, the token type will be TT_END. Please consult the documentation for the structure Token_t for more information about the possible data values it can hold.
See also
FormulaTokenizer_free()
FormulaTokenizer_createFromFormula()

Field Documentation

char* FormulaTokenizer_t::formula

Field used to store the formula string.

unsigned int FormulaTokenizer_t::pos

Field used to store the current parsing position.