comparison core/src/luan/cmd_line.luan @ 326:db37d6aee4db

remove try-catch statement; add Luan.try() and Luan.pcall(); git-svn-id: https://luan-java.googlecode.com/svn/trunk@327 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Thu, 19 Mar 2015 00:01:57 +0000
parents cd2924a1052c
children dc21bd260690
comparison
equal deleted inserted replaced
325:78a6a71afbfd 326:db37d6aee4db
1 local Luan = require "luan:Luan" 1 local Luan = require "luan:Luan"
2 local ipairs = Luan.ipairs 2 local ipairs = Luan.ipairs
3 local load = Luan.load 3 local load = Luan.load
4 local load_file = Luan.load_file 4 local load_file = Luan.load_file
5 local try = Luan.try
5 require "luan:String" -- for String methods 6 require "luan:String" -- for String methods
6 local Table = require "luan:Table" 7 local Table = require "luan:Table"
7 local Io = require "luan:Io" 8 local Io = require "luan:Io"
8 local print = Io.print 9 local print = Io.print
9 local Debug = require "luan:Debug" 10 local Debug = require "luan:Debug"
70 local file = args[i] 71 local file = args[i]
71 Luan.arg = {} 72 Luan.arg = {}
72 for j,v in ipairs(args) do 73 for j,v in ipairs(args) do
73 Luan.arg[j-i] = v 74 Luan.arg[j-i] = v
74 end 75 end
75 try 76 try {
76 local main_file = load_file("file:"..file) 77 function()
77 main_file( Table.unpack(Luan.arg) ) 78 local main_file = load_file("file:"..file)
78 catch e do 79 main_file( Table.unpack(Luan.arg) )
79 Io.print_to(Io.stderr, e ) 80 end;
80 end 81 catch = function(e)
82 Io.print_to(Io.stderr, e )
83 end;
84 }
81 end 85 end
82 if interactive then 86 if interactive then
83 Debug.debug("> ") 87 Debug.debug("> ")
84 end 88 end