1 package gnu.q2.lang;
2 
3 import gnu.mapping.Symbol;
4 import gnu.expr.*;
5 import gnu.lists.*;
6 import kawa.lang.*;
7 
8 /** Syntax handler for ($define$ VAR [TYPE-SPECIFIER]). */
9 
10 public class DefineOp extends Syntax {
11     public static final DefineOp defineOp = new DefineOp();
12 
rewriteForm(Pair form, Translator tr)13     public Expression rewriteForm(Pair form, Translator tr) {
14         Pair pair1 = (Pair) form.getCdr();
15         Object pat = pair1.getCar();
16         Pair typeSpecPair = null;
17         if (pair1.getCdr() instanceof Pair)
18             typeSpecPair = (Pair) pair1.getCdr();
19         if (pat instanceof Symbol) {
20             Symbol sym = (Symbol) pat;
21             Declaration decl = tr.define(sym, tr.currentScope());
22             PrimProcedure makeLazy = new PrimProcedure("gnu.mapping.Promise",
23                                                        "makeBlank", 0);
24             BindDecls.setInitializer(decl, new ApplyExp(makeLazy),
25                                      tr.currentScope(), tr);
26             if (typeSpecPair != null)
27                 tr.exp2Type(typeSpecPair, decl, null);
28             return new ReferenceExp(decl);
29         }
30         return null;
31     }
scanForm(Pair st, ScopeExp defs, Translator tr)32     public void scanForm(Pair st, ScopeExp defs, Translator tr) {
33         super.scanForm(st, defs, tr);
34     }
35 }
36