01: package sisc.compiler;
02:
03: import sisc.util.Util;
04: import sisc.data.*;
05: import sisc.ser.*;
06: import sisc.interpreter.ContinuationException;
07: import sisc.interpreter.Interpreter;
08: import sisc.io.ValueWriter;
09:
10: import java.io.IOException;
11:
12: public class Syntax extends Value implements NamedValue, Singleton {
13: int synid;
14:
15: public Syntax(int synid) {
16: this .synid = synid;
17: }
18:
19: public void eval(Interpreter r) throws ContinuationException {
20: error(r, Util.liMessage(SISCB, "invalidsyncontext", getName()
21: .toString()));
22: }
23:
24: public void display(ValueWriter w) throws IOException {
25: w.append("#%").append(getName());
26: }
27:
28: public Syntax() {
29: }
30:
31: public void deserialize(Deserializer s) throws IOException {
32: synid = s.readInt();
33: setName(Symbol.get(s.readUTF()));
34: }
35:
36: public void serialize(Serializer s) throws IOException {
37: s.writeInt(synid);
38: s.writeUTF(((Symbol) getName()).symval);
39: }
40:
41: public Value singletonValue() {
42: return (Value) CompilerConstants.SYNTACTIC_TOKENS
43: .get(((Symbol) getName()).symval);
44: }
45: }
46: /*
47: * The contents of this file are subject to the Mozilla Public
48: * License Version 1.1 (the "License"); you may not use this file
49: * except in compliance with the License. You may obtain a copy of
50: * the License at http://www.mozilla.org/MPL/
51: *
52: * Software distributed under the License is distributed on an "AS
53: * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
54: * implied. See the License for the specific language governing
55: * rights and limitations under the License.
56: *
57: * The Original Code is the Second Interpreter of Scheme Code (SISC).
58: *
59: * The Initial Developer of the Original Code is Scott G. Miller.
60: * Portions created by Scott G. Miller are Copyright (C) 2000-2007
61: * Scott G. Miller. All Rights Reserved.
62: *
63: * Contributor(s):
64: * Matthias Radestock
65: *
66: * Alternatively, the contents of this file may be used under the
67: * terms of the GNU General Public License Version 2 or later (the
68: * "GPL"), in which case the provisions of the GPL are applicable
69: * instead of those above. If you wish to allow use of your
70: * version of this file only under the terms of the GPL and not to
71: * allow others to use your version of this file under the MPL,
72: * indicate your decision by deleting the provisions above and
73: * replace them with the notice and other provisions required by
74: * the GPL. If you do not delete the provisions above, a recipient
75: * may use your version of this file under either the MPL or the
76: * GPL.
77: */
|