Skip to content

Commit

Permalink
Syntax coherence
Browse files Browse the repository at this point in the history
  • Loading branch information
spacebanana420 authored Jul 26, 2024
1 parent 0e1f7ac commit 7cee70c
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/runner/runner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,24 @@ private def loopScript(s: Seq[String], ifunc: Seq[Int], nfunc: Seq[String], i: I
loopScript(s, ifunc, nfunc, i+1)
case "arradd" =>
val (name, value) = parseArrayAddition(s(i))
value match {
value match
case intValue: Int =>
addToArray(name, intValue)
case strValue: String =>
try {
try
val intValue = strValue.toInt
addToArray(name, intValue)
} catch {
case e: NumberFormatException =>
addToArray(name, strValue)
}
}
catch case e: NumberFormatException => addToArray(name, strValue)
loopScript(s, ifunc, nfunc, i+1)
case "arrget" =>
val (name, variable, index) = parseArrayAccess(s(i))
getFromArray(name, variable, index) match {
getFromArray(name, variable, index) match
case intValue: Int =>
declareInt(variable, intValue)
case strValue: String =>
declareString(variable, strValue)
case other =>
closeTofu(s"Type error! Value '$other' from array '$name' at index $index is not an Int or String!")
}
loopScript(s, ifunc, nfunc, i+1)
case "exec" =>
exec(s(i))
Expand Down

0 comments on commit 7cee70c

Please sign in to comment.