mes: #<eof> is not a character.

* module/mes/display.mes (display):
* module/mes/type-0.mes (char?): -1 is not a character.
  (eof-object?): New function.
* tests/base.test ("#<eof>"): Test it.
* module/mes/scm.mes (eof-object?): Remove.
  (unread-char): Return character (WAS: integer).
This commit is contained in:
Jan Nieuwenhuizen 2018-01-04 21:36:46 +01:00
parent 0e06928320
commit cab272a101
4 changed files with 17 additions and 11 deletions

View file

@ -1,7 +1,7 @@
;;; -*-scheme-*- ;;; -*-scheme-*-
;;; Mes --- Maxwell Equations of Software ;;; Mes --- Maxwell Equations of Software
;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org> ;;; Copyright © 2016,2017,2018 Jan Nieuwenhuizen <janneke@gnu.org>
;;; ;;;
;;; This file is part of Mes. ;;; This file is part of Mes.
;;; ;;;
@ -62,10 +62,11 @@
(define (d x cont? sep) (define (d x cont? sep)
(for-each (cut write-char <> port) (string->list sep)) (for-each (cut write-char <> port) (string->list sep))
(cond (cond
((eof-object? x)
(display "#<eof>" port))
((char? x) ((char? x)
(if (not write?) (write-char x port) (if (not write?) (write-char x port)
(let ((name (and=> (assq x '((#\*eof* . *eof*) (let ((name (and=> (assq x '((#\nul . nul)
(#\nul . nul)
(#\alarm . alarm) (#\alarm . alarm)
(#\backspace . backspace) (#\backspace . backspace)
(#\tab . tab) (#\tab . tab)

View file

@ -82,10 +82,6 @@
(define integer? number?) (define integer? number?)
(define (eof-object? x)
(or (and (number? x) (= x -1))
(and (char? x) (eof-object? (char->integer x)))))
(if (not (defined? 'peek-char)) (if (not (defined? 'peek-char))
(define (peek-char) (define (peek-char)
(integer->char (peek-byte)))) (integer->char (peek-byte))))
@ -96,7 +92,7 @@
(if (not (defined? 'unread-char)) (if (not (defined? 'unread-char))
(define (unread-char c) (define (unread-char c)
(unread-byte (char->integer c)))) (integer->char (unread-byte (char->integer c)))))
(define (assq-set! alist key val) (define (assq-set! alist key val)
(let ((entry (assq key alist))) (let ((entry (assq key alist)))

View file

@ -1,7 +1,7 @@
;;; -*-scheme-*- ;;; -*-scheme-*-
;;; Mes --- Maxwell Equations of Software ;;; Mes --- Maxwell Equations of Software
;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org> ;;; Copyright © 2016,2017,2018 Jan Nieuwenhuizen <janneke@gnu.org>
;;; ;;;
;;; This file is part of Mes. ;;; This file is part of Mes.
;;; ;;;
@ -62,7 +62,12 @@
(cond ((assq (core:type x) cell:type-alist) => cdr))) (cond ((assq (core:type x) cell:type-alist) => cdr)))
(define (char? x) (define (char? x)
(eq? (core:type x) <cell:char>)) (and (eq? (core:type x) <cell:char>)
(>= (char->integer x) 0)))
(define (eof-object? x)
(and (eq? (core:type x) <cell:char>)
(= (char->integer x) -1)))
(define (closure? x) (define (closure? x)
(eq? (core:type x) <cell:closure>)) (eq? (core:type x) <cell:closure>))

View file

@ -9,7 +9,7 @@ exit $?
;;; -*-scheme-*- ;;; -*-scheme-*-
;;; Mes --- Maxwell Equations of Software ;;; Mes --- Maxwell Equations of Software
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org> ;;; Copyright © 2016,2018 Jan Nieuwenhuizen <janneke@gnu.org>
;;; ;;;
;;; This file is part of Mes. ;;; This file is part of Mes.
;;; ;;;
@ -110,4 +110,8 @@ exit $?
(begin (set! seen? #t) (begin (set! seen? #t)
(cont 2))))) (cont 2)))))
(if (not guile?)
(pass-if-not "#<eof>"
(char? (integer->char -1))))
(result 'report) (result 'report)