libSBML C API  5.18.0
L3ParserSettings_t Class Reference

Detailed Description

Controls the behavior of the Level 3 formula parser.

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.

The function SBML_parseL3FormulaWithSettings(), along with its variants SBML_parseL3Formula() and SBML_parseL3FormulaWithModel(), are the interfaces to a parser for mathematical formulas written as text strings. The inverse function is SBML_formulaToL3String() and its variants such as SBML_formulaToL3StringWithSettings(). The parsers and the formula writers convert between a text-string representation of mathematical formulas and Abstract Syntax Trees (ASTs), represented in libSBML using ASTNode_t objects. Compared to the parser and writer implemented by the functions SBML_parseFormula() and SBML_formulaToString(), which were designed primarily for converting the mathematical formula strings in SBML Level 1, the SBML Level 3 or "L3" variants of the parser and writer use an extended formula syntax. They also have a number of configurable behaviors. This class (L3ParserSettings_t) is an object used to communicate the configuration settings with callers.

The following aspects of the parser are configurable using L3ParserSettings_t objects. (For the formula writer, only a subset of these settings is relevant; please see the documentation for SBML_formulaToL3StringWithSettings() for more information about which ones).

  • A Model_t object may optionally be provided to use identifiers (values of type SId) from the model in preference to pre-defined MathML symbols More precisely, the Model_t entities whose identifiers will shadow identical symbols in the mathematical formula are: Species_t, Compartment_t, Parameter_t, Reaction_t, and SpeciesReference_t. For instance, if the parser is given a Model_t containing a Species_t with the identifier "pi", and the formula to be parsed is "3*pi", the MathML produced by the parser will contain the construct <ci> pi </ci> instead of the construct <pi/>. Another example, if the passed-in Model_t contains a FunctionDefinition_t with the identifier "sin", that function will be used instead of the predefined MathML function <sin/>.
  • The function log with a single argument ("log(x)") can be parsed as log10(x), ln(x), or treated as an error, as desired.
  • Unary minus signs can be either collapsed or preserved; that is, the parser can either (1) remove sequential pairs of unary minuses (e.g., "- -3") from the input and incorporate single unary minuses into the number node, or (2) preserve all minuses in the AST node structure, turning them into ASTNode_t objects of type AST_MINUS.
  • The character sequence "number id" can be interpreted as a numerical value number followed by units of measurement indicated by id, or it can be treated as a syntax error. (In Level 3, MathML <cn> elements can have an attribute named units placed in the SBML namespace, which can be used to indicate the units to be associated with the number. The text-string infix formula parser allows units to be placed after raw numbers; they are interpreted as unit identifiers for units defined by the SBML specification or in the containing Model_t object.)
  • The symbol avogadro can be parsed either as a MathML csymbol or as a identifier. More specifically, "avogadro" can be treated as an ASTNode_t of type AST_NAME_AVOGADRO or of type AST_NAME.
  • Strings that match built-in functions and constants can either be parsed as a match regardless of capitalization, or may be required to be all-lower-case to be considered a match.
  • LibSBML plug-ins implementing support for SBML Level 3 packages may introduce extensions to the syntax understood by the parser. The precise nature of the extensions will be documented by the individual package plug-ins. An example of a possible extension is a notation for vectors and arrays, introduced by the SBML Level 3 Arrays package.

To obtain the default configuration values, callers can use the function SBML_getDefaultL3ParserSettings(). To change the configuration, callers can create an L3ParserSettings_t object, set the desired characteristics using the methods provided, and pass that object to SBML_parseL3FormulaWithSettings().

See also
SBML_parseL3Formula()
SBML_parseL3FormulaWithSettings()
SBML_parseL3FormulaWithModel()
SBML_parseFormula()
SBML_formulaToL3StringWithSettings()
SBML_formulaToL3String()
SBML_formulaToString()
SBML_getDefaultL3ParserSettings()
Examples:
translateL3Math.c.

