comparison src/luan/CmdLine.java @ 36:2a35154aec14

implement more basic lib functions git-svn-id: https://luan-java.googlecode.com/svn/trunk@37 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Tue, 18 Dec 2012 09:53:42 +0000
parents e51906de0f11
children 8a57ebfdfd78
comparison
equal deleted inserted replaced
35:e51906de0f11 36:2a35154aec14
1 package luan; 1 package luan;
2 2
3 import java.io.InputStreamReader;
4 import java.util.Arrays; 3 import java.util.Arrays;
5 import java.util.Scanner; 4 import java.util.Scanner;
6 import luan.lib.BasicLib; 5 import luan.lib.BasicLib;
7 import luan.interp.LuaCompiler; 6 import luan.interp.LuaCompiler;
8 7
37 } catch(LuaException e) { 36 } catch(LuaException e) {
38 System.err.println("command line error: "+e.getMessage()); 37 System.err.println("command line error: "+e.getMessage());
39 System.exit(-1); 38 System.exit(-1);
40 } 39 }
41 } else if( arg.equals("-") ) { 40 } else if( arg.equals("-") ) {
42 String cmd = BasicLib.readAll(new InputStreamReader(System.in));
43 try { 41 try {
44 LuaFunction fn = BasicLib.load(lua,cmd); 42 BasicLib.dofile(lua,null);
45 fn.call(lua);
46 } catch(LuaException e) { 43 } catch(LuaException e) {
47 System.err.println(e.getMessage()); 44 System.err.println(e.getMessage());
48 System.exit(-1); 45 System.exit(-1);
49 } 46 }
50 System.exit(0); 47 System.exit(0);
98 String input = new Scanner(System.in).nextLine(); 95 String input = new Scanner(System.in).nextLine();
99 try { 96 try {
100 LuaFunction fn = BasicLib.load(lua,input); 97 LuaFunction fn = BasicLib.load(lua,input);
101 Object[] rtn = fn.call(lua); 98 Object[] rtn = fn.call(lua);
102 if( rtn.length > 0 ) 99 if( rtn.length > 0 )
103 BasicLib.print(rtn); 100 BasicLib.print(lua,rtn);
104 } catch(LuaException e) { 101 } catch(LuaException e) {
105 System.out.println(e.getMessage()); 102 System.out.println(e.getMessage());
106 } 103 }
107 } 104 }
108 } 105 }