1 | /* |
---|
2 | * MainAlternative.java |
---|
3 | * |
---|
4 | * Copyright (C) 2008 Ville Voutilainen |
---|
5 | * $Id: MainAlternative.java 12307 2009-12-25 21:54:31Z ehuelsmann $ |
---|
6 | * |
---|
7 | * This program is free software; you can redistribute it and/or |
---|
8 | * modify it under the terms of the GNU General Public License |
---|
9 | * as published by the Free Software Foundation; either version 2 |
---|
10 | * of the License, or (at your option) any later version. |
---|
11 | * |
---|
12 | * This program is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | * GNU General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU General Public License |
---|
18 | * along with this program; if not, write to the Free Software |
---|
19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
20 | */ |
---|
21 | |
---|
22 | import org.armedbear.lisp.*; |
---|
23 | |
---|
24 | public class MainAlternative |
---|
25 | { |
---|
26 | /** |
---|
27 | * This example creates an Interpreter instance, loads our |
---|
28 | * lisp code from a file and then looks up a function defined |
---|
29 | * in the loaded lisp file and executes the function. |
---|
30 | */ |
---|
31 | public static void main(String[] argv) |
---|
32 | { |
---|
33 | try |
---|
34 | { |
---|
35 | Interpreter interpreter = Interpreter.createInstance(); |
---|
36 | interpreter.eval("(load \"lispfunction.lisp\")"); |
---|
37 | // the function is not in a separate package, thus the |
---|
38 | // correct package is CL-USER. Symbol names are |
---|
39 | // upper case. Package needs the prefix, because java |
---|
40 | // also has a class named Package. |
---|
41 | org.armedbear.lisp.Package defaultPackage = |
---|
42 | Packages.findPackage("CL-USER"); |
---|
43 | Symbol sym = |
---|
44 | defaultPackage.findAccessibleSymbol("LISPFUNCTION"); |
---|
45 | Function function = (Function) sym.getSymbolFunction(); |
---|
46 | function.execute(); |
---|
47 | } |
---|
48 | catch (Throwable t) |
---|
49 | { |
---|
50 | System.out.println("exception!"); |
---|
51 | t.printStackTrace(); |
---|
52 | } |
---|
53 | } |
---|
54 | } |
---|