core: Remove symbol_to_list, char_to_integer, integer_to_char.

* mes.c (symbol_to_list, char_to_integer, integer_to_char): Remove
* module/mes/read-0.mes (symbol->list, integer->char,
  symbol->keyword): New function.
  (read-word): Use symbol->keyword.
* module/mes/type-0.mes (char->integer): New function.
* module/mes/scm.mes (keyword->symbol): New function.
This commit is contained in:
Jan Nieuwenhuizen 2016-12-23 23:25:49 +01:00
parent 95fd6646dc
commit 73fc7707a5
4 changed files with 27 additions and 24 deletions

21
mes.c
View file

@ -868,27 +868,6 @@ write_char (SCM x) ///((arity . n))
return c; return c;
} }
SCM
symbol_to_list (SCM x)
{
assert (TYPE (x) == SYMBOL);
return STRING (x);
}
SCM
char_to_integer (SCM x)
{
assert (TYPE (x) == CHAR);
return MAKE_NUMBER (VALUE (x));
}
SCM
integer_to_char (SCM x)
{
assert (TYPE (x) == NUMBER);
return MAKE_CHAR (VALUE (x));
}
void void
make_tmps (scm* cells) make_tmps (scm* cells)
{ {

View file

@ -104,12 +104,24 @@
(quote ((current-module)))))) (quote ((current-module))))))
(current-module))) (current-module)) (current-module))) (current-module))
(define <cell:character> 0)
(define <cell:keyword> 3) (define <cell:keyword> 3)
(define <cell:string> 9) (define <cell:string> 9)
(define (list->symbol lst) (make-symbol lst))
(define (symbol->list s)
(core:car s))
(define (list->string lst) (define (list->string lst)
(make-cell <cell:string> lst 0)) (make-cell <cell:string> lst 0))
(define (integer->char x)
(make-cell <cell:character> 0 x))
(define (symbol->keyword s)
(make-cell <cell:keyword> (symbol->list s) 0))
(define (read) (define (read)
(read-word (read-byte) (list) (current-module))) (read-word (read-byte) (list) (current-module)))
@ -190,8 +202,6 @@
(define (not x) (define (not x)
(if x #f #t)) (if x #f #t))
(define (list->symbol lst) (make-symbol lst))
(define (read-character) (define (read-character)
(define (read-octal c p n) (define (read-octal c p n)
(if (not (and (> p 47) (< p 56))) n (if (not (and (> p 47) (< p 56))) n
@ -289,7 +299,7 @@
((eq? (peek-byte) 39) (read-byte) ((eq? (peek-byte) 39) (read-byte)
(cons (quote syntax) (cons (read-word (read-byte) w a) (list)))) (cons (quote syntax) (cons (read-word (read-byte) w a) (list))))
((eq? (peek-byte) 58) (read-byte) ((eq? (peek-byte) 58) (read-byte)
(make-cell <cell:keyword> (symbol->list (read-word (read-byte) (list) a)) 0)) (symbol->keyword (read-word (read-byte) (list) a)))
((eq? (peek-byte) 59) (read-byte) ((eq? (peek-byte) 59) (read-byte)
(read-word (read-byte) w a) (read-word (read-byte) w a)
(read-word (read-byte) w a)) (read-word (read-byte) w a))

View file

@ -237,6 +237,11 @@
(set! counter (+ counter 1)) (set! counter (+ counter 1))
(string->symbol (string-append "g" value)))))) (string->symbol (string-append "g" value))))))
;;; Keywords
(define (keyword->symbol s)
(list->symbol (keyword->list s)))
;;; Characters ;;; Characters
(define (char=? x y) (define (char=? x y)

View file

@ -127,8 +127,17 @@
(define (symbol->list s) (define (symbol->list s)
(core:car s)) (core:car s))
(define (keyword->list s)
(core:car s))
(define (symbol->string s) (define (symbol->string s)
(apply string (symbol->list s))) (apply string (symbol->list s)))
(define (string-append . rest) (define (string-append . rest)
(apply string (apply append (map1 string->list rest)))) (apply string (apply append (map1 string->list rest))))
(define (integer->char x)
(make-cell <cell:character> 0 x))
(define (char->integer x)
(make-cell <cell:number> 0 x))