mes.c: when reading `EOF', defer read control to program.
This commit is contained in:
parent
8dacd68fe8
commit
46387d411b
|
@ -84,8 +84,7 @@ record: all
|
|||
|
||||
|
||||
paren: all
|
||||
cat scm.mes syntax.mes lib/srfi/srfi-0.scm lib/record.mes lib/record.scm lib/srfi/srfi-9.scm lib/lalr.mes lib/lalr.scm paren.scm | ./mes
|
||||
# #echo '___P((()))'
|
||||
echo -e 'EOF\n___P((()))' | cat scm.mes syntax.mes lib/srfi/srfi-0.scm lib/record.mes lib/record.scm lib/srfi/srfi-9.scm lib/lalr.mes lib/lalr.scm paren.scm - | ./mes
|
||||
|
||||
paren.test: lib/lalr.scm paren.scm
|
||||
cat $^ > $@
|
||||
|
|
18
mes.c
18
mes.c
|
@ -738,6 +738,10 @@ lookup (char *x, scm *a)
|
|||
if (*x == '#' && *(x+1) == ',' && *(x+2) == '@') return &symbol_unsyntax_splicing;
|
||||
if (*x == '#' && *(x+1) == ',') return &symbol_unsyntax;
|
||||
|
||||
if (!strcmp (x, "EOF")) {
|
||||
fprintf (stderr, "mes: got EOF\n");
|
||||
return &scm_nil; // `EOF': eval program, which may read stdin
|
||||
}
|
||||
return make_symbol (x);
|
||||
}
|
||||
|
||||
|
@ -921,13 +925,13 @@ peek_char () //int
|
|||
}
|
||||
|
||||
scm*
|
||||
builtin_getchar ()
|
||||
builtin_peek_char ()
|
||||
{
|
||||
return make_number (getchar ());
|
||||
return make_char (peek_char ());
|
||||
}
|
||||
|
||||
scm*
|
||||
builtin_peek_char ()
|
||||
scm *
|
||||
read_char ()
|
||||
{
|
||||
return make_char (getchar ());
|
||||
}
|
||||
|
@ -990,8 +994,8 @@ readword (int c, char* w, scm *a)
|
|||
&& !w) {char buf[3] = "#"; buf[1] = getchar (); return cons (lookup (buf, a),
|
||||
cons (readword (getchar (), w, a),
|
||||
&scm_nil));}
|
||||
if (c == ';') {readcomment (c); return readword ('\n', w, a);}
|
||||
if (c == '#' && peek_char () == '\\') {getchar (); return read_char ();}
|
||||
if (c == ';') {readcomment (c); return readword ('\n', w, a);}
|
||||
if (c == '#' && peek_char () == '\\') {getchar (); return read_character ();}
|
||||
if (c == '#' && !w && peek_char () == '(') {getchar (); return list_to_vector (readlist (a));}
|
||||
if (c == '#' && peek_char () == '(') {ungetchar (c); return lookup (w, a);}
|
||||
if (c == '#' && peek_char () == '!') {getchar (); readblock (getchar ()); return readword (getchar (), w, a);}
|
||||
|
@ -1001,7 +1005,7 @@ readword (int c, char* w, scm *a)
|
|||
}
|
||||
|
||||
scm *
|
||||
read_char ()
|
||||
read_character ()
|
||||
{
|
||||
int c = getchar ();
|
||||
if (c >= '0' && c <= '7'
|
||||
|
|
Loading…
Reference in a new issue