finished interpreter
Some checks failed
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.10) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.6) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, pre) (push) Has been cancelled

This commit is contained in:
Daniel 2024-09-08 11:52:10 +02:00
parent c608abfb17
commit 44722bfc65
3 changed files with 9 additions and 6 deletions

View File

@ -23,8 +23,8 @@ function expr_to_postfix(expr::Expr)::PostfixType
for j in 2:length(expr.args) for j in 2:length(expr.args)
arg = expr.args[j] arg = expr.args[j]
if typeof(arg) === Expr if typeof(arg) === Expr
# exprElement = convert_to_ExpressionElement()
append!(postfix, expr_to_postfix(arg)) append!(postfix, expr_to_postfix(arg))
elseif typeof(arg) === Symbol # variables/parameters elseif typeof(arg) === Symbol # variables/parameters
exprElement = convert_to_ExpressionElement(convert_var_to_int(arg)) exprElement = convert_to_ExpressionElement(convert_var_to_int(arg))
@ -34,7 +34,8 @@ function expr_to_postfix(expr::Expr)::PostfixType
push!(postfix, exprElement) push!(postfix, exprElement)
end end
if length(postfix) >= 2 # only add operator if at least 2 values are added. For the case where another expression is added first, we check if we are at the first iteration or not ( j != 2)
if length(postfix) >= 2 && j != 2
exprElement = convert_to_ExpressionElement(operator) exprElement = convert_to_ExpressionElement(operator)
push!(postfix, exprElement) push!(postfix, exprElement)
end end

View File

@ -29,4 +29,6 @@ end
postfix = expr_to_postfix(expressions[1]) postfix = expr_to_postfix(expressions[1])
@test isequal(reference, postfix) @test isequal(reference, postfix)
# TODO: Do more complex expressions because these have led to errors in the past
end end

View File

@ -145,8 +145,8 @@ end
# var set 1 # var set 1
@test isapprox(result[1,1], 37.32, atol=0.01) # expr1 @test isapprox(result[1,1], 37.32, atol=0.01) # expr1
@test isequal(result[1,2], 64.74, atol=0.01) # expr2 @test isapprox(result[1,2], 64.74, atol=0.01) # expr2
# var set 2 # var set 2
@test isequal(result[2,1], 37.32, atol=0.01) # expr1 @test isapprox(result[2,1], 37.32, atol=0.01) # expr1
@test isequal(result[2,2], -83.65, atol=0.01) # expr2 @test isapprox(result[2,2], -83.65, atol=0.01) # expr2
end end