mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-03 11:16:36 +02:00
handle [+-].[^0-9] symbols (fixes issue #307)
This commit is contained in:
parent
3cf21ee8db
commit
8a739d2698
2 changed files with 10 additions and 1 deletions
|
@ -73,6 +73,8 @@
|
|||
(vector-set! x 2 x)
|
||||
x))
|
||||
|
||||
(test '+.! (read-from-string "+.!"))
|
||||
|
||||
(test 255 (read-from-string "#xff"))
|
||||
(test 99 (read-from-string "#d99"))
|
||||
(test 63 (read-from-string "#o77"))
|
||||
|
|
9
sexp.c
9
sexp.c
|
@ -2613,6 +2613,12 @@ static sexp sexp_fill_reader_labels(sexp ctx, sexp x, sexp shares, int state) {
|
|||
}
|
||||
#endif
|
||||
|
||||
static int sexp_peek_char(sexp ctx, sexp in) {
|
||||
int c = sexp_read_char(ctx, in);
|
||||
if (c != EOF) sexp_push_char(ctx, c, in);
|
||||
return c;
|
||||
}
|
||||
|
||||
sexp sexp_read_raw (sexp ctx, sexp in, sexp *shares) {
|
||||
char *str;
|
||||
int c1, c2, line;
|
||||
|
@ -3030,7 +3036,8 @@ sexp sexp_read_raw (sexp ctx, sexp in, sexp *shares) {
|
|||
case '+':
|
||||
case '-':
|
||||
c2 = sexp_read_char(ctx, in);
|
||||
if (c2 == '.' || sexp_isdigit(c2)) {
|
||||
if ((c2 == '.' && sexp_isdigit(sexp_peek_char(ctx, in)))
|
||||
|| sexp_isdigit(c2)) {
|
||||
sexp_push_char(ctx, c2, in);
|
||||
res = sexp_read_number(ctx, in, 10, 0);
|
||||
if ((c1 == '-') && ! sexp_exceptionp(res)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue