Commit 8b14eb1b authored by Juergen Nickelsen's avatar Juergen Nickelsen

cleaned up error reporting in Read, and smallish message changes

parent 57ad4880
......@@ -39,13 +39,12 @@ sub end_file {
undef($filename);
}
# after a read error, consume to end of line
# after a read error, consume to end of line for the benefit of interactive use
sub read_error {
my ($in, $format, @args) = @_;
<$in>;
if ($filename) {
print STDERR ("\n\n$filename:$linecount: $format\n", @args);
error("in $filename");
error("\n\n$filename:$linecount: $format\n", @args);
} else {
error($format, @args);
}
......@@ -57,7 +56,7 @@ sub Read {
if (stringp($in)) {
my $string = $in;
open(my $str_in, "<", \$string) or
error("read: cannot open string as filehandle: $!\n");
error("read: cannot open string as filehandle: $!");
$in = $str_in;
}
......@@ -68,7 +67,7 @@ sub Read {
my $list = read_list_elems($in);
return undef unless defined($list);
my $closer = next_token($in);
return read_error($in, "syntax: list closed by $closer")
return read_error($in, "list closed by $closer")
unless $closer eq ')';
return $list;
} elsif ($t eq '\'') {
......@@ -78,11 +77,11 @@ sub Read {
return list(intern($Quote), $t);
} elsif ($t eq '#\'') {
$t = Read($in);
return read_error($in, "EOF in quote")
return read_error($in, "EOF in #quote")
unless defined($t);
return list(intern($n_function), $t);
} elsif ($t eq '.') {
return read_error($in, "found . where sexpr was expected");
return read_error($in, "found . when expecting sexpr");
} elsif (symbolp($t)) {
return $t;
} elsif ($t =~ m{^\"}) {
......@@ -105,7 +104,7 @@ sub read_list_elems {
push_back_token($t);
return $list;
} elsif ($t eq '.') {
return read_error($in, "syntax: . at start of list")
return read_error($in, ". at start of list")
unless $end;
my $sexpr = Read($in);
return undef unless defined($t);
......@@ -128,7 +127,7 @@ sub read_list_elems {
}
}
}
return read_error($in, "EOF while reading list elements");
return read_error($in, "EOF reading list elements");
}
......@@ -211,7 +210,7 @@ sub error_or_eof {
if (defined($!)) {
return read_error($in, "read failure: $!");
}
return read_error($in, "unexpected EOF line");
return read_error($in, "unexpected EOF");
}
sub read_macro {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment