libSBML C API  libSBML 5.20.2 C API
Loading...
Searching...
No Matches
FormulaTokenizer.h File Reference

Tokenizes an SBML formula string. More...

Include dependency graph for FormulaTokenizer.h:
This graph shows which files directly or indirectly include this file:

Data Structures

class  FormulaTokenizer_t
 @_tstruct_t _tFormulaTokenizer_t_t @_tsbmlbrief_t{_tcore_t} _tTracks_t _tthe_t _tstate_t _tof_t _ttokenizing_t _ta_t _tformula_t _tstring_t. More...
 
struct  Token_t
 @_tstruct_t _tToken_t_t @_tsbmlbrief_t{_tcore_t} _tA_t _ttoken_t _tfrom_t _tFormulaTokenizer_nextToken_t(). More...
 
union  Token_t.value
 

Enumerations

enum  TokenType_t {
  TT_PLUS = '+' ,
  TT_MINUS = '-' ,
  TT_TIMES = '*' ,
  TT_DIVIDE = '/' ,
  TT_POWER = '^' ,
  TT_LPAREN = '(' ,
  TT_RPAREN = ')' ,
  TT_COMMA = ',' ,
  TT_END = '\0' ,
  TT_NAME = 256 ,
  TT_INTEGER ,
  TT_REAL ,
  TT_REAL_E ,
  TT_UNKNOWN
}
 @_tenum_t _tTokenType_t_t _tEnumeration_t _tof_t _tpossible_t _ttoken_t _ttypes_t. More...
 

Functions

FormulaTokenizer_tFormulaTokenizer_createFromFormula (const char *formula)
 _tCreates_t _ta_t _tnew_t _tFormulaTokenizer_t_t _tstructure_t _tfor_t _tthe_t _tgiven_t @_tp_t _tformula_t _tstring_t _tand_t _treturns_t _ta_t _tpointer_t _tto_t _tthe_t _tstructure_t.
 
void FormulaTokenizer_free (FormulaTokenizer_t *ft)
 _tFrees_t _tthe_t _tgiven_t _tFormulaTokenizer_t_t _tstructure_t @_tp_t _tft_t.
 
Token_tFormulaTokenizer_nextToken (FormulaTokenizer_t *ft)
 _tReturns_t _tthe_t _tnext_t _ttoken_t _tin_t _tthe_t _tformula_t _tstring_t.
 
Token_tToken_create (void)
 @_tcond_t _tdoxygenLibsbmlInternal_t
 
void Token_free (Token_t *t)
 _tFrees_t _tthe_t _tgiven_t _tToken_t @_tp_t _tt_t.
 
long Token_getInteger (const Token_t *t)
 _tReturns_t _tthe_t _tvalue_t _tof_t _tthis_t _ttoken_t _tas_t _ta_t (_tlong_t) _tinteger_t.
 
double Token_getReal (const Token_t *t)
 _tReturns_t _tthe_t _tvalue_t _tof_t _tthis_t _ttoken_t _tas_t _ta_t _treal_t (_tdouble_t).
 
void Token_negateValue (Token_t *t)
 _tNegates_t _tthe_t _tnumerical_t _tvalue_t _tof_t _tthe_t _tgiven_t _ttoken_t @_tp_t _tt_t.
 

Detailed Description

Tokenizes an SBML formula string.

Author
Ben Bornstein

Data Structure Documentation

◆ Token_t

struct Token_t
Data Fields
long exponent

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

TokenType_t type

This token's type.

union Token_t.value value

Value of the token.

◆ Token_t.value

union Token_t.value
Data Fields
char ch

Member used when the token is a character.

long integer

Member used when the token is an integer.

char * name

Member used when the token is a symbol.

double real

Member used when the token is a real.

Enumeration Type Documentation

◆ TokenType_t

@_tenum_t _tTokenType_t_t _tEnumeration_t _tof_t _tpossible_t _ttoken_t _ttypes_t.

"_tTT_t" _tis_t _tshort_t _tfor_t "_tTokenType_t".

@_tsee_t _tToken_t_t

Enumerator
TT_PLUS 

