01: package kawa.lang;
02:
03: import gnu.expr.*;
04: import java.util.Vector;
05:
06: /** Bindings from a <code>syntax-case</code>/<code>syntax-rules</code> pattern. */
07:
08: public class PatternScope extends LetExp {
09: PatternScope previousSyntax;
10:
11: /** Currently visible macro pattern names.
12: * For the i'th pattern variable, pattern_names.elementAt(i)
13: * is the name of the variable, */
14: public Vector pattern_names;
15:
16: /** Nesting of currently visible macro pattern names.
17: * For the <code>i</code>'th pattern variable,
18: * <code>(int) patternNesting.charAt(i)/2</code> is the nesting (in terms of
19: * number of ellipsis that indicate the variable is repeated).
20: * The low-order bit indicates that if matched value is the <code>car</code>
21: * of the value saved in the <code>vars</code> array. */
22: public StringBuffer patternNesting;
23:
24: // FIXME - move to Translator?
25: public Declaration matchArray;
26:
27: public PatternScope() {
28: super (null);
29: }
30:
31: public static PatternScope push(Translator tr) {
32: PatternScope newScope = new PatternScope();
33: PatternScope oldScope = tr.patternScope;
34: newScope.previousSyntax = oldScope;
35: tr.patternScope = newScope;
36: if (oldScope == null) {
37: newScope.pattern_names = new Vector();
38: newScope.patternNesting = new StringBuffer();
39: } else {
40: newScope.pattern_names = (Vector) oldScope.pattern_names
41: .clone();
42: newScope.patternNesting = new StringBuffer(
43: oldScope.patternNesting.toString());
44: }
45: newScope.outer = tr.currentScope();
46: return newScope;
47: }
48:
49: public static void pop(Translator tr) {
50: tr.patternScope = tr.patternScope.previousSyntax;
51: }
52:
53: /*
54: public void compile (Compilation comp, Target target)
55: {
56: throw new RuntimeException ("internal error - PatternScope.compile called");
57: }
58: */
59:
60: }
|