* mes.c (MAKE_CHAR): New macro.
(make_char): Remove. Update callers.
* reader.c (peek_char, read_char, unread_char): Remove.
* module/mes/scm.mes (peek-char, read-char, unread-char): New function.
#define CDADAR(x) CAR (CDR (CAR (CDR (x))))
#define CADR(x) CAR (CDR (x))
#define CDADAR(x) CAR (CDR (CAR (CDR (x))))
#define CADR(x) CAR (CDR (x))
+#define MAKE_CHAR(n) make_cell (tmp_num_ (CHAR), 0, tmp_num2_ (n))
#define MAKE_NUMBER(n) make_cell (tmp_num_ (NUMBER), 0, tmp_num2_ (n))
SCM display_ (FILE* f, SCM x);
#define MAKE_NUMBER(n) make_cell (tmp_num_ (NUMBER), 0, tmp_num2_ (n))
SCM display_ (FILE* f, SCM x);
return append2 (car (x), append (cdr (x)));
}
return append2 (car (x), append (cdr (x)));
}
-SCM
-make_char (int x)
-{
- g_cells[tmp_num].value = CHAR;
- g_cells[tmp_num2].value = x;
- return make_cell (tmp_num, tmp_num2, tmp_num2);
-}
-
SCM p = cell_nil;
int i = strlen (s);
while (i--)
SCM p = cell_nil;
int i = strlen (s);
while (i--)
- p = cons (make_char (s[i]), p);
+ p = cons (MAKE_CHAR (s[i]), p);
assert (VALUE (i) < LENGTH (x));
SCM e = VECTOR (x) + VALUE (i);
if (TYPE (e) == REF) e = g_cells[e].ref;
assert (VALUE (i) < LENGTH (x));
SCM e = VECTOR (x) + VALUE (i);
if (TYPE (e) == REF) e = g_cells[e].ref;
- if (TYPE (e) == CHAR) e = make_char (VALUE (e));
+ if (TYPE (e) == CHAR) e = MAKE_CHAR (VALUE (e));
if (TYPE (e) == NUMBER) e = MAKE_NUMBER (VALUE (e));
return e;
}
if (TYPE (e) == NUMBER) e = MAKE_NUMBER (VALUE (e));
return e;
}
integer_to_char (SCM x)
{
assert (TYPE (x) == NUMBER);
integer_to_char (SCM x)
{
assert (TYPE (x) == NUMBER);
- return make_char (VALUE (x));
+ return MAKE_CHAR (VALUE (x));
mes_stack (SCM a) ///((internal))
{
r0 = a;
mes_stack (SCM a) ///((internal))
{
r0 = a;
- r1 = make_char (0);
- r2 = make_char (0);
- r3 = make_char (0);
+ r1 = MAKE_CHAR (0);
+ r2 = MAKE_CHAR (0);
+ r3 = MAKE_CHAR (0);
stack = cons (cell_nil, cell_nil);
return r0;
}
stack = cons (cell_nil, cell_nil);
return r0;
}
(if (null? lst) (* sign n)
(loop (cdr lst) (+ (* n 10) (- (char->integer (car lst)) (char->integer #\0)))))))))
(if (null? lst) (* sign n)
(loop (cdr lst) (+ (* n 10) (- (char->integer (car lst)) (char->integer #\0)))))))))
+(define (peek-char)
+ (integer->char (peek-byte)))
+
+(define (read-char)
+ (integer->char (read-byte)))
+
+(define (unread-char c)
+ (unread-byte (char->integer c))
+ c)
+
(define (char<? a b) (< (char->integer a) (char->integer b)))
(define (char>? a b) (> (char->integer a) (char->integer b)))
(define (char<=? a b) (<= (char->integer a) (char->integer b)))
(define (char<? a b) (< (char->integer a) (char->integer b)))
(define (char>? a b) (> (char->integer a) (char->integer b)))
(define (char<=? a b) (<= (char->integer a) (char->integer b)))
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
*/
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
*/
-SCM
-peek_char ()
-{
- return make_char (peekchar ());
-}
-
-SCM
-read_char ()
-{
- return make_char (getchar ());
-}
-
-SCM
-unread_char (SCM c)
-{
- return ungetchar (VALUE (c));
-}
-
int
read_line_comment (int c)
{
int
read_line_comment (int c)
{
if (c == ')' && w == cell_nil) {ungetchar (c); return cell_nil;}
if (c == ')') {ungetchar (c); return lookup_ (w, a);}
if (c == ';') {read_line_comment (c); return read_word ('\n', w, a);}
if (c == ')' && w == cell_nil) {ungetchar (c); return cell_nil;}
if (c == ')') {ungetchar (c); return lookup_ (w, a);}
if (c == ';') {read_line_comment (c); return read_word ('\n', w, a);}
- return read_word (getchar (), append2 (w, cons (make_char (c), cell_nil)), a);
+ return read_word (getchar (), append2 (w, cons (MAKE_CHAR (c), cell_nil)), a);
assert (TYPE (x) == STRING);
assert (TYPE (k) == NUMBER);
VALUE (tmp_num) = VALUE (k);
assert (TYPE (x) == STRING);
assert (TYPE (k) == NUMBER);
VALUE (tmp_num) = VALUE (k);
- return make_char (VALUE (list_ref (STRING (x), tmp_num)));
+ return MAKE_CHAR (VALUE (list_ref (STRING (x), tmp_num)));
while (start--) s = cdr (s);
SCM p = cell_nil;
while (n-- && s != cell_nil) {
while (start--) s = cdr (s);
SCM p = cell_nil;
while (n-- && s != cell_nil) {
- p = append2 (p, cons (make_char (VALUE (car (s))), cell_nil));
+ p = append2 (p, cons (MAKE_CHAR (VALUE (car (s))), cell_nil));
s = cdr (s);
}
return make_string (p);
s = cdr (s);
}
return make_string (p);
{
assert (TYPE (x) == NUMBER);
int n = VALUE (x);
{
assert (TYPE (x) == NUMBER);
int n = VALUE (x);
- SCM p = n < 0 ? cons (make_char ('-'), cell_nil) : cell_nil;
+ SCM p = n < 0 ? cons (MAKE_CHAR ('-'), cell_nil) : cell_nil;
- p = cons (make_char (n % 10 + '0'), p);
+ p = cons (MAKE_CHAR (n % 10 + '0'), p);
n = n / 10;
} while (n);
return make_string (p);
n = n / 10;
} while (n);
return make_string (p);