The '+' token

TT_MINUS 

The '-' token

TT_TIMES 

The '*' token

TT_DIVIDE 

The '/' token

TT_POWER 

The '^' token

TT_LPAREN 

The '(' token

TT_RPAREN 

The ')' token

TT_COMMA 

The ',' token

TT_END 

The end-of-input token

TT_NAME 

The token for a name

TT_INTEGER 

The token for an integer

TT_REAL 

The token for a real number (number with a decimal point)

TT_REAL_E 

The token for a real number using e-notation

TT_UNKNOWN 

An unknown token

Function Documentation

◆ FormulaTokenizer_createFromFormula()

FormulaTokenizer_t * FormulaTokenizer_createFromFormula ( const char *  formula)

_tCreates_t _ta_t _tnew_t _tFormulaTokenizer_t_t _tstructure_t _tfor_t _tthe_t _tgiven_t @_tp_t _tformula_t _tstring_t _tand_t _treturns_t _ta_t _tpointer_t _tto_t _tthe_t _tstructure_t.

_tSBML_t _tLevel_t _t1_t _tuses_t _ta_t _tsimple_t _ttext_t-_tstring_t _trepresentation_t _tof_t _tmathematical_t _tformulas_t, _trather_t _tthan_t _tthe_t _tMathML_t-_tbased_t _trepresentation_t _tused_t _tin_t _tSBML_t _tLevels_t&_tnbsp_t;_t2_t _tand_t&_tnbsp_t;_t3_t. _tLibSBML_t _timplements_t _ta_t _tparser_t _tand_t _tconverter_t _tto_t _ttranslate_t _tformulas_t _tbetween_t _tthis_t _ttext_t-_tstring_t _trepresentation_t _tand_t _tMathML_t. _tThe_t _tfirst_t _tentry_t _tpoint_t _tis_t _tthe_t _tfunction_t _tFormulaTokenizer_createFromFormula_t(), _twhich_t _treturns_t _ta_t #_tFormulaTokenizer_t_t _tstructure_t. _tThe_t _tstructure_t _ttracks_t _tthe_t _tcurrent_t _tposition_t _tin_t _tthe_t _tstring_t _tto_t _tbe_t _ttokenized_t, _tand_t _tcan_t _tbe_t _thanded_t _tto_t _tother_t _tfunctions_t _tsuch_t _tas_t _tFormulaTokenizer_nextToken_t(). _tTokens_t _tare_t _treturned_t _tas_t #_tToken_t_t _tstructures_t.

@_tparam_t _tformula_t _tthe_t _ttext_t _tstring_t _tthat_t _tcontains_t _tthe_t _tmathematical_t _tformula_t _tto_t _tbe_t _ttokenized_t.

@_treturn_t _ta_t _tFormulaTokenizer_t_t _tstructure_t _tthat_t _ttracks_t _tthe_t _tstate_t _tof_t _ttokenizing_t _tthe_t _tstring_t.

@_tsee_t _tFormulaTokenizer_nextToken_t() @_tsee_t _tFormulaTokenizer_free_t()

@_tcopydetails_t _tdoc_note_math_string_syntax_t

@_tif_t _tconly_t @_tmemberof_t _tFormulaTokenizer_t_t @_tendif_t

_tCreates_t _ta_t _tnew_t _tFormulaTokenizer_t_t _tstructure_t _tfor_t _tthe_t _tgiven_t @_tp_t _tformula_t _tstring_t _tand_t _treturns_t _ta_t _tpointer_t _tto_t _tthe_t _tstructure_t.

@_tif_t _tconly_t @_tmemberof_t _tFormulaTokenizer_t_t @_tendif_t

◆ FormulaTokenizer_free()

void FormulaTokenizer_free ( FormulaTokenizer_t ft)

_tFrees_t _tthe_t _tgiven_t _tFormulaTokenizer_t_t _tstructure_t @_tp_t _tft_t.

@_tif_t _tconly_t @_tmemberof_t _tFormulaTokenizer_t_t @_tendif_t

_tFrees_t _tthe_t _tgiven_t _tFormulaTokenizer_t_t _tstructure_t @_tp_t _tft_t.

◆ FormulaTokenizer_nextToken()

Token_t * FormulaTokenizer_nextToken ( FormulaTokenizer_t ft)

_tReturns_t _tthe_t _tnext_t _ttoken_t _tin_t _tthe_t _tformula_t _tstring_t.

_tSBML_t _tLevel_t _t1_t _tuses_t _ta_t _tsimple_t _ttext_t-_tstring_t _trepresentation_t _tof_t _tmathematical_t _tformulas_t, _trather_t _tthan_t _tthe_t _tMathML_t-_tbased_t _trepresentation_t _tused_t _tin_t _tSBML_t _tLevels_t&_tnbsp_t;_t2_t _tand_t&_tnbsp_t;_t3_t. _tLibSBML_t _timplements_t _ta_t _tparser_t _tand_t _tconverter_t _tto_t _ttranslate_t _tformulas_t _tbetween_t _tthis_t _ttext_t-_tstring_t _trepresentation_t _tand_t _tMathML_t. _tThe_t _tfirst_t _tentry_t _tpoint_t _tis_t _tthe_t _tfunction_t _tFormulaTokenizer_createFromFormula_t(), _twhich_t _treturns_t _ta_t #_tFormulaTokenizer_t_t _tstructure_t. _tThe_t _tstructure_t _ttracks_t _tthe_t _tcurrent_t _tposition_t _tin_t _tthe_t _tstring_t _tto_t _tbe_t _ttokenized_t, _tand_t _tcan_t _tbe_t _thanded_t _tto_t _tother_t _tfunctions_t _tsuch_t _tas_t _tFormulaTokenizer_nextToken_t(). _tTokens_t _tare_t _treturned_t _tas_t #_tToken_t_t _tstructures_t.

_tAn_t _tinstance_t _tof_t _ta_t #_tFormulaTokenizer_t_t _tmaintains_t _tits_t _town_t _tinternal_t _tcopy_t _tof_t _tthe_t _tformula_t _tbeing_t _ttokenized_t _tand_t _tthe_t _tcurrent_t _tposition_t _twithin_t _tthe_t _tformula_t _tstring_t. _tCallers_t _tdo_t _tnot_t _tneed_t _tto_t _tmanipulate_t _tthe_t _tfields_t _tof_t _ta_t _tFormulaTokenizer_t_t _tstructure_t _tthemselves_t; _tinstances_t _tof_t _tFormulaTokenizer_t_t _tare_t _tonly_t _tmeant_t _tto_t _tbe_t _tpassed_t _taround_t _tbetween_t _tthe_t _tfunctions_t _tof_t _tthe_t _tformula_t _ttokenizer_t _tsystem_t, _tsuch_t _tas_t _tFormulaTokenizer_createFromFormula_t() _tand_t _tFormulaTokenizer_getName_t().

@_tparam_t _tft_t _tthe_t _tstructure_t _ttracking_t _tthe_t _tcurrent_t _ttokenization_t _tstate_t.

@_treturn_t _ta_t _tpointer_t _tto_t _ta_t _ttoken_t. _tIf_t _tno_t _tmore_t _ttokens_t _tare_t _tavailable_t, _tthe_t _ttoken_t _ttype_t _twill_t _tbe_t @_tc_t _tTT_END_t. _tPlease_t _tconsult_t _tthe_t _tdocumentation_t _tfor_t _tthe_t _tstructure_t _tToken_t_t _tfor_t _tmore_t _tinformation_t _tabout_t _tthe_t _tpossible_t _tdata_t _tvalues_t _tit_t _tcan_t _thold_t.

@_tsee_t _tFormulaTokenizer_free_t() @_tsee_t _tFormulaTokenizer_createFromFormula_t()

@_tcopydetails_t _tdoc_note_math_string_syntax_t

@_tif_t _tconly_t @_tmemberof_t _tFormulaTokenizer_t_t @_tendif_t

_tReturns_t _tthe_t _tnext_t _ttoken_t _tin_t _tthe_t _tformula_t _tstring_t.

