Commit 8ad91a27 authored by Miroslav Kratochvil's avatar Miroslav Kratochvil
Browse files

separate out mathematical constants

...to allow distinguishing stuff like Euler's number from variable name `e`
parent a12020cd
...@@ -23,8 +23,10 @@ This attempts to parse out a decent Julia-esque ([`Math`](@ref) AST from a ...@@ -23,8 +23,10 @@ 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)
......
...@@ -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