Public Member Functions

L3ParserSettings_tL3ParserSettings_create ()
 Creates a new L3ParserSettings_t structure and returns a pointer to it. More...
 
void L3ParserSettings_free (L3ParserSettings_t *settings)
 Frees the given L3ParserSettings_t structure. More...
 
const Model_tL3ParserSettings_getModel (const L3ParserSettings_t *settings)
 Retrieves the model associated with this L3ParserSettings_t structure. More...
 
int L3ParserSettings_getParseAvogadroCsymbol (const L3ParserSettings_t *settings)
 Retrieves the avogadro csymbol option associated with this L3ParserSettings_t structure. More...
 
int L3ParserSettings_getParseCollapseMinus (const L3ParserSettings_t *settings)
 Retrieves the collapse minus option associated with this L3ParserSettings_t structure. More...
 
ParseLogType_t L3ParserSettings_getParseLog (const L3ParserSettings_t *settings)
 Retrieves the log parsing option associated with this L3ParserSettings_t structure. More...
 
int L3ParserSettings_getParseModuloL3v2 (const L3ParserSettings_t *settings)
 Indicates the current behavior set for handling the '' sumbol in mathematical formulas. More...
 
int L3ParserSettings_getParseUnits (const L3ParserSettings_t *settings)
 Retrieves the units option associated with this L3ParserSettings_t structure. More...
 
void L3ParserSettings_setModel (L3ParserSettings_t *settings, const Model_t *model)
 Sets the model associated with this L3ParserSettings_t structure to the provided pointer. More...
 
void L3ParserSettings_setParseAvogadroCsymbol (L3ParserSettings_t *settings, int flag)
 Sets the avogadro csymbol option associated with this L3ParserSettings_t structure. More...
 
void L3ParserSettings_setParseCollapseMinus (L3ParserSettings_t *settings, int flag)
 Sets the collapse minus option associated with this L3ParserSettings_t structure. More...
 
void L3ParserSettings_setParseLog (L3ParserSettings_t *settings, ParseLogType_t type)
 Sets the log parsing option associated with this L3ParserSettings_t structure. More...
 
void L3ParserSettings_setParseModuloL3v2 (const L3ParserSettings_t *settings, int modulol3v2)
 Sets the behavior for handling the '' sumbol in mathematical formulas. More...
 
void L3ParserSettings_setParseUnits (L3ParserSettings_t *settings, int flag)
 Sets the units option associated with this L3ParserSettings_t structure. More...
 
void L3ParserSettings_unsetModel (L3ParserSettings_t *settings)
 Unsets the model associated with this L3ParserSettings_t structure. More...
 
L3ParserSettings_tSBML_getDefaultL3ParserSettings ()
 Returns a copy of the default Level 3 ("L3") formula parser settings. More...
 

Member Function Documentation

L3ParserSettings_t * L3ParserSettings_create ( )

Creates a new L3ParserSettings_t structure and returns a pointer to it.

Note
This functions sets the Model_t* to NULL, and other settings to L3P_PARSE_LOG_AS_LOG10, L3P_EXPAND_UNARY_MINUS, L3P_PARSE_UNITS, and L3P_AVOGADRO_IS_CSYMBOL.
Returns
a pointer to the newly created L3ParserSettings_t structure.
Examples:
translateL3Math.c.
void L3ParserSettings_free ( L3ParserSettings_t settings)

Frees the given L3ParserSettings_t structure.

Parameters
settingsthe L3ParserSettings_t to free.
const Model_t * L3ParserSettings_getModel ( const L3ParserSettings_t settings)

Retrieves the model associated with this L3ParserSettings_t structure.

Parameters
settingsthe L3ParserSettings_t structure from which to get the Model_t.
Returns
the Model_t structure associated with this L3ParserSettings_t structure.
int L3ParserSettings_getParseAvogadroCsymbol ( const L3ParserSettings_t settings)

Retrieves the avogadro csymbol option associated with this L3ParserSettings_t structure.