@_tif_t _tconly_t @_tmemberof_t _tFormulaTokenizer_t_t @_tendif_t

◆ Token_create()

Token_t * Token_create ( void  )

@_tcond_t _tdoxygenLibsbmlInternal_t

_tCreates_t _ta_t _tnew_t _tToken_t _tand_t _treturns_t _ta_t _tpoint_t _tto_t _tit_t.

@_treturn_t _ta_t _tpointer_t _tto_t _ta_t _ttoken_t.

@_tif_t _tconly_t @_tmemberof_t _tToken_t_t @_tendif_t

◆ Token_free()

void Token_free ( Token_t t)

_tFrees_t _tthe_t _tgiven_t _tToken_t @_tp_t _tt_t.

@_tif_t _tconly_t @_tmemberof_t _tToken_t_t @_tendif_t

◆ Token_getInteger()

long Token_getInteger ( const Token_t t)

_tReturns_t _tthe_t _tvalue_t _tof_t _tthis_t _ttoken_t _tas_t _ta_t (_tlong_t) _tinteger_t.

_tThis_t _tfunction_t _tshould_t _tbe_t _tcalled_t _tonly_t _twhen_t _tthe_t _ttoken_t'_ts_t _ttype_t _tis_t @_tc_t _tTT_INTEGER_t. _tIf_t _tthe_t _ttype_t _tis_t @_tc_t _tTT_REAL_t _tor_t @_tc_t _tTT_REAL_E_t, _tthe_t _tfunction_t _twill_t _tcope_t _tby_t _ttruncating_t _tthe_t _tnumber_t'_ts_t _tfractional_t _tpart_t.

@_tparam_t _tt_t _tthe_t _ttoken_t _tto_t _tbe_t _tparsed_t _tinto_t _tan_t _tinteger_t.

@_treturn_t _tthe_t _tvalue_t _tof_t _tthe_t _ttoken_t _tafter_t _tit_t _tis_t _tinterpreted_t _tas_t _tan_t _tinteger_t.

@_tif_t _tconly_t @_tmemberof_t _tToken_t_t @_tendif_t

◆ Token_getReal()

double Token_getReal ( const Token_t t)

_tReturns_t _tthe_t _tvalue_t _tof_t _tthis_t _ttoken_t _tas_t _ta_t _treal_t (_tdouble_t).

_tThis_t _tfunction_t _tshould_t _tbe_t _tcalled_t _tonly_t _twhen_t _tthe_t _ttoken_t _tis_t _ta_t _tnumber_t (@_tc_t _tTT_REAL_t, @_tc_t _tTT_REAL_E_t _tor_t @_tc_t _tTT_INTEGER_t).

@_tparam_t _tt_t _tthe_t _ttoken_t _tto_t _tbe_t _tparsed_t _tinto_t _ta_t _treal_t _tnumber_t.

@_treturn_t _tthe_t _tvalue_t _tof_t _tthe_t _ttoken_t _tafter_t _tit_t _tis_t _tinterpreted_t _tas_t _ta_t _treal_t _tnumber_t.

@_tif_t _tconly_t @_tmemberof_t _tToken_t_t @_tendif_t

◆ Token_negateValue()

void Token_negateValue ( Token_t t)

_tNegates_t _tthe_t _tnumerical_t _tvalue_t _tof_t _tthe_t _tgiven_t _ttoken_t @_tp_t _tt_t.

_tThe_t _ttoken_t _tstored_t _tin_t @_tp_t _tt_t _tis_t _tmodified_t _tin_t _tplace_t. _tThis_t _toperation_t _tis_t _tonly_t _tvalid_t _tif_t _tthe_t _ttoken_t'_ts_t _ttype_t _tis_t @_tc_t _tTT_INTEGER_t, @_tc_t _tTT_REAL_t, _tor_t @_tc_t _tTT_REAL_E_t.

@_tparam_t _tt_t _tthe_t _ttoken_t _twhose_t _tvalue_t _tis_t _tto_t _tbe_t _tnegated_t.

@_tif_t _tconly_t @_tmemberof_t _tToken_t_t @_tendif_t