Talk:Catch

From Esolang
Jump to navigation Jump to search

Okay, let's try to get a list of exceptions here:

  • createVariableInst
  • inputInst
  • printInst
  • testGreaterInst
  • testEqualityInst
  • addInst
  • subtractInst
  • pushInst
  • popInst
  • gotoInst

Is this all we really need, or maybe too much, or what? I feel the divideInst makes this suddenly too high-level... I'll remove it. --Ihope127 18:27, 2 Sep 2005 (GMT)

I thought this was kind of a neat idea for an esolang, so I made a quick compiler in ruby that compiles the commands listed on the main language page into ruby code:

def evaluate(stmt)
stmt = stmt.gsub("\z","\\n")
if stmt.split(" ")[0] != "if"
puts "ERROR: Exception unhandled"
else
r = stmt.split(" ")[1..stmt.split(" ").count].join(" ")
if r[0..17] == "createVariableInst"
puts r.split("(")[1][0..-2] + "=" + "\"\"" 
elsif r[0..8] == "inputInst"
puts r.split("(")[1][0..-2] + "=" + "gets"
elsif r[0..8] == "printInst"
puts "print " + r.split("(")[1][0..-2]
elsif r[0..11] == "subtractInst"
puts r.split("(")[1][0..-2].split(",")[2].delete(" ") + "=" + r.split("(")[1][0..-2].split(",")[0].delete(" ") + ".to_f-" + r.split("(")[1][0..-2].split(",")[1].delete(" ") + ".to_f"
end
end
end

$program = File.open(gets.delete("\n"),"r").read.gsub("\\n","\z").split("\n")
c = 0
while c < $program.count
evaluate($program[c])
c+=1
end

OriginalOldMan (talk) 03:05, 19 September 2013 (UTC)