sicp-tool.ss
;; Note: This was adapted from the PLT 4.1.5 "eopl-tool.ss".

#lang mzscheme

(require mzlib/unit
         mzlib/class
         drscheme/tool
         string-constants)

(provide tool@)

(define tool@
  (unit
    (import drscheme:tool^)
    (export drscheme:tool-exports^)
    (define language-base%
      (class* object% (drscheme:language:simple-module-based-language<%>)
        (define/public (get-language-numbers)
          '(-500 -333)) ;; TODO: !!!
        (define/public (get-language-position)
          (list (string-constant teaching-languages)
                "SICP"))
        (define/public (get-module)
          '(lib "sicp/main.ss"))
        (define/public (get-one-line-summary)
          "Based on the !!! text")
        (define/public (get-language-url)
          "http://mitpress.mit.edu/sicp/")
        (define/public (get-reader)
          (lambda (src port)
            (let ([v (read-syntax src port)])
              (if (eof-object? v)
                  v
                  (namespace-syntax-introduce v)))))
        (super-instantiate ())))

    (define language%
      (class (drscheme:language:module-based-language->language-mixin
              (drscheme:language:simple-module-based-language->module-based-language-mixin
               language-base%))
        (define/override (use-namespace-require/copy?) #t)
        (define/override (on-execute settings run-in-user-thread)
          (super on-execute settings run-in-user-thread)
          (print-mpair-curly-braces #f)
          ;; (run-in-user-thread
          ;;  (lambda ()
          ;;    ((namespace-variable-value 'install-sicp-exception-handler))))
          )
        (super-instantiate ())))

    (define (phase1) (void))
    (define (phase2)
      (drscheme:language-configuration:add-language
       (make-object ((drscheme:language:get-default-mixin) language%))))))