Loading Read.pm +9 −10 Original line number Diff line number Diff line Loading @@ -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); } Loading @@ -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; } Loading @@ -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 '\'') { Loading @@ -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{^\"}) { Loading @@ -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); Loading @@ -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"); } Loading Loading @@ -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 { Loading Loading
Read.pm +9 −10 Original line number Diff line number Diff line Loading @@ -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); } Loading @@ -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; } Loading @@ -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 '\'') { Loading @@ -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{^\"}) { Loading @@ -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); Loading @@ -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"); } Loading Loading @@ -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 { Loading