01: /*
02: * DefaultParseEnv.java
03: *
04: * Copyright (c) 2004,2006 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution of
07: * this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package org.pnuts.lang;
10:
11: import pnuts.lang.ParseEnvironment;
12: import pnuts.lang.ParseException;
13:
14: public class DefaultParseEnv implements ParseEnvironment {
15: static DefaultParseEnv instance = new DefaultParseEnv();
16:
17: private Object scriptSource;
18:
19: private DefaultParseEnv() {
20: }
21:
22: private DefaultParseEnv(Object scriptSource) {
23: this .scriptSource = scriptSource;
24: }
25:
26: public static DefaultParseEnv getInstance() {
27: return instance;
28: }
29:
30: public static DefaultParseEnv getInstance(Object scriptSource) {
31: return new DefaultParseEnv(scriptSource);
32: }
33:
34: public void handleParseException(ParseException e)
35: throws ParseException {
36: if (scriptSource != null) {
37: e.setScriptSource(scriptSource);
38: }
39: throw e;
40: }
41: }
|