01: /*
02: * ParseResult.java
03: *
04: * Copyright (c) 1997 Cornell University.
05: * Copyright (c) 1997 Sun Microsystems, Inc.
06: *
07: * See the file "license.terms" for information on usage and
08: * redistribution of this file, and for a DISCLAIMER OF ALL
09: * WARRANTIES.
10: *
11: * RCS: @(#) $Id: ParseResult.java,v 1.3 2003/01/09 02:15:39 mdejong Exp $
12: *
13: */
14:
15: package tcl.lang;
16:
17: /**
18: * This class stores a single word that's generated inside the Tcl parser
19: * inside the Interp class.
20: */
21: class ParseResult {
22:
23: /**
24: * The value of a parse operation. For calls to Interp.intEval(),
25: * this variable is the same as interp.m_result. The ref count
26: * has been incremented, so the user will need to explicitly
27: * invoke release() to drop the ref.
28: */
29: TclObject value;
30:
31: /**
32: * Points to the next character to be parsed.
33: */
34: int nextIndex;
35:
36: /**
37: * Create an empty parsed word.
38: */
39: ParseResult() {
40: value = TclString.newInstance("");
41: value.preserve();
42: }
43:
44: ParseResult(String s, int ni) {
45: value = TclString.newInstance(s);
46: value.preserve();
47: nextIndex = ni;
48: }
49:
50: /**
51: * Assume that the caller has already preserve()'ed the TclObject.
52: */
53: ParseResult(TclObject o, int ni) {
54: value = o;
55: nextIndex = ni;
56: }
57:
58: ParseResult(StringBuffer sbuf, int ni) {
59: value = TclString.newInstance(sbuf.toString());
60: value.preserve();
61: nextIndex = ni;
62: }
63:
64: void release() {
65: value.release();
66: }
67: }
|