ichiban / prolog

The only reasonable scripting engine for Go.
MIT License
616 stars 29 forks source link

multiline block comment not accepted by consult/1 predicate #326

Open Jean-Luc-Picard-2021 opened 2 months ago

Jean-Luc-Picard-2021 commented 2 months ago

If I use this Prolog text:

human(socrates).       % This is a fact.
mortal(X) :- human(X). % This is a rule.

Everything works fine:

?- human(X).
X = socrates;

On the other hand this Prolog text:

/**
 * block comment
 * block comment
 * block comment
 * block comment
 * block comment
 * block comment
 **/

human(socrates).       % This is a fact.
mortal(X) :- human(X). % This is a rule.

Doesn't work ok:

?- human(X).
2024/08/10 21:29:19 error(existence_error(procedure,human/1),root)

I used top level ['categories.p'] respectively ['categories2.p'] with these texts:

categories.p.log categories2.p.log

ichiban commented 2 months ago

I can reproduce the bug with a shorter example:

$ cat foo.pl
/* **/foo.
$ $(go env GOPATH)/bin/1pl
Top level for ichiban/prolog v1.2.1
This is for testing purposes only!
See https://github.com/ichiban/prolog for more details.
Type Ctrl-C or 'halt.' to exit.
?- [foo].
true.
?- foo.
2024/08/14 14:35:25 error(existence_error(procedure,foo/0),root)
?- 

Something's wrong in lexer and mishandling the **/, I guess.