01: package sisc.compiler;
02:
03: import sisc.util.Util;
04: import sisc.data.Symbol;
05: import java.util.Map;
06: import java.util.HashMap;
07: import sisc.env.SymbolicEnvironment;
08:
09: public abstract class CompilerConstants extends Util {
10:
11: //Various integer constants
12: public static final int SYNTACTIC_TOKEN_COUNT = 9, PROGRAM = 0,
13: APPLICATION = 1, LAMBDA = 2, _IF = 3, BEGIN = 4, QUOTE = 5,
14: SET = 6, DEFINE = 7, MAKEANNOTATION = 8, LETREC = 9,
15: UNKNOWN = -1, REALTAIL = 1;
16:
17: public static final Map SYNTACTIC_TOKENS = new HashMap(
18: SYNTACTIC_TOKEN_COUNT);
19:
20: //Define the core syntactic constructs of the interpreter
21: static final Syntax SYN_QUOTE = syntax("quote", QUOTE),
22: SYN_PROGRAM = syntax("program", PROGRAM),
23: SYN_BEGIN = syntax("begin", BEGIN), SYN_IF = syntax("if",
24: _IF), SYN_DEFINE = syntax("define", DEFINE),
25: SYN_SET = syntax("set!", SET), SYN_LAMBDA = syntax(
26: "lambda", LAMBDA), SYN_LETREC = syntax("letrec",
27: LETREC),
28: //SYN_FIX = syntax("fix", FIX),
29: SYN_ANNOT = syntax("annotate", MAKEANNOTATION),
30: SYN_UNKNOWN = syntax("unknown", UNKNOWN);
31:
32: static Syntax syntax(String name, int id) {
33: Syntax s = new Syntax(id);
34: s.setName(Symbol.get(name));
35: SYNTACTIC_TOKENS.put(name, s);
36: SYNTACTIC_TOKENS.put(new Integer(id), s);
37: return s;
38: }
39:
40: static void extendenv(SymbolicEnvironment env, String s, Syntax syn) {
41: Symbol name = Symbol.get(s);
42: env.define(name, syn);
43: }
44:
45: static final Symbol VARNAME = Symbol.get("var-name"),
46: PROCNAME = Symbol.get("proc-name"), _LETREC = Symbol
47: .get("letrec");
48: }
49: /*
50: * The contents of this file are subject to the Mozilla Public
51: * License Version 1.1 (the "License"); you may not use this file
52: * except in compliance with the License. You may obtain a copy of
53: * the License at http://www.mozilla.org/MPL/
54: *
55: * Software distributed under the License is distributed on an "AS
56: * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
57: * implied. See the License for the specific language governing
58: * rights and limitations under the License.
59: *
60: * The Original Code is the Second Interpreter of Scheme Code (SISC).
61: *
62: * The Initial Developer of the Original Code is Scott G. Miller.
63: * Portions created by Scott G. Miller are Copyright (C) 2000-2007
64: * Scott G. Miller. All Rights Reserved.
65: *
66: * Contributor(s):
67: * Matthias Radestock
68: *
69: * Alternatively, the contents of this file may be used under the
70: * terms of the GNU General Public License Version 2 or later (the
71: * "GPL"), in which case the provisions of the GPL are applicable
72: * instead of those above. If you wish to allow use of your
73: * version of this file only under the terms of the GPL and not to
74: * allow others to use your version of this file under the MPL,
75: * indicate your decision by deleting the provisions above and
76: * replace them with the notice and other provisions required by
77: * the GPL. If you do not delete the provisions above, a recipient
78: * may use your version of this file under either the MPL or the
79: * GPL.
80: */
|