diff options
author | dos-reis <gdr@axiomatics.org> | 2011-10-01 14:02:30 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2011-10-01 14:02:30 +0000 |
commit | 73374b314b15f2a313718d0e347a1050d1d1a405 (patch) | |
tree | e893bb8f428e229c04445ffc11fdc0a2f3f6a1f5 /src/boot/strap | |
parent | 4cb6f558586ccd4893c2acd088bba66654f6bf19 (diff) | |
download | open-axiom-73374b314b15f2a313718d0e347a1050d1d1a405.tar.gz |
* boot/utility.boot: Define BOOTTRAN namespace.
(setUnion): New.
(setDifference): New.
* boot/translator.boot (packageBody): New.
(translateToplevel): Use it. Translate namespace definition.
* boot/tokens.boot: Replace bitmask with bitref.
Do not translate setDifference and setUnion.
* boot/parser.boot (bpDef): Now include namespace definition.
(bpComma): Remove namespace rule as subsumed by Where rule.
* boot/Makefile.in: Remove dependencies on initial-env.lisp.
(AXIOM_LOCAL_LISP_sources): Remove as unused,
(boot_sources): Remove as redundant with boot_SOURCES.
* boot/initial-env.lisp: Remove.
Diffstat (limited to 'src/boot/strap')
-rw-r--r-- | src/boot/strap/parser.clisp | 6 | ||||
-rw-r--r-- | src/boot/strap/tokens.clisp | 7 | ||||
-rw-r--r-- | src/boot/strap/translator.clisp | 89 | ||||
-rw-r--r-- | src/boot/strap/utility.clisp | 66 |
4 files changed, 138 insertions, 30 deletions
diff --git a/src/boot/strap/parser.clisp b/src/boot/strap/parser.clisp index 898c6192..7b470d05 100644 --- a/src/boot/strap/parser.clisp +++ b/src/boot/strap/parser.clisp @@ -884,7 +884,8 @@ T)) (DEFUN |bpDef| () - (AND (|bpName|) (|bpStoreName|) (|bpDefTail| #'|%Definition|))) + (OR (AND (|bpName|) (|bpStoreName|) (|bpDefTail| #'|%Definition|)) + (AND (|bpNamespace|) (|bpSimpleDefinitionTail|)))) (DEFUN |bpDDef| () (AND (|bpName|) (|bpDefTail| #'|%Definition|))) @@ -930,8 +931,7 @@ (DEFUN |bpPDefinitionItems| () (|bpParenthesized| #'|bpSemiColonDefinition|)) -(DEFUN |bpComma| () - (OR (|bpModule|) (|bpImport|) (|bpNamespace|) (|bpTuple| #'|bpWhere|))) +(DEFUN |bpComma| () (OR (|bpModule|) (|bpImport|) (|bpTuple| #'|bpWhere|))) (DEFUN |bpTuple| (|p|) (|bpListofFun| |p| #'|bpCommaBackSet| #'|bfTuple|)) diff --git a/src/boot/strap/tokens.clisp b/src/boot/strap/tokens.clisp index 12192b72..ba4e28a2 100644 --- a/src/boot/strap/tokens.clisp +++ b/src/boot/strap/tokens.clisp @@ -160,7 +160,7 @@ (LIST '|strconc| "") (LIST 'CONCAT "") (LIST 'MAX (- 999999)) (LIST 'MIN 999999) (LIST '* 1) (LIST '|times| 1) (LIST 'CONS NIL) (LIST '|append| NIL) (LIST '|append!| NIL) (LIST 'UNION NIL) - (LIST 'UNIONQ NIL) (LIST '|union| NIL) (LIST '|and| T) + (LIST '|setUnion| NIL) (LIST '|union| NIL) (LIST '|and| T) (LIST '|or| NIL) (LIST 'AND T) (LIST 'OR NIL))) (|i| NIL)) (LOOP @@ -176,7 +176,7 @@ (LIST '|alphanumeric?| 'ALPHANUMERICP) (LIST '|and| 'AND) (LIST '|apply| 'APPLY) (LIST '|array?| 'ARRAYP) (LIST '|arrayRef| 'AREF) (LIST '|atom| 'ATOM) - (LIST '|bitmask| 'SBIT) (LIST '|canonicalFilename| 'PROBE-FILE) + (LIST '|bitref| 'SBIT) (LIST '|canonicalFilename| 'PROBE-FILE) (LIST '|charByName| 'NAME-CHAR) (LIST '|charDowncase| 'CHAR-DOWNCASE) (LIST '|charEq?| 'CHAR=) (LIST '|charUpcase| 'CHAR-UPCASE) (LIST '|charString| 'STRING) @@ -201,8 +201,7 @@ (LIST '|readOnly?| 'CONSTANTP) (LIST '|removeDuplicates| 'REMDUP) (LIST '|rest| 'CDR) (LIST '|sameObject?| 'EQ) (LIST '|scalarEq?| 'EQL) (LIST '|scalarEqual?| 'EQL) - (LIST '|second| 'CADR) (LIST '|setIntersection| 'INTERSECTION) - (LIST '|setPart| 'SETELT) (LIST '|setUnion| 'UNION) + (LIST '|second| 'CADR) (LIST '|setPart| 'SETELT) (LIST '|strconc| 'CONCAT) (LIST '|stringChar| 'SCHAR) (LIST '|stringDowncase| 'STRING-DOWNCASE) (LIST '|string?| 'STRINGP) (LIST '|stringEq?| 'STRING=) diff --git a/src/boot/strap/translator.clisp b/src/boot/strap/translator.clisp index 4ab03112..95ad05d9 100644 --- a/src/boot/strap/translator.clisp +++ b/src/boot/strap/translator.clisp @@ -565,8 +565,49 @@ (COND ((NULL |ns|) NIL) (T (LIST (|inAllContexts| (LIST 'EXPORT (|quote| |ns|))))))) +(DEFUN |packageBody| (|x| |p|) + (PROG (|user| |ns| |ISTMP#3| |ISTMP#2| |ISTMP#1|) + (RETURN + (COND + ((AND (CONSP |x|) (EQ (CAR |x|) '|%Import|) + (PROGN + (SETQ |ISTMP#1| (CDR |x|)) + (AND (CONSP |ISTMP#1|) (NULL (CDR |ISTMP#1|)) + (PROGN + (SETQ |ISTMP#2| (CAR |ISTMP#1|)) + (AND (CONSP |ISTMP#2|) (EQ (CAR |ISTMP#2|) '|%Namespace|) + (PROGN + (SETQ |ISTMP#3| (CDR |ISTMP#2|)) + (AND (CONSP |ISTMP#3|) (NULL (CDR |ISTMP#3|)) + (PROGN (SETQ |ns| (CAR |ISTMP#3|)) T)))))))) + (SETQ |user| (COND ((NULL |p|) NIL) (T (LIST (SYMBOL-NAME |p|))))) + (COND + ((EQ |ns| '|System|) + (LIST 'COND + (LIST (LIST '|%hasFeature| :COMMON-LISP) + (CONS 'USE-PACKAGE (CONS "COMMON-LISP" |user|))) + (LIST 'T (CONS 'USE-PACKAGE (CONS "LISP" |user|))))) + (T (CONS 'USE-PACKAGE (CONS (SYMBOL-NAME |ns|) |user|))))) + ((AND (CONSP |x|) (EQ (CAR |x|) 'PROGN)) + (CONS (CAR |x|) + (LET ((|bfVar#2| NIL) + (|bfVar#3| NIL) + (|bfVar#1| (CDR |x|)) + (|y| NIL)) + (LOOP + (COND + ((OR (NOT (CONSP |bfVar#1|)) + (PROGN (SETQ |y| (CAR |bfVar#1|)) NIL)) + (RETURN |bfVar#2|)) + ((NULL |bfVar#2|) + (SETQ |bfVar#2| #1=(CONS (|packageBody| |y| |p|) NIL)) + (SETQ |bfVar#3| |bfVar#2|)) + (T (RPLACD |bfVar#3| #1#) (SETQ |bfVar#3| (CDR |bfVar#3|)))) + (SETQ |bfVar#1| (CDR |bfVar#1|)))))) + (T |x|))))) + (DEFUN |translateToplevel| (|b| |export?|) - (PROG (|lhs| |t| |ISTMP#2| |sig| |n| |ISTMP#1| |xs|) + (PROG (|lhs| |t| |ISTMP#2| |sig| |def| |ns| |n| |ISTMP#1| |xs|) (DECLARE (SPECIAL |$currentModuleName| |$foreignsDefsForCLisp| |$constantIdentifiers| |$InteractiveMode| |$activeNamespace|)) @@ -621,8 +662,7 @@ (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|))))) + (LIST (|inAllContexts| (|packageBody| |m| NIL)))) (T (COND ((NOT (STRING= (|getOptionValue| '|import|) "skip")) @@ -636,22 +676,33 @@ (LIST (|genTypeAlias| |lhs| |rhs|)))) (|%ConstantDefinition| (LET ((|lhs| (CADR |b|)) (|rhs| (CADDR |b|))) - (PROGN - (SETQ |sig| NIL) - (COND - ((AND (CONSP |lhs|) (EQ (CAR |lhs|) '|%Signature|) - (PROGN - (SETQ |ISTMP#1| (CDR |lhs|)) - (AND (CONSP |ISTMP#1|) - (PROGN - (SETQ |n| (CAR |ISTMP#1|)) - (SETQ |ISTMP#2| (CDR |ISTMP#1|)) - (AND (CONSP |ISTMP#2|) (NULL (CDR |ISTMP#2|)) - (PROGN (SETQ |t| (CAR |ISTMP#2|)) T)))))) - (SETQ |sig| (|genDeclaration| |n| |t|)) (SETQ |lhs| |n|))) - (SETQ |$constantIdentifiers| - (CONS |lhs| |$constantIdentifiers|)) - (LIST (LIST 'DEFCONSTANT |lhs| |rhs|))))) + (COND + ((AND (CONSP |lhs|) (EQ (CAR |lhs|) '|%Namespace|) + (PROGN + (SETQ |ISTMP#1| (CDR |lhs|)) + (AND (CONSP |ISTMP#1|) (NULL (CDR |ISTMP#1|)) + (PROGN (SETQ |ns| (CAR |ISTMP#1|)) T)))) + (SETQ |def| + (LIST 'UNLESS + (LIST 'FIND-PACKAGE (SYMBOL-NAME |ns|)) + (LIST 'MAKE-PACKAGE (SYMBOL-NAME |ns|)))) + (LIST (|inAllContexts| |def|) + (|inAllContexts| (|packageBody| |rhs| |ns|)))) + (T (SETQ |sig| NIL) + (COND + ((AND (CONSP |lhs|) (EQ (CAR |lhs|) '|%Signature|) + (PROGN + (SETQ |ISTMP#1| (CDR |lhs|)) + (AND (CONSP |ISTMP#1|) + (PROGN + (SETQ |n| (CAR |ISTMP#1|)) + (SETQ |ISTMP#2| (CDR |ISTMP#1|)) + (AND (CONSP |ISTMP#2|) (NULL (CDR |ISTMP#2|)) + (PROGN (SETQ |t| (CAR |ISTMP#2|)) T)))))) + (SETQ |sig| (|genDeclaration| |n| |t|)) (SETQ |lhs| |n|))) + (SETQ |$constantIdentifiers| + (CONS |lhs| |$constantIdentifiers|)) + (LIST (LIST 'DEFCONSTANT |lhs| |rhs|)))))) (|%Assignment| (LET ((|lhs| (CADR |b|)) (|rhs| (CADDR |b|))) (PROGN diff --git a/src/boot/strap/utility.clisp b/src/boot/strap/utility.clisp index a4c6aa61..7137a1c6 100644 --- a/src/boot/strap/utility.clisp +++ b/src/boot/strap/utility.clisp @@ -1,5 +1,14 @@ (PROCLAIM '(OPTIMIZE SPEED)) -(IMPORT-MODULE "initial-env") +(EVAL-WHEN (:COMPILE-TOPLEVEL :LOAD-TOPLEVEL :EXECUTE) + (UNLESS (FIND-PACKAGE #1="BOOTTRAN") (MAKE-PACKAGE #1#))) + +(EVAL-WHEN (:COMPILE-TOPLEVEL :LOAD-TOPLEVEL :EXECUTE) + (PROGN + (COND + ((|%hasFeature| :COMMON-LISP) + (USE-PACKAGE "COMMON-LISP" . #1=(#2="BOOTTRAN"))) + (T (USE-PACKAGE "LISP" . #1#))) + (USE-PACKAGE "AxiomCore" #2#))) (IN-PACKAGE "BOOTTRAN") @@ -10,9 +19,9 @@ '(|objectMember?| |symbolMember?| |stringMember?| |charMember?| |scalarMember?| |listMember?| |reverse| |reverse!| |lastNode| |append| |append!| |copyList| |substitute| - |substitute!| |setDifference| |applySubst| |applySubst!| - |applySubstNQ| |remove| |removeSymbol| |atomic?| - |finishLine| |subStringMatch?|))) + |substitute!| |setDifference| |setUnion| |setIntersection| + |applySubst| |applySubst!| |applySubstNQ| |remove| + |removeSymbol| |atomic?| |finishLine|))) (DECLAIM (FTYPE (FUNCTION (|%Thing| |%Thing| |%Thing|) |%Thing|) |substitute|)) @@ -39,6 +48,18 @@ (DECLAIM (FTYPE (FUNCTION ((|%List| |%Thing|) |%Thing|) (|%List| |%Thing|)) |remove|)) +(DECLAIM + (FTYPE (FUNCTION ((|%List| |%Thing|) (|%List| |%Thing|)) (|%List| |%Thing|)) + |setDifference|)) + +(DECLAIM + (FTYPE (FUNCTION ((|%List| |%Thing|) (|%List| |%Thing|)) (|%List| |%Thing|)) + |setUnion|)) + +(DECLAIM + (FTYPE (FUNCTION ((|%List| |%Thing|) (|%List| |%Thing|)) (|%List| |%Thing|)) + |setIntersection|)) + (DECLAIM (FTYPE (FUNCTION (|%Thing|) |%Boolean|) |atomic?|)) (DECLAIM (FTYPE (FUNCTION (|%Thing|) |%Void|) |finishLine|)) @@ -51,6 +72,8 @@ (FTYPE (FUNCTION (|%String| |%Short|) (|%Maybe| |%Short|)) |firstBlankPosition|)) +(|%defaultReadAndLoadSettings|) + (DEFUN |atomic?| (|x|) (OR (NOT (CONSP |x|)) (EQ (CAR |x|) 'QUOTE))) (DEFUN |objectMember?| (|x| |l|) @@ -224,6 +247,41 @@ (SETQ |bfVar#1| (CDR |bfVar#1|)))) (CDR |l|)))))) +(DEFUN |setUnion| (|x| |y|) + (PROG (|z|) + (RETURN + (PROGN + (SETQ |z| NIL) + (LET ((|bfVar#1| |x|) (|a| NIL)) + (LOOP + (COND + ((OR (NOT (CONSP |bfVar#1|)) (PROGN (SETQ |a| (CAR |bfVar#1|)) NIL)) + (RETURN NIL)) + (T (AND (NOT (|objectMember?| |a| |z|)) (SETQ |z| (CONS |a| |z|))))) + (SETQ |bfVar#1| (CDR |bfVar#1|)))) + (LET ((|bfVar#2| |y|) (|a| NIL)) + (LOOP + (COND + ((OR (NOT (CONSP |bfVar#2|)) (PROGN (SETQ |a| (CAR |bfVar#2|)) NIL)) + (RETURN NIL)) + (T (AND (NOT (|objectMember?| |a| |z|)) (SETQ |z| (CONS |a| |z|))))) + (SETQ |bfVar#2| (CDR |bfVar#2|)))) + (|reverse!| |z|))))) + +(DEFUN |setIntersection| (|x| |y|) + (LET ((|bfVar#2| NIL) (|bfVar#3| NIL) (|bfVar#1| |x|) (|a| NIL)) + (LOOP + (COND + ((OR (NOT (CONSP |bfVar#1|)) (PROGN (SETQ |a| (CAR |bfVar#1|)) NIL)) + (RETURN |bfVar#2|)) + (T + (AND (|objectMember?| |a| |y|) + (COND + ((NULL |bfVar#2|) (SETQ |bfVar#2| #1=(CONS |a| NIL)) + (SETQ |bfVar#3| |bfVar#2|)) + (T (RPLACD |bfVar#3| #1#) (SETQ |bfVar#3| (CDR |bfVar#3|))))))) + (SETQ |bfVar#1| (CDR |bfVar#1|))))) + (DEFUN |removeSymbol| (|l| |x|) (PROG (|y| |LETTMP#1| |l'| |before|) (RETURN |