01: /*
02: * @(#)Implementation.java 1.2 04/12/06
03: *
04: * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package pnuts.lang;
10:
11: import java.io.FileNotFoundException;
12: import java.net.URL;
13:
14: /**
15: * Defines an abstract interface of script interpreter's implementation,
16: *
17: * @see pnuts.lang.Context#setImplementation(Implementation)
18: * @see pnuts.lang.Context#getImplementation()
19: */
20: public interface Implementation {
21:
22: /**
23: * Evaluate an expreesion
24: *
25: * @param expr
26: * the expression to be evaluated
27: * @param context
28: * the context in which the expression is evaluated
29: * @return the result of the evaluation
30: */
31: public Object eval(String expr, Context context);
32:
33: /**
34: * Load a script file from local file system
35: *
36: * @param filename
37: * the file name of the script
38: * @param context
39: * the context in which the expression is evaluated
40: * @return the result of the evaluation
41: */
42: public Object loadFile(String filename, Context context)
43: throws FileNotFoundException;
44:
45: /**
46: * Load a script file using classloader
47: *
48: * @param file
49: * the name of the script
50: * @param context
51: * the context in which the script is executed
52: * @return the result of the evaluation
53: */
54: public Object load(String file, Context context)
55: throws FileNotFoundException;
56:
57: /**
58: * Load a script file from a URL
59: *
60: * @param scriptURL
61: * the URL of the script
62: * @param context
63: * the context in which the script is executed
64: * @return the result of the evaluation
65: */
66: public Object load(URL scriptURL, Context context);
67:
68: /**
69: * Interpret an AST
70: *
71: * @param node
72: * the AST
73: * @param context
74: * the context in which the AST is interpreted
75: */
76: public Object accept(SimpleNode node, Context context);
77: }
|