Parameters
settingsthe L3ParserSettings_t structure from which to get the option.
Returns
an integer indicating whether avogadro should be considered as a csymbol (non-zero) or not (zero). Returns zero (0) if
Parameters
settingsis NULL.
int L3ParserSettings_getParseCollapseMinus ( const L3ParserSettings_t settings)

Retrieves the collapse minus option associated with this L3ParserSettings_t structure.

This option allows the user to specify how the infix expression '-4' is parsed in a MathML ASTNode_t.

Parameters
settingsthe L3ParserSettings_t structure from which to get the option.
Returns
an integer indicating whether unary minus should be collapsed (non-zero) or not (zero). Returns zero (0) if
Parameters
settingsis NULL.
ParseLogType_t L3ParserSettings_getParseLog ( const L3ParserSettings_t settings)

Retrieves the log parsing option associated with this L3ParserSettings_t structure.

This option allows the user to specify how the infix expression 'log(x)' is parsed in a MathML ASTNode_t. The options are:

  • L3P_PARSE_LOG_AS_LOG10 (0)
  • L3P_PARSE_LOG_AS_LN (1)
  • L3P_PARSE_LOG_AS_ERROR (2)
Parameters
settingsthe L3ParserSettings_t structure on which to set the Model_t.
Returns
ParseLogType_t log parsing option to associate with this L3ParserSettings_t structure. Returns L3P_PARSE_LOG_AS_LOG10 (0) if
Parameters
settingsis NULL.
int L3ParserSettings_getParseModuloL3v2 ( const L3ParserSettings_t settings)

Indicates the current behavior set for handling the '' sumbol in mathematical formulas.

This setting affects whether the '' symbol (modulo) is parsed as a piecewise equation that returns the modulo value of the entries on either side of the symbol, or whether it is parsed as the MathML 'rem' function, which was allowed in SBML Level 3 Version 2, but not in previous level/versions. The latter is more succinct, but might not be legal SBML for the desired target SBML document.
Returns
A boolean indicating the behavior currently set. The possible values are as follows:
See also
setParseModuloL3v2()
int L3ParserSettings_getParseUnits ( const L3ParserSettings_t settings)

Retrieves the units option associated with this L3ParserSettings_t structure.

Parameters
settingsthe L3ParserSettings_t structure from which to get the option.
Returns
an integer indicating whether numbers should be considered as a having units (non-zero) or not (zero). Returns zero (0) if
Parameters
settingsis NULL.
void L3ParserSettings_setModel ( L3ParserSettings_t settings,
const Model_t model 
)

Sets the model associated with this L3ParserSettings_t structure to the provided pointer.

Note
A copy of the Model_t is not made, so modifications to the Model_t itself may affect future parsing.
Parameters
settingsthe L3ParserSettings_t structure on which to set the Model_t.
modelthe Model_t structure to which infix strings are to be compared.
Examples:
translateL3Math.c.
void L3ParserSettings_setParseAvogadroCsymbol ( L3ParserSettings_t settings,
int  flag 
)

Sets the avogadro csymbol option associated with this L3ParserSettings_t structure.

Parameters
settingsthe L3ParserSettings_t structure on which to set the option.
flagan integer indicating whether avogadro should be considered as a csymbol (non-zero) or not (zero).
void L3ParserSettings_setParseCollapseMinus ( L3ParserSettings_t settings,
int  flag 
)

Sets the collapse minus option associated with this L3ParserSettings_t structure.

This option allows the user to specify how the infix expression '-4' is parsed in a MathML ASTNode_t.

Parameters
settingsthe L3ParserSettings_t structure on which to set the option.
flagan integer indicating whether unary minus should be collapsed (non-zero) or not (zero).
Examples:
translateL3Math.c.
void L3ParserSettings_setParseLog ( L3ParserSettings_t settings,
ParseLogType_t  type 
)

Sets the log parsing option associated with this L3ParserSettings_t structure.

