Unverified Commit 63902370 authored by Miroslav Kratochvil's avatar Miroslav Kratochvil Committed by GitHub
Browse files

Merge pull request #59 from LCSB-BioCore/mk-relational-ops

support relational operators in math
parents 4010ae63 8ad91a27
...@@ -23,15 +23,17 @@ This attempts to parse out a decent Julia-esque ([`Math`](@ref) AST from a ...@@ -23,15 +23,17 @@ This attempts to parse out a decent Julia-esque ([`Math`](@ref) AST from a
pointer to `ASTNode_t`. pointer to `ASTNode_t`.
""" """
function parse_math(ast::VPtr)::Math function parse_math(ast::VPtr)::Math
if ast_is(ast, :ASTNode_isName) || ast_is(ast, :ASTNode_isConstant) if ast_is(ast, :ASTNode_isName)
return MathIdent(get_string(ast, :ASTNode_getName)) return MathIdent(get_string(ast, :ASTNode_getName))
elseif ast_is(ast, :ASTNode_isConstant)
return MathConst(get_string(ast, :ASTNode_getName))
elseif ast_is(ast, :ASTNode_isInteger) elseif ast_is(ast, :ASTNode_isInteger)
return MathVal(ccall(sbml(:ASTNode_getInteger), Cint, (VPtr,), ast)) return MathVal(ccall(sbml(:ASTNode_getInteger), Cint, (VPtr,), ast))
elseif ast_is(ast, :ASTNode_isReal) elseif ast_is(ast, :ASTNode_isReal)
return MathVal(ccall(sbml(:ASTNode_getReal), Cdouble, (VPtr,), ast)) return MathVal(ccall(sbml(:ASTNode_getReal), Cdouble, (VPtr,), ast))
elseif ast_is(ast, :ASTNode_isFunction) elseif ast_is(ast, :ASTNode_isFunction)
return MathApply(get_string(ast, :ASTNode_getName), parse_math_children(ast)) return MathApply(get_string(ast, :ASTNode_getName), parse_math_children(ast))
elseif ast_is(ast, :ASTNode_isOperator) elseif ast_is(ast, :ASTNode_isOperator) || ast_is(ast, :ASTNode_isRelational)
return MathApply( return MathApply(
string(Char(ccall(sbml(:ASTNode_getCharacter), Cchar, (VPtr,), ast))), string(Char(ccall(sbml(:ASTNode_getCharacter), Cchar, (VPtr,), ast))),
parse_math_children(ast), parse_math_children(ast),
......
...@@ -74,6 +74,14 @@ struct MathIdent <: Math ...@@ -74,6 +74,14 @@ struct MathIdent <: Math
id::String id::String
end end
"""
A constant identified by name (usually something like `pi`, `e` or `true`) in
mathematical expression
"""
struct MathConst <: Math
id::String
end
""" """
Function application ("call by name", no tricks allowed) in mathematical expression Function application ("call by name", no tricks allowed) in mathematical expression
""" """
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment