01: package kawa.standard;
02:
03: import kawa.lang.*;
04: import gnu.expr.*;
05: import gnu.lists.*;
06:
07: public class export extends Syntax {
08: public static final export module_export = new export();
09: static {
10: module_export.setName("module-export");
11: }
12:
13: public boolean scanForDefinitions(Pair st, java.util.Vector forms,
14: ScopeExp defs, Translator tr) {
15: Object list = st.cdr;
16: Object savePos = tr.pushPositionOf(st);
17: try {
18: if (defs instanceof ModuleExp)
19: ((ModuleExp) defs).setFlag(ModuleExp.EXPORT_SPECIFIED);
20: else {
21: tr.error('e', "\'" + getName()
22: + "\' not at module level");
23: return true;
24: }
25: SyntaxForm restSyntax = null;
26: while (list != LList.Empty) {
27: tr.pushPositionOf(list);
28: while (list instanceof SyntaxForm) {
29: restSyntax = (SyntaxForm) list;
30: list = restSyntax.form;
31: }
32: SyntaxForm nameSyntax = restSyntax;
33: if (list instanceof Pair) {
34: st = (Pair) list;
35: Object symbol = st.car;
36: while (symbol instanceof SyntaxForm) {
37: nameSyntax = (SyntaxForm) symbol;
38: symbol = nameSyntax.form;
39: }
40: if (symbol instanceof String) {
41: String str = (String) symbol;
42: if (str.startsWith("namespace:")) {
43: tr
44: .error('w',
45: "'namespace:' prefix ignored");
46: symbol = str.substring(10).intern();
47: }
48: }
49: if (symbol instanceof String
50: || symbol instanceof gnu.mapping.Symbol) {
51: if (nameSyntax != null) {
52: // Difficult to implement correctly. And probably
53: // not much point in doing so. FIXME.
54: }
55: Declaration decl = defs.getNoDefine(symbol);
56: if (decl.getFlag(Declaration.NOT_DEFINING))
57: Translator.setLine(decl, st);
58: decl.setFlag(Declaration.EXPORT_SPECIFIED);
59: list = st.cdr;
60: continue;
61: }
62: }
63: tr.error('e', "invalid syntax in '" + getName() + '\'');
64: return false;
65: }
66: return true;
67: } finally {
68: tr.popPositionOf(savePos);
69: }
70: }
71:
72: public Expression rewriteForm(Pair form, Translator tr) {
73: return null;
74: }
75: }
|