This option allows the user to specify how the infix expression 'log(x)' is parsed in a MathML ASTNode_t. The options are:

  • L3P_PARSE_LOG_AS_LOG10 (0)
  • L3P_PARSE_LOG_AS_LN (1)
  • L3P_PARSE_LOG_AS_ERROR (2)
Parameters
settingsthe L3ParserSettings_t structure on which to set the option.
typeParseLogType_t log parsing option to associate with this L3ParserSettings_t structure.
Examples:
translateL3Math.c.
void L3ParserSettings_setParseModuloL3v2 ( const L3ParserSettings_t settings,
int  modulol3v2 
)

Sets the behavior for handling the '' sumbol in mathematical formulas.

This setting affects whether the '' symbol (modulo) is parsed as a piecewise equation that returns the modulo value of the entries on either side of the symbol, or whether it is parsed as the MathML 'rem' function, which was allowed in SBML Level 3 Version 2, but not in previous level/versions. The latter is more succinct, but might not be legal SBML for the desired target SBML document.

This method lets you tell the parser which behavior to use—either collapse minuses or always preserve them. The two possibilities are represented using the following constants:

Parameters
modulol3v2a boolean value (one of the constants L3P_MODULO_IS_PIECEWISE or L3P_MODULO_IS_REM) indicating how the '' symbol in the input should be handled.
See also
getParseModuloL3v2()
void L3ParserSettings_setParseUnits ( L3ParserSettings_t settings,
int  flag 
)

Sets the units option associated with this L3ParserSettings_t structure.

Parameters
settingsthe L3ParserSettings_t structure on which to set the option.
flagan integer indicating whether numbers should be considered as a having units (non-zero) or not (zero).
Examples:
translateL3Math.c.
void L3ParserSettings_unsetModel ( L3ParserSettings_t settings)

Unsets the model associated with this L3ParserSettings_t structure.

Parameters
settingsthe L3ParserSettings_t structure on which to unset the Model_t.
L3ParserSettings_t * SBML_getDefaultL3ParserSettings ( )

Returns a copy of the default Level 3 ("L3") formula parser settings.

The data structure storing the settings allows callers to change the following parsing behaviors:

The text-string form of mathematical formulas read by the function SBML_parseL3Formula() and written by the function SBML_formulaToL3String() uses an expanded version of the syntax read and written by SBML_parseFormula() and SBML_formulaToString(), respectively. The latter two libSBML functions were originally developed to support conversion between SBML Levels 1 and 2, and were focused on the syntax of mathematical formulas used in SBML Level 1. With time, and the use of MathML in SBML Levels 2 and 3, it became clear that supporting Level 2 and 3's expanded mathematical syntax would be useful for software developers. To maintain backwards compatibility for libSBML users, the original SBML_formulaToString() and SBML_parseFormula() have been left untouched, and instead, the new functionality is provided in the form of SBML_parseL3Formula() and SBML_formulaToL3String().

