Closed UWN closed 2 years ago
@UWN I went through all the cases in http://www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing, managed to pass all of them by completely redoing the parser/lexer/writer.
$ $(go env GOPATH)/bin/1pl
Top level for ichiban/prolog v0.10.0
This is for testing purposes only!
See https://github.com/ichiban/prolog for more details.
Type Ctrl-C or 'halt.' to exit.
?- writeq((*)=(*)).
(*)=(*)true.
(I now went through all cases manually, because I somehow was not able to use Ichiban in an Emacs-shell...)
#270 and 271 only work outside the top level which is ok, as the top level is not subject to these tests. So I did instead:````
ulrich@p0:~/iso-prolog$ cat ct_270.pl
get_char(C). %a
ulrich@p0:~/iso-prolog$ cat ct_271.pl
get_char(C).%a
ulrich@p0:~/iso-prolog$ $(go env GOPATH)/bin/1pl
Top level for ichiban/prolog v0.10.0
This is for testing purposes only!
See https://github.com/ichiban/prolog for more details.
Type Ctrl-C or 'halt.' to exit.
?- open('ct_270.pl',read,S), read(S, Term),get_char(S, Ch).
S = '$stream'(824634131312),
Term = get_char(_965),
Ch = ' ';
?- open('ct_271.pl',read,S), read(S, Term),get_char(S, Ch).
S = '$stream'(824634132832),
Term = get_char(_1007),
Ch = '%';
?-
which is just fine.
?- get_char(Ch).
Ch = '\r'.
I do not quite understand why you get here \r
and not \n
.
A similar toplevel problem happens with, say #281, where the error is not produced immediately after issuing return but rather upon a second return. So I'd say this is probably not a conformity issue:
ulrich@p0:~/iso-prolog$ $(go env GOPATH)/bin/1pl
Top level for ichiban/prolog v0.10.0
This is for testing purposes only!
See https://github.com/ichiban/prolog for more details.
Type Ctrl-C or 'halt.' to exit.
?- writeq(00'a).
|-
2022/07/20 08:59:34 failed to query: unexpected token: {invalid 'a).
}
So why in this case the continuation prompt |-
is shown instead of producing the error immediately?
I bet this is because of the readline
-ish library ssh/terminal
to process keyboard inputs. I'm not sure why it's '\r'. I'll investigate it later.
As for \r
, the user_input
for 1pl
is the standard input in raw mode which, I believe, emulates VT100. So the return key becomes \r
(carriage return). https://vt100.net/docs/vt100-ug/chapter3.html#T3-4 Maybe we should stop using raw mode for user_input
.
Not sure how to interpret the vt100 documentation. In any case, look at:
?- number_chars(N,"%\n1").
N = 1.
?- number_chars(N,"%\r1").
2022/08/05 07:16:06 error(syntax_error(not a number),number_chars/2)
which is perfect conformance (like SICStus, Scryer etc).
Fixed some rough edges of 1pl
regarding user input on v0.10.4:
$ go install github.com/ichiban/prolog/cmd/1pl@latest
go: downloading github.com/ichiban/prolog v0.10.4
$ $(go env GOPATH)/bin/1pl
Top level for ichiban/prolog v0.10.4
This is for testing purposes only!
See https://github.com/ichiban/prolog for more details.
Type Ctrl-C or 'halt.' to exit.
?- get_char(Ch).
|:
Ch = '\n'.
?- writeq(00'a).
2022/08/07 16:46:27 failed to query: unexpected token: {invalid 'a).
}
?-
Conformity to ISO syntax means two things: Both correct reading and writing.
For example, #27 is not conforming:
Expected:
(*)=(*)
It seems best to go through all (currently) 307 cases.