Commit e924dcbe by Miroslav Kratochvil

### support parsing of a small subset of MathML

`...let's see what can be done with it`
parent aefe4708
 """ parseMath(ast::VPtr)::Math ast_is(ast::VPtr, what::Symbol)::Bool Helper for quickly recognizing kinds of ASTs """ ast_is(ast::VPtr, what::Symbol)::Bool = ccall(sbml(what), Cint, (VPtr,), ast) != 0 """ parse_math(ast::VPtr)::Math This attempts to parse out a decent Julia-esque ([`Math`](@ref) AST from a pointer to `ASTNode_t`. """ function parseMath(ast::VPtr)::Math @info "got \$ast" MathIdent("placeholder") function parse_math(ast::VPtr)::Math if ast_is(ast, :ASTNode_isName) || ast_is(ast, :ASTNode_isConstant) return MathIdent(get_string(ast, :ASTNode_getName)) elseif ast_is(ast, :ASTNode_isConstantNumber) return MathVal(ccall_sbml(:ASTNode_getValue), Cdouble, (VPtr,), ast) elseif ast_is(ast, :ASTNode_isFunction) return MathApply( get_string(ast, :ASTNode_getName), [ parse_math(ccall(sbml(:ASTNode_getChild), VPtr, (VPtr, Cuint), ast, i - 1)) for i = 1:ccall(sbml(:ASTNode_getNumChildren), Cuint, (VPtr,), ast) ], ) elseif ast_is(ast, :ASTNode_isOperator) return MathApply( string(Char(ccall(sbml(:ASTNode_getCharacter), Cchar, (VPtr,), ast))), [ parse_math(ccall(sbml(:ASTNode_getChild), VPtr, (VPtr, Cuint), ast, i - 1)) for i = 1:ccall(sbml(:ASTNode_getNumChildren), Cuint, (VPtr,), ast) ], ) else @warn "unsupported math element at \$ast" return MathIdent("?unsupported?") end end
 ... ... @@ -236,7 +236,7 @@ function extractModel(mdl::VPtr)::Model end if ccall(sbml(:KineticLaw_isSetMath), Cint, (VPtr,), kl) != 0 math = parseMath(ccall(sbml(:KineticLaw_getMath), VPtr, (VPtr,), kl)) math = parse_math(ccall(sbml(:KineticLaw_getMath), VPtr, (VPtr,), kl)) end end ... ...
 ... ... @@ -79,7 +79,6 @@ Function application ("call by name", no tricks allowed) in mathematical express """ struct MathApply <: Math fn::String attributes::Dict{String,String} args::Vector{Math} end ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!