The following lists the main differences in the formula syntax supported by the Level 3 ("L3") versions of the formula parsers and formatters, compared to what is supported by the Level 1-oriented SBML_parseFormula() and SBML_formulaToString():

  • Units may be asociated with bare numbers, using the following syntax:
    number unit
    The number may be in any form (an integer, real, or rational number), and the unit must conform to the syntax of an SBML identifier (technically, the type defined as SId in the SBML specifications). The whitespace between number and unit is optional.
  • The Boolean function symbols && (and), || (or), ! (not), and != (not equals) may be used.
  • All inverse trigonometric functions may be defined in the infix either using arc as a prefix or simply a; in other words, both arccsc and acsc are interpreted as the operator arccosecant as defined in MathML 2.0. (Many functions in the simpler SBML Level 1 oriented parser implemented by SBML_parseFormula() are defined this way as well, but not all.)
  • The following expression is parsed as a rational number instead of as a numerical division:
       (integer/integer)
    Spaces are not allowed in this construct; in other words, "(3 / 4)" (with whitespace between the numbers and the operator) will be parsed into the MathML <divide> construct rather than a rational number. You can, however, assign units to a rational number as a whole; here is an example: "(3/4) ml". (In the case of division rather than a rational number, units are not interpreted in this way.)
  • Various parser and formatter behaviors may be altered through the use of a L3ParserSettings_t object in conjunction with the functions SBML_parseL3FormulaWithSettings() and SBML_formulaToL3StringWithSettings() The settings available include the following:
    • The function log with a single argument ("log(x)") can be parsed as log10(x), ln(x), or treated as an error, as desired.

    • Unary minus signs can be collapsed or preserved; that is, sequential pairs of unary minuses (e.g., "- -3") can be removed from the input entirely and single unary minuses can be incorporated into the number node, or all minuses can be preserved in the AST node structure.

    • Parsing of units embedded in the input string can be turned on and off.

    • The string avogadro can be parsed as a MathML csymbol or as an identifier.

    • The string % can be parsed either as a piecewise function or as the 'rem' function: a % b will either become

      piecewise(a - b*ceil(a/b), xor((a < 0), (b < 0)), a - b*floor(a/b))

      or

      rem(a, b).

      The latter is simpler, but the rem MathML is only allowed as of SBML Level 3 Version 2.

    • A Model_t object may optionally be provided to the parser using the variant function call SBML_parseL3FormulaWithModel() or stored in a L3ParserSettings_t object passed to the variant function SBML_parseL3FormulaWithSettings(). When a Model_t object is provided, identifiers (values of type SId ) from that model are used in preference to pre-defined MathML definitions for both symbols and functions. More precisely:

      • In the case of symbols: the Model_t entities whose identifiers will shadow identical symbols in the mathematical formula are: Species_t, Compartment_t, Parameter_t, Reaction_t, and SpeciesReference_t. For instance, if the parser is given a Model_t containing a Species_t with the identifier "pi", and the formula to be parsed is "3*pi", the MathML produced will contain the construct <ci> pi </ci> instead of the construct <pi/>.

      • In the case of user-defined functions: when a Model_t object is provided, SId values of user-defined functions present in the model will be used preferentially over pre-defined MathML functions. For example, if the passed-in Model_t contains a FunctionDefinition_t object with the identifier "sin", that function will be used instead of the predefined MathML function <sin/>.

    • An SBMLNamespaces_t object may optionally be provided to identify SBML Level 3 packages that extend the syntax understood by the formula parser. When the namespaces are provided, the parser will interpret possible additional syntax defined by the libSBML plug-ins implementing the SBML Level 3 packages; for example, it may understand vector/array extensions introduced by the SBML Level 3 Arrays package.

These configuration settings cannot be changed directly using the basic parser and formatter functions, but can be changed on a per-call basis by using the alternative functions SBML_parseL3FormulaWithSettings() and SBML_formulaToL3StringWithSettings().

Neither SBML nor the MathML standard define a "string-form" equivalent to MathML expressions. The approach taken by libSBML is to start with the formula syntax defined by SBML Level 1 (which in fact used a custom text-string representation of formulas, and not MathML), and expand it to include the functionality described above. This formula syntax is based mostly on C programming syntax, and may contain operators, function calls, symbols, and white space characters. The following table provides the precedence rules for the different entities that may appear in formula strings.

Token Operation Class Preced. Assoc.
namesymbol referenceoperand8n/a
(expression)expression groupingoperand8n/a
f(...)function callprefix8left
^powerbinary7left
-, !negation, Boolean 'not'unary6right
*, /, %multip., div., modulobinary5left
+, -addition and subtractionbinary4left
==, <, >, <=, >=, !=Boolean comparisonsbinary3left
&&, ||Boolean 'and' and 'or'binary2left
,argument delimiterbinary1left
Expression operators and their precedence in the "Level 3" text-string format for mathematical expressions.

In the table above, operand implies the construct is an operand, prefix implies the operation is applied to the following arguments, unary implies there is one argument, and binary implies there are two arguments. The values in the Precedence column show how the order of different types of operation are determined. For example, the expression a + b * c is evaluated as a + (b * c) because the * operator has higher precedence. The Associates column shows how the order of similar precedence operations is determined; for example, a && b || c is evaluated as (a && b) || c because the && and || operators are left-associative and have the same precedence.

The function call syntax consists of a function name, followed by optional white space, followed by an opening parenthesis token, followed by a sequence of zero or more arguments separated by commas (with each comma optionally preceded and/or followed by zero or more white space characters), followed by a closing parenthesis token. The function name must be chosen from one of the pre-defined functions in SBML or a user-defined function in the model. The following table lists the names of certain common mathematical functions; this table corresponds to Table 6 in the SBML Level 1 Version 2 specification with additions based on the functions added in SBML Level 2 and Level 3:

Name Argument(s) Formula or meaning Argument Constraints Result constraints
abs x Absolute value of x.
acos, arccos x Arccosine of x in radians. –1.0 ≤ x ≤ 1.0 0 ≤ acos(x) ≤ π
acosh, arccosh x Hyperbolic arccosine of x in radians.
acot, arccot x Arccotangent of x in radians.
acoth, arccoth x Hyperbolic arccotangent of x in radians.
acsc, arccsc x Arccosecant of x in radians.
acsch, arccsch x Hyperbolic arccosecant of x in radians.
asec, arcsec x Arcsecant of x in radians.
asech, arcsech x Hyperbolic arcsecant of x in radians.
asin, arcsin xArcsine of x in radians. –1.0 ≤ x ≤ 1.0 0 ≤ asin(x) ≤ π
atan, arctan x Arctangent of x in radians. 0 ≤ atan(x) ≤ π
atanh, arctanh x Hyperbolic arctangent of x in radians.
ceil, ceiling x Smallest number not less than x whose value is an exact integer.
cos x Cosine of x
cosh x Hyperbolic cosine of x.
cot x Cotangent of x.
coth x Hyperbolic cotangent of x.
csc x Cosecant of x.
csch x Hyperbolic cosecant of x.
delay x, y The value of x at y time units in the past.
factorial n The factorial of n. Factorials are defined by n! = n*(n–1)* ... * 1. n must be an integer.
exp x e x, where e is the base of the natural logarithm.
floor x The largest number not greater than x whose value is an exact integer.
ln x Natural logarithm of x. x > 0
log x By default, the base 10 logarithm of x, but can be set to be the natural logarithm of x, or to be an illegal construct. x > 0
log x, y The base x logarithm of y. y > 0
log10 x Base 10 logarithm of x. x > 0
piecewise x1, y1, [x2, y2,] [...] [z] A piecewise function: if (y1), x1. Otherwise, if (y2), x2, etc. Otherwise, z. y1, y2, y3 [etc] must be Boolean
pow, power x, y x y.
root b, x The root base b of x.
sec x Secant of x.
sech x Hyperbolic secant of x.
sqr x x2.
sqrt x x. x > 0 sqrt(x) ≥ 0
sin x Sine of x.
sinh x Hyperbolic sine of x.
tan x Tangent of x. x ≠ n*π/2, for odd integer n
tanh x Hyperbolic tangent of x.
and x, y, z... Boolean and(x, y, z...): returns true if all of its arguments are true. Note that and is an n-ary function, taking 0 or more arguments, and that and() returns true. All arguments must be Boolean
not x Boolean not(x) x must be Boolean
or x, y, z... Boolean or(x, y, z...): returns true if at least one of its arguments is true. Note that or is an n-ary function, taking 0 or more arguments, and that or() returns false. All arguments must be Boolean
xor x, y, z... Boolean xor(x, y, z...): returns true if an odd number of its arguments is true. Note that xor is an n-ary function, taking 0 or more arguments, and that xor() returns false. All arguments must be Boolean
eq x, y, z... Boolean eq(x, y, z...): returns true if all arguments are equal. Note that eq is an n-ary function, but must take 2 or more arguments.
geq x, y, z... Boolean geq(x, y, z...): returns true if each argument is greater than or equal to the argument following it. Note that geq is an n-ary function, but must take 2 or more arguments.
gt x, y, z... Boolean gt(x, y, z...): returns true if each argument is greater than the argument following it. Note that gt is an n-ary function, but must take 2 or more arguments.
leq x, y, z... Boolean leq(x, y, z...): returns true if each argument is less than or equal to the argument following it. Note that leq is an n-ary function, but must take 2 or more arguments.
lt x, y, z... Boolean lt(x, y, z...): returns true if each argument is less than the argument following it. Note that lt is an n-ary function, but must take 2 or more arguments.
neq x, y Boolean x != y: returns true unless x and y are equal.
plus x, y, z... x + y + z + ...: The sum of the arguments of the function. Note that plus is an n-ary function taking 0 or more arguments, and that plus() returns 0.
times x, y, z... x * y * z * ...: The product of the arguments of the function. Note that times is an n-ary function taking 0 or more arguments, and that times() returns 1.
minus x, y xy.
divide x, y x / y.
Mathematical functions defined in the "Level 3" text-string formula syntax.

