/** * Formats the given ASTNode as an SBML L1 token and appends the result to * the given StringBuffer. */ void FormulaFormatter_format (StringBuffer_t *sb, const ASTNode_t *node) { if (sb == NULL) return; if (ASTNode_isOperator(node)) { FormulaFormatter_formatOperator(sb, node); } else if (ASTNode_isFunction(node)) { FormulaFormatter_formatFunction(sb, node); } else if (ASTNode_isInteger(node)) { StringBuffer_appendInt(sb, ASTNode_getInteger(node)); } else if (ASTNode_isRational(node)) { FormulaFormatter_formatRational(sb, node); } else if (ASTNode_isReal(node)) { FormulaFormatter_formatReal(sb, node); } else if ( !ASTNode_isUnknown(node) ) { StringBuffer_append(sb, ASTNode_getName(node)); } }
/** * Formats the given ASTNode as an SBML L3 token and appends the result to * the given StringBuffer. */ void L3FormulaFormatter_format (StringBuffer_t *sb, const ASTNode_t *node, const L3ParserSettings_t *settings) { if (sb == NULL) return; if (L3FormulaFormatter_isFunction(node, settings)) { L3FormulaFormatter_formatFunction(sb, node, settings); } else if (ASTNode_isOperator(node) || ASTNode_getType(node) == AST_FUNCTION_POWER) { L3FormulaFormatter_formatOperator(sb, node); } else if (ASTNode_isLogical(node) || ASTNode_isRelational(node)) { L3FormulaFormatter_formatLogicalRelational(sb, node); } else if (ASTNode_isRational(node)) { L3FormulaFormatter_formatRational(sb, node, settings); } else if (ASTNode_isInteger(node)) { L3FormulaFormatter_formatReal(sb, node, settings); } else if (ASTNode_isReal(node)) { L3FormulaFormatter_formatReal(sb, node, settings); } else if ( !ASTNode_isUnknown(node) ) { StringBuffer_append(sb, ASTNode_getName(node)); } }
/** * Formats the given ASTNode as a directed graph token and returns the result as * a string. */ char * FormulaGraphvizFormatter_format (const ASTNode_t *node) { StringBuffer_t *p = StringBuffer_create(128); char *s = NULL; if (ASTNode_isOperator(node)) { s = FormulaGraphvizFormatter_formatOperator(node); } else if (ASTNode_isFunction(node)) { s = FormulaGraphvizFormatter_formatFunction(node); } else if (ASTNode_isInteger(node)) { StringBuffer_appendInt(p, ASTNode_getInteger(node)); s = StringBuffer_toString(p); } else if (ASTNode_isRational(node)) { s = FormulaGraphvizFormatter_formatRational(node); } else if (ASTNode_isReal(node)) { s = FormulaGraphvizFormatter_formatReal(node); } else if ( !ASTNode_isUnknown(node) ) { if (ASTNode_getName(node) == NULL) { StringBuffer_append(p, "unknown"); } else { StringBuffer_append(p, ASTNode_getName(node)); } s = StringBuffer_toString(p); } free(p); return s; }