Re: Reading a file for lexing, one way to do it...

Sean Charles <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
Hi Daniel,

Thanks for taking the time to write such a good reply…

> 
> Remark: your list is ended by a variable (reported as an underscore by the top-level). This is totally OK (and often used to further add elements to the end of the list). If it is not the wanted behavior (you want a proper list ended by the empty list []), you have to replace the first lexread/2 clause by:
> 
> lexread(In, []) :- at_end_of_stream(In), !.

I had to really look but then I saw you haste have "[]" instead of _.

Then a huge penny dropped as to where the "mysterious" empty variable at then end of the list came from! It made me laugh! When you see things clearly, sometimes it hurts your eyes. That's a beautiful answer and I thank you for your time to explain it.

That was an enlightenment moment because I have been plagued by the same issue in some other code I have been playing with and now I can go back and kick its butt into submission with FULL understanding which is all you can ever hope for.

Thanks!

:)
Sean.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.