;;;; -*- mode:lisp;coding:utf-8 -*-
;;;;**************************************************************************
;;;;FILE:               packages.lisp
;;;;LANGUAGE:           Common-Lisp
;;;;SYSTEM:             Common-Lisp
;;;;USER-INTERFACE:     NONE
;;;;DESCRIPTION
;;;;
;;;;    Define the packages for the minimal compiler.
;;;;
;;;;AUTHORS
;;;;    <PJB> Pascal J. Bourguignon <pjb@informatimago.com>
;;;;MODIFICATIONS
;;;;    2010-02-07 <PJB> Created.
;;;;BUGS
;;;;LEGAL
;;;;    GPL
;;;;
;;;;    Copyright Pascal J. Bourguignon 2010 - 2010
;;;;
;;;;    This program is free software; you can redistribute it and/or
;;;;    modify it under the terms of the GNU General Public License
;;;;    as published by the Free Software Foundation; either version
;;;;    2 of the License, or (at your option) any later version.
;;;;
;;;;    This program is distributed in the hope that it will be
;;;;    useful, but WITHOUT ANY WARRANTY; without even the implied
;;;;    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;;;;    PURPOSE.  See the GNU General Public License for more details.
;;;;
;;;;    You should have received a copy of the GNU General Public
;;;;    License along with this program; if not, write to the Free
;;;;    Software Foundation, Inc., 59 Temple Place, Suite 330,
;;;;    Boston, MA 02111-1307 USA
;;;;**************************************************************************
(in-package "COMMON-LISP-USER")

(defpackage "MINIMAL-COMPILER"
  (:nicknames "MC")
  (:use "COMMON-LISP"
        "COM.INFORMATIMAGO.COMMON-LISP.LISP-SEXP.SOURCE-FORM"
        "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY")
  (:shadow
   . #1=(
         "*MACROEXPAND-HOOK*"
         "COMPILER-MACRO-FUNCTION"
         "MACRO-FUNCTION"
         "DEFINE-SYMBOL-MACRO" "DEFINE-COMPILER-MACRO" "DEFMACRO"
         "DEFINE-SETF-EXPANDER" "DEFSETF"
         "MACROEXPAND" "MACROEXPAND-1" "GET-SETF-EXPANSION"
         ))

  (:export
   "*INHERIT-CL-COMPILER-MACROS*" "*INHERIT-CL-MACROS*"
   "MINIMAL-COMPILE"
   . #1#)
  (:documentation "

This package exports a Common Lisp minimal compiler.

It defines its own environments, and exports the functions, accessors
and macros needed to manipulate them.

"))


(defpackage "MINIMAL-COMPILER-SYSTEM"
  (:use "COMMON-LISP")
  (:nicknames "MC-SYSTEM" "MCSYS")
  (:export "NOTE-TYPE"  "ENSURE-TYPE"
           "NOTE-CLASS" "ENSURE-CLASS"
           "CONSTANT"
           "SOURCE-PROGRAM-ERROR"
           "SOURCE-PROGRAM-ERROR-SOURCE-FORM"
           "SOURCE-PROGRAM-ERROR-ERRONEOUS-SUBFORM"
           "SOURCE-PROGRAM-ERROR-INVALID-VARIABLE-NAME"
           "SOURCE-PROGRAM-ERROR-INVALID-DOCUMENTATION-STRING"
           "SOURCE-PROGRAM-ERROR-TOO-MANY-DOCUMENTATION-STRINGS"
           "SOURCE-PROGRAM-ERROR-TOO-MANY-SIZE-CLAUSES"
           "SOURCE-PROGRAM-ERROR-INVALID-DEFPACKAGE-CLAUSE"
           "SOURCE-PROGRAM-ERROR-TOO-MANY-DEFTYPE-FORMS"
           "PACKAGE-ERROR-PACKAGE-NOT-FOUND"
           "PACKAGE-ERROR-SYMBOL-NOT-FOUND"

           "TRACE-FUNCTION"
           "UNTRACE-FUNCTION"
           "TRACED-FUNCTIONS")
  (:documentation "

This package exports primitives that are referenced by the macros
defined in STANDARD-MACRO.

"))



(defpackage "STANDARD-MACROS"
  (:nicknames "SM")
  (:use "COMMON-LISP"
        "MINIMAL-COMPILER"
        "MINIMAL-COMPILER-SYSTEM"
        "COM.INFORMATIMAGO.COMMON-LISP.LISP-SEXP.SOURCE-FORM")
  (:shadowing-import-from
   "MINIMAL-COMPILER"
   "*MACROEXPAND-HOOK*"
   "COMPILER-MACRO-FUNCTION"
   "MACRO-FUNCTION"
   "MACROEXPAND" "MACROEXPAND-1" "GET-SETF-EXPANSION")
  (:shadowing-import-from
   "MINIMAL-COMPILER"
   . #1= (
          "DEFINE-SYMBOL-MACRO" "DEFINE-COMPILER-MACRO" "DEFMACRO"
          "DEFINE-SETF-EXPANDER" "DEFSETF"))
  (:shadow
   . #2= (

          "CALL-METHOD" "LOOP-FINISH" "MAKE-METHOD"
          "PPRINT-EXIT-IF-LIST-EXHAUSTED" "PPRINT-POP"

          "AND" "ASSERT" "CASE" "CCASE" "CHECK-TYPE" "COND"
          "CTYPECASE" "DECF" "DECLAIM" "DEFCLASS" "DEFCONSTANT"
          "DEFGENERIC" "DEFINE-CONDITION"
          "DEFINE-METHOD-COMBINATION" "DEFINE-MODIFY-MACRO"
          "DEFMETHOD" "DEFPACKAGE" "DEFPARAMETER"
          "DEFSTRUCT" "DEFTYPE" "DEFUN" "DEFVAR" "DESTRUCTURING-BIND"
          "DO" "DO*" "DO-ALL-SYMBOLS" "DO-EXTERNAL-SYMBOLS"
          "DO-SYMBOLS" "DOLIST" "DOTIMES" "ECASE" "ETYPECASE"
          "FORMATTER" "HANDLER-BIND" "HANDLER-CASE" "IGNORE-ERRORS"
          "IN-PACKAGE" "INCF" "LAMBDA" "LOOP" "MULTIPLE-VALUE-BIND"
          "MULTIPLE-VALUE-LIST" "MULTIPLE-VALUE-SETQ" "NTH-VALUE" "OR"
          "POP" "PPRINT-LOGICAL-BLOCK" "PRINT-UNREADABLE-OBJECT"
          "PROG" "PROG*" "PROG1" "PROG2" "PSETF" "PSETQ" "PUSH"
          "PUSHNEW" "REMF" "RESTART-BIND" "RESTART-CASE" "RETURN"
          "ROTATEF" "SETF" "SHIFTF" "STEP" "TIME" "TRACE" "TYPECASE"
          "UNLESS" "UNTRACE" "WHEN" "WITH-ACCESSORS"
          "WITH-COMPILATION-UNIT" "WITH-CONDITION-RESTARTS"
          "WITH-HASH-TABLE-ITERATOR" "WITH-INPUT-FROM-STRING"
          "WITH-OPEN-STREAM" "WITH-OUTPUT-TO-STRING"
          "WITH-PACKAGE-ITERATOR" "WITH-SIMPLE-RESTART" "WITH-SLOTS"
          "WITH-STANDARD-IO-SYNTAX"

          ))
  (:export . #1#)
  (:export . #2#))



(defpackage "MINIMAL-COMPILER-MACROS"
  (:nicknames "MCM")
  )


(defparameter *cl-accessors*
  '(AREF BIT CAAAAR CAAADR CAAAR CAADAR CAADDR CAADR CAAR CADAAR
    CADADR CADAR CADDAR CADDDR CADDR CADR CAR CDAAAR CDAADR CDAAR CDADAR
    CDADDR CDADR CDAR CDDAAR CDDADR CDDAR CDDDAR CDDDDR CDDDR CDDR CDR
    CHAR COMPILER-MACRO-FUNCTION EIGHTH ELT FDEFINITION FIFTH
    FILL-POINTER FIND-CLASS FIRST FOURTH GET GETF GETHASH LDB
    LOGICAL-PATHNAME-TRANSLATIONS MACRO-FUNCTION MASK-FIELD NINTH NTH
    READTABLE-CASE REST ROW-MAJOR-AREF SBIT SCHAR SECOND SEVENTH SIXTH
    SUBSEQ SVREF SYMBOL-FUNCTION SYMBOL-PLIST SYMBOL-VALUE TENTH THIRD
    VALUES))


(defparameter *cl-local-macros*
  '(CALL-METHOD LOOP-FINISH MAKE-METHOD PPRINT-EXIT-IF-LIST-EXHAUSTED
    PPRINT-POP))


(defparameter *cl-macros*
  '(AND ASSERT CASE CCASE CHECK-TYPE COND CTYPECASE DECF DECLAIM
    DEFCLASS DEFCONSTANT DEFGENERIC DEFINE-COMPILER-MACRO
    DEFINE-CONDITION DEFINE-METHOD-COMBINATION DEFINE-MODIFY-MACRO
    DEFINE-SETF-EXPANDER DEFINE-SYMBOL-MACRO DEFMACRO DEFMETHOD
    DEFPACKAGE DEFPARAMETER DEFSETF DEFSTRUCT DEFTYPE DEFUN DEFVAR
    DESTRUCTURING-BIND DO DO* DO-ALL-SYMBOLS DO-EXTERNAL-SYMBOLS
    DO-SYMBOLS DOLIST DOTIMES ECASE ETYPECASE FORMATTER HANDLER-BIND
    HANDLER-CASE IGNORE-ERRORS IN-PACKAGE INCF LAMBDA LOOP
    MULTIPLE-VALUE-BIND MULTIPLE-VALUE-LIST MULTIPLE-VALUE-SETQ NTH-VALUE
    OR POP PPRINT-LOGICAL-BLOCK PRINT-UNREADABLE-OBJECT PROG PROG* PROG1
    PROG2 PSETF PSETQ PUSH PUSHNEW REMF RESTART-BIND RESTART-CASE RETURN
    ROTATEF SETF SHIFTF STEP TIME TRACE TYPECASE UNLESS UNTRACE WHEN
    WITH-ACCESSORS WITH-COMPILATION-UNIT WITH-CONDITION-RESTARTS
    WITH-HASH-TABLE-ITERATOR WITH-INPUT-FROM-STRING WITH-OPEN-STREAM
    WITH-OUTPUT-TO-STRING WITH-PACKAGE-ITERATOR WITH-SIMPLE-RESTART
    WITH-SLOTS WITH-STANDARD-IO-SYNTAX))


(defparameter *cl-special-operators*
  '(SETQ BLOCK CATCH EVAL-WHEN FLET FUNCTION GO IF LABELS LET LET*
    LOAD-TIME-VALUE LOCALLY MACROLET MULTIPLE-VALUE-CALL
    MULTIPLE-VALUE-PROG1 PROGN PROGV QUOTE RETURN-FROM SYMBOL-MACROLET
    TAGBODY THE THROW UNWIND-PROTECT))
ViewGit