Parsing of the various MathML functions and constants are all case-insensitive by default: function names such as cos, Cos and COS are all parsed as the MathML cosine operator, <cos>. However, when a Model_t object is used in conjunction with either SBML_parseL3FormulaWithModel() or SBML_parseL3FormulaWithSettings(), any identifiers found in that model will be parsed in a case-sensitive way. For example, if a model contains a Species_t having the identifier Pi, the parser will parse "Pi" in the input as "<ci> Pi </ci>" but will continue to parse the symbols "pi" and "PI" as "<pi>".

As mentioned above, the manner in which the "L3" versions of the formula parser and formatter interpret the function "log" can be changed. To do so, callers should use the function SBML_parseL3FormulaWithSettings() and pass it an appropriate L3ParserSettings_t object. By default, unlike the SBML Level 1 parser implemented by SBML_parseFormula(), the string "log" is interpreted as the base 10 logarithm, and not as the natural logarithm. However, you can change the interpretation to be base-10 log, natural log, or as an error; since the name "log" by itself is ambiguous, you require that the parser uses log10 or ln instead, which are more clear. Please refer to SBML_parseL3FormulaWithSettings().

In addition, the following symbols will be translated to their MathML equivalents, if no symbol with the same SId identifier string exists in the Model_t object provided:

Name Meaning MathML
true Boolean value true <true/>
false Boolean value false <false/>
pi Mathematical constant pi <pi/>
avogadro Value of Avogadro's constant stipulated by SBML <csymbol encoding="text" definitionURL="http://www.sbml.org/sbml/symbols/avogadro"> avogadro </csymbol/>
time Simulation time as defined in SBML <csymbol encoding="text" definitionURL="http://www.sbml.org/sbml/symbols/time"> time </csymbol/>
inf, infinity Mathematical constant "infinity" <infinity/>
nan, notanumber Mathematical concept "not a number" <notanumber/>
Mathematical symbols defined in the "Level 3" text-string formula syntax.

Again, as mentioned above, whether the string "avogadro" is parsed as an AST node of type AST_NAME_AVOGADRO or AST_NAME is configurable; use the version of the parser function called SBML_parseL3FormulaWithSettings(). This Avogadro-related functionality is provided because SBML Level 2 models may not use AST_NAME_AVOGADRO AST nodes.

For more details about the parser, please see the definition of L3ParserSettings_t and SBML_parseL3Formula().

See also
SBML_parseL3Formula()
SBML_parseL3FormulaWithSettings()
SBML_formulaToL3StringWithSettings()
L3ParserSettings_t