aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2011-04-25 08:43:20 +0000
committerdos-reis <gdr@axiomatics.org>2011-04-25 08:43:20 +0000
commite2e6e0d0acb2655634e475f214958e612dddb7c1 (patch)
tree210a86c0483a0bf5622d80a0f1884ea85125a1e3 /src
parent9852c96d425eaad7f299ed36558930514a0487d3 (diff)
downloadopen-axiom-e2e6e0d0acb2655634e475f214958e612dddb7c1.tar.gz
* boot/translator.boot (inAllContexts): New.
(translateToplevel): Use it. * boot/parser.boot (bpImport): Accept namespace import.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/boot/ast.boot2
-rw-r--r--src/boot/parser.boot2
-rw-r--r--src/boot/strap/parser.clisp19
-rw-r--r--src/boot/strap/translator.clisp26
-rw-r--r--src/boot/translator.boot9
6 files changed, 47 insertions, 17 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e60e529f..89b5b8fc 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2011-04-25 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * boot/translator.boot (inAllContexts): New.
+ (translateToplevel): Use it.
+ * boot/parser.boot (bpImport): Accept namespace import.
+
2011-04-24 Gabriel Dos Reis <gdr@cs.tamu.edu>
* boot/initial-env.lisp (MEMQ): Remove.
diff --git a/src/boot/ast.boot b/src/boot/ast.boot
index 447f9253..d76fcb72 100644
--- a/src/boot/ast.boot
+++ b/src/boot/ast.boot
@@ -60,7 +60,7 @@ structure %Ast ==
%Lisp(%String) -- )lisp command
%Module(%Symbol,%List,%List) -- module declaration
%Namespace(%Symbol) -- namespace AxiomCore
- %Import(%Symbol) -- import module
+ %Import(%Ast) -- import module; import namespace foo
%ImportSignature(%Symbol,%Signature) -- import function declaration
%TypeAlias(%Head, %List) -- type alias definition
%Signature(%Symbol,%Mapping) -- op: S -> T
diff --git a/src/boot/parser.boot b/src/boot/parser.boot
index 6f625748..a6420449 100644
--- a/src/boot/parser.boot
+++ b/src/boot/parser.boot
@@ -445,8 +445,10 @@ bpModule() ==
++ Import:
++ IMPORT Signature FOR Name
++ IMPORT Name
+++ IMPORT Namespace
bpImport() ==
bpEqKey "IMPORT" =>
+ bpNamespace() => bpPush %Import bpPop1()
a := bpState()
bpName() or bpTrap()
bpEqPeek "COLON" =>
diff --git a/src/boot/strap/parser.clisp b/src/boot/strap/parser.clisp
index 7cf584dd..00b784f7 100644
--- a/src/boot/strap/parser.clisp
+++ b/src/boot/strap/parser.clisp
@@ -484,15 +484,18 @@
(PROG (|a|)
(RETURN
(COND
- ((|bpEqKey| 'IMPORT) (SETQ |a| (|bpState|))
- (OR (|bpName|) (|bpTrap|))
+ ((|bpEqKey| 'IMPORT)
(COND
- ((|bpEqPeek| 'COLON) (|bpRestore| |a|)
- (AND (OR (|bpSignature|) (|bpTrap|))
- (OR (|bpEqKey| 'FOR) (|bpTrap|))
- (OR (|bpName|) (|bpTrap|))
- (|bpPush| (|%ImportSignature| (|bpPop1|) (|bpPop1|)))))
- (T (|bpPush| (|%Import| (|bpPop1|))))))
+ ((|bpNamespace|) (|bpPush| (|%Import| (|bpPop1|))))
+ (T (SETQ |a| (|bpState|)) (OR (|bpName|) (|bpTrap|))
+ (COND
+ ((|bpEqPeek| 'COLON) (|bpRestore| |a|)
+ (AND (OR (|bpSignature|) (|bpTrap|))
+ (OR (|bpEqKey| 'FOR) (|bpTrap|))
+ (OR (|bpName|) (|bpTrap|))
+ (|bpPush|
+ (|%ImportSignature| (|bpPop1|) (|bpPop1|)))))
+ (T (|bpPush| (|%Import| (|bpPop1|))))))))
(T NIL)))))
(DEFUN |bpNamespace| ()
diff --git a/src/boot/strap/translator.clisp b/src/boot/strap/translator.clisp
index 6e73c749..3992e54d 100644
--- a/src/boot/strap/translator.clisp
+++ b/src/boot/strap/translator.clisp
@@ -593,8 +593,12 @@
((NULL |ns|) NIL)
(T (LIST (LIST 'EXPORT (LIST 'QUOTE |ns|))))))
+(DEFUN |inAllContexts| (|x|)
+ (LIST 'EVAL-WHEN (LIST :COMPILE-TOPLEVEL :LOAD-TOPLEVEL :EXECUTE)
+ |x|))
+
(DEFUN |translateToplevel| (|b| |export?|)
- (PROG (|lhs| |t| |ISTMP#2| |n| |ISTMP#1| |sig| |xs|)
+ (PROG (|lhs| |t| |ISTMP#2| |sig| |n| |ISTMP#1| |xs|)
(DECLARE (SPECIAL |$activeNamespace| |$InteractiveMode|
|$constantIdentifiers| |$foreignsDefsForCLisp|
|$currentModuleName|))
@@ -645,12 +649,20 @@
(CDR |bfVar#12|)))))))))
(|%Import|
(LET ((|m| (CADR |b|)))
- (PROGN
- (COND
- ((NOT (STRING= (|getOptionValue| '|import|)
- "skip"))
- (|bootImport| (SYMBOL-NAME |m|))))
- (LIST (LIST 'IMPORT-MODULE (SYMBOL-NAME |m|))))))
+ (COND
+ ((AND (CONSP |m|) (EQ (CAR |m|) '|%Namespace|)
+ (PROGN
+ (SETQ |ISTMP#1| (CDR |m|))
+ (AND (CONSP |ISTMP#1|)
+ (NULL (CDR |ISTMP#1|))
+ (PROGN (SETQ |n| (CAR |ISTMP#1|)) T))))
+ (LIST (|inAllContexts|
+ (LIST 'USE-PACKAGE (SYMBOL-NAME |n|)))))
+ (T (COND
+ ((NOT (STRING= (|getOptionValue| '|import|)
+ "skip"))
+ (|bootImport| (SYMBOL-NAME |m|))))
+ (LIST (LIST 'IMPORT-MODULE (SYMBOL-NAME |m|)))))))
(|%ImportSignature|
(LET ((|x| (CADR |b|)) (|sig| (CADDR |b|)))
(|genImportDeclaration| |x| |sig|)))
diff --git a/src/boot/translator.boot b/src/boot/translator.boot
index af1c967b..08b0bfde 100644
--- a/src/boot/translator.boot
+++ b/src/boot/translator.boot
@@ -407,6 +407,11 @@ exportNames ns ==
ns = nil => nil
[["EXPORT",["QUOTE",ns]]]
+inAllContexts x ==
+ ["EVAL-WHEN",[KEYWORD::COMPILE_-TOPLEVEL,
+ KEYWORD::LOAD_-TOPLEVEL,
+ KEYWORD::EXECUTE], x]
+
translateToplevel(b,export?) ==
atom b => [b] -- generally happens in interactive mode.
b is ["TUPLE",:xs] => coreError '"invalid AST"
@@ -420,7 +425,9 @@ translateToplevel(b,export?) ==
[["PROVIDE", symbolName m], :exportNames ns,
:[first translateToplevel(d,true) for d in ds]]
- %Import(m) =>
+ %Import(m) =>
+ m is ['%Namespace,n] =>
+ [inAllContexts ["USE-PACKAGE",symbolName n]]
if getOptionValue "import" ~= '"skip" then
bootImport symbolName m
[["IMPORT-MODULE", symbolName m]]