Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phrase_from_file does not work on Windows #481

Closed
PatrickSkowronek opened this issue Jun 11, 2019 · 6 comments
Closed

phrase_from_file does not work on Windows #481

PatrickSkowronek opened this issue Jun 11, 2019 · 6 comments

Comments

@PatrickSkowronek
Copy link

Hello everyone,

currently I'm working on parser with DCG. With phrase and taking every single line it's working perfectly, but with phrase_from_file it does not work. Neither does these examples http://www.pathwayslms.com/swipltuts/dcg/#anch6 or https://www.metalevel.at/prolog/dcg .
Unfortunately I can't test it on Linux, on Windows with 8.0.2 it is not working.

Kind regards Patrick

@JanWielemaker
Copy link
Member

JanWielemaker commented Jun 11, 2019

Seems quite unikely. Only some parts of this tutorial may need to be adjusted for SWI-Prolog version 7 and later (http://www.swi-prolog.org/pldoc/man?section=strings), but not phrase_from_file/2,3. Please continue this at the forum and include exactly what you did as it is probably some minor detail.

@PatrickSkowronek
Copy link
Author

I followed @Anniepoo tutorial of DGC. I tried this code to test phrase_from_file :

:- set_prolog_flag(double_quotes, chars).
:- use_module(library(pio)).
:- use_module(library(dcg/basics)).

runDGC:- phrase_from_file(like(What), 'like.txt'), writeln(What).

like(What) --> "I like ", list(What), ".", list(_).

list([]) --> [].
list([L|Ls]) --> [L], list(Ls).

The text file contains "I like it." and the path is set correct. I consulted the file on a fresh console and there is no prolog flag for double quotes in my init file.

@JanWielemaker
Copy link
Member

phrase_from_file/3 doesn't work with :- set_prolog_flag(double_quotes, chars).. In fact, little except for some toy things do. If you want to discuss why, please use the forum.

@PatrickSkowronek
Copy link
Author

Thanks for the answer. After removing the :- set_prolog_flag(double_quotes, chars). it worked. I checked, the second example recommend using it.

@AnnieAtHasura
Copy link

my bad, filed
Anniepoo/swipldcgtut#18

@PatrickSkowronek
Copy link
Author

Sry @AnnieAtHasura the second example is from @triska .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants