home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-07-26 | 6.9 KB | 196 lines | [TEXT/gamI] |
- (##declare (standard-bindings) (block) (fixnum))
- (##declare
- (namespace "c#")
- (namespace ""
- not boolean? eqv? eq? equal? pair? cons car cdr set-car! set-cdr!
- caar cadr cdar cddr caaar caadr cadar caddr cdaar cdadr cddar cdddr
- caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr cdaaar cdaadr
- cdadar cdaddr cddaar cddadr cdddar cddddr null? list? list length
- append reverse list-ref memq memv member assq assv assoc symbol?
- symbol->string string->symbol number? complex? real? rational?
- integer? exact? inexact? = < > <= >= zero? positive? negative? odd?
- even? max min + * - / abs quotient remainder modulo gcd lcm numerator
- denominator floor ceiling truncate round rationalize exp log sin cos
- tan asin acos atan sqrt expt make-rectangular make-polar real-part
- imag-part magnitude angle exact->inexact inexact->exact number->string
- string->number char? char=? char<? char>? char<=? char>=? char-ci=?
- char-ci<? char-ci>? char-ci<=? char-ci>=? char-alphabetic?
- char-numeric? char-whitespace? char-upper-case? char-lower-case?
- char->integer integer->char char-upcase char-downcase string?
- make-string string string-length string-ref string-set! string=?
- string<? string>? string<=? string>=? string-ci=? string-ci<?
- string-ci>? string-ci<=? string-ci>=? substring string-append vector?
- make-vector vector vector-length vector-ref vector-set! procedure?
- apply map for-each call-with-current-continuation call-with-input-file
- call-with-output-file input-port? output-port? current-input-port
- current-output-port open-input-file open-output-file close-input-port
- close-output-port eof-object? read read-char peek-char write display
- newline write-char
-
- eval error
- ))
- ;==============================================================================
-
- ; file: "host.scm"
-
- ;------------------------------------------------------------------------------
- ;
- ; Host system interface:
- ; ---------------------
-
- ; This package contains definitions to interface to the host system in which
- ; the compiler is loaded. This is the only package that contains non-portable
- ; scheme code. So one should be able to port the compiler to another system by
- ; adjusting this file. The global variable 'host-system' is assumed to contain
- ; the name of the host system.
-
- ;------------------------------------------------------------------------------
-
- ; The host dependent variables:
- ; ----------------------------
-
- ; 'open-input-file*' is like open-input-file but returns #f when the named
- ; file does not exist.
-
- (define open-input-file* ##open-input-file)
-
- ; 'pp-expression' is used to pretty print an expression on a given port.
-
- (define (pp-expression expr port)
- (##pretty-print expr port (##port-width port))
- (##newline port))
-
- ; 'write-returning-len' is like 'write' but it returns the number of
- ; characters that were written out.
-
- (define (write-returning-len obj port)
- (##write obj port #t))
-
- ; 'display-returning-len' is like 'display' but it returns the number of
- ; characters that were written out.
-
- (define (display-returning-len obj port)
- (##display obj port #t))
-
- ; 'write-word' is used to write out files containing binary data.
-
- (define (write-word w port)
- (write-char (integer->char (quotient w 256)) port)
- (write-char (integer->char (modulo w 256)) port))
-
- ; Various characters
-
- (define char-newline (integer->char 10))
- (define char-tab (integer->char 9))
-
- ; 'character-encoding' is used to convert Scheme characters into their
- ; corresponding machine representation.
-
- (define character-encoding char->integer)
-
- ; Highest value returned by 'character-encoding'.
-
- (define max-character-encoding 255)
-
- ; 'fatal-err' is used to signal non recoverable errors.
-
- (define (fatal-err msg arg)
- (error msg arg))
-
- ; 'scheme-global-var', 'scheme-global-var-ref', 'scheme-global-var-set!' and
- ; 'scheme-global-eval' define an interface to the a built-in evaluator (if
- ; there is one). The evaluator is only needed for the processing of macros.
-
- (define (scheme-global-var name)
- name)
-
- (define (scheme-global-var-ref var)
- (scheme-global-eval var))
-
- (define (scheme-global-var-set! var val)
- (scheme-global-eval (list 'SET! var (list 'QUOTE val)) fatal-err))
-
- (define (scheme-global-eval expr err)
- (eval expr))
-
- ; 'pinpoint-error' is called when the compiler detects a user error in a source
- ; file. In a windowed environment this can be used to show the location of
- ; an error.
-
- (define (pinpoint-error filename line char)
- #t)
-
- ; 'path-absolute?', 'file-path', 'file-name', 'file-root', 'file-ext' define
- ; an interface to the file system's naming conventions.
- ;
- ; Under UNIX,
- ; (path-absolute? "/foo/bar") => #t
- ; (path-absolute? "foo.scm") => #f
- ; (file-path "foo/bar/baz.scm") => "foo/bar"
- ; (file-name "foo/bar/baz.scm") => "baz.scm"
- ; (file-ext "foo/bar/baz.scm") => "scm"
- ; (file-root "foo/bar/baz.scm") => "foo/bar/baz"
-
- (define file-path-sep #\:)
- (define file-ext-sep #\.)
-
- (define (path-absolute? x)
- (and (> (string-length x) 0)
- (let ((c (string-ref x 0)))
- (or (char=? c #\/) (char=? c #\~)))))
-
- (define (file-path x)
- (let loop1 ((i (string-length x)))
- (if (and (> i 0) (not (char=? (string-ref x (- i 1)) file-path-sep)))
- (loop1 (- i 1))
- (let ((result (make-string i)))
- (let loop2 ((j (- i 1)))
- (if (< j 0)
- result
- (begin
- (string-set! result j (string-ref x j))
- (loop2 (- j 1)))))))))
-
- (define (file-name x)
- (let loop1 ((i (string-length x)))
- (if (and (> i 0) (not (char=? (string-ref x (- i 1)) file-path-sep)))
- (loop1 (- i 1))
- (let ((result (make-string (- (string-length x) i))))
- (let loop2 ((j (- (string-length x) 1)))
- (if (< j i)
- result
- (begin
- (string-set! result (- j i) (string-ref x j))
- (loop2 (- j 1)))))))))
-
- (define (file-ext x)
- (let loop1 ((i (string-length x)))
- (if (or (= i 0) (char=? (string-ref x (- i 1)) file-path-sep))
- ""
- (if (not (char=? (string-ref x (- i 1)) file-ext-sep))
- (loop1 (- i 1))
- (let ((result (make-string (- (string-length x) i))))
- (let loop2 ((j (- (string-length x) 1)))
- (if (< j i)
- result
- (begin
- (string-set! result (- j i) (string-ref x j))
- (loop2 (- j 1))))))))))
-
- (define (file-root x)
- (let loop1 ((i (string-length x)))
- (if (or (= i 0) (char=? (string-ref x (- i 1)) file-path-sep))
- x
- (if (not (char=? (string-ref x (- i 1)) file-ext-sep))
- (loop1 (- i 1))
- (let ((result (make-string (- i 1))))
- (let loop2 ((j (- i 2)))
- (if (< j 0)
- result
- (begin
- (string-set! result j (string-ref x j))
- (loop2 (- j 1))))))))))
-
-
- ;==============================================================================
-