Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
prolog reading a file the ISO style
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
levilista@gmail.com  
View profile  
 More options May 10 2008, 7:08 am
Newsgroups: comp.lang.prolog
From: "levili...@gmail.com" <levili...@gmail.com>
Date: Sat, 10 May 2008 04:08:52 -0700 (PDT)
Local: Sat, May 10 2008 7:08 am
Subject: prolog reading a file the ISO style
I have seen many posts reading a file the Edinborough style, but very
few about the ISO style.

I tried to write a simple program which reads a file, and prints it to
the standard output.

fussal(X):-
%       see("parse.pl"),
        open("parse.pl",read,[alias(input)]),
        repeat,
        read(input,T),print(T),T=end_of_file,!,X=false.

Result of running:

|    fussal(X).
ERROR: open/3: Type error: `atom' expected, found `[112, 97, 114, 115,
101, 46, 112, 108]'
   Exception: (8) open([112, 97, 114, 115, 101, 46, 112, 108], read,
[alias(input)]) ?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
levilista@gmail.com  
View profile  
 More options May 10 2008, 7:21 am
Newsgroups: comp.lang.prolog
From: "levili...@gmail.com" <levili...@gmail.com>
Date: Sat, 10 May 2008 04:21:55 -0700 (PDT)
Local: Sat, May 10 2008 7:21 am
Subject: Re: prolog reading a file the ISO style
Actually I tried the Edinbrough style as well, but I run into errors:

fussal(X):-
        X = "parse.pl",
        see("parse.pl"),
        seeing(X),
        read(T),display(T).

Running it:

|    fussal(X).
ERROR: see/1: Type error: `atom' expected, found `[112, 97, 114, 115,
101, 46, 112, 108]'
   Exception: (8) see([112, 97, 114, 115, 101, 46, 112, 108]) ? creep
6 ?-


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bart Demoen  
View profile  
 More options May 10 2008, 7:34 am
Newsgroups: comp.lang.prolog
From: Bart Demoen <b...@cs.kuleuven.ac.be>
Date: Sat, 10 May 2008 13:34:38 +0200
Local: Sat, May 10 2008 7:34 am
Subject: Re: prolog reading a file the ISO style

levili...@gmail.com wrote:
> fussal(X):-
> %  see("parse.pl"),
>    open("parse.pl",read,[alias(input)]),
>    repeat,
>    read(input,T),print(T),T=end_of_file,!,X=false.

> Result of running:

> |    fussal(X).
> ERROR: open/3: Type error: `atom' expected, found `[112, 97, 114, 115,
> 101, 46, 112, 108]'
>    Exception: (8) open([112, 97, 114, 115, 101, 46, 112, 108], read,
> [alias(input)]) ?

The message is saying that it expects an atom where it gets something else.
And that it is in the open/3 predicate.
That should ring a bell, no ?

Replace the " by '

Cheers

Bart Demoen


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chip Eastham  
View profile  
 More options May 10 2008, 7:35 am
Newsgroups: comp.lang.prolog
From: Chip Eastham <hardm...@gmail.com>
Date: Sat, 10 May 2008 04:35:36 -0700 (PDT)
Local: Sat, May 10 2008 7:35 am
Subject: Re: prolog reading a file the ISO style
On May 10, 7:21 am, "levili...@gmail.com" <levili...@gmail.com> wrote:

> Actually I tried the Edinbrough style as well, but I run into errors:

> fussal(X):-
>         X = "parse.pl",
>         see("parse.pl"),
>         seeing(X),
>         read(T),display(T).

> Running it:

> |    fussal(X).
> ERROR: see/1: Type error: `atom' expected, found `[112, 97, 114, 115,
> 101, 46, 112, 108]'
>    Exception: (8) see([112, 97, 114, 115, 101, 46, 112, 108]) ? creep
> 6 ?-

Try using single quotes rather than the double quotes. This
allows an atom to be formed using varied characters besides
the default syntax for an atom.

Double quotes turn the contents into a list of characters,
as you've seen above.

regards, chip


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
levilista@gmail.com  
View profile  
 More options May 10 2008, 8:45 am
Newsgroups: comp.lang.prolog
From: "levili...@gmail.com" <levili...@gmail.com>
Date: Sat, 10 May 2008 05:45:03 -0700 (PDT)
Local: Sat, May 10 2008 8:45 am
Subject: Re: prolog reading a file the ISO style
On May 10, 1:34 pm, Bart Demoen <b...@cs.kuleuven.ac.be> wrote:

Thanks for the comments. I wasn't aware of the differences between '
and "

You just highlighted my ignorance of the Prolog type system. (I know,
Prolog is called untyped. )


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
levilista@gmail.com  
View profile  
 More options May 10 2008, 9:02 am
Newsgroups: comp.lang.prolog
From: "levili...@gmail.com" <levili...@gmail.com>
Date: Sat, 10 May 2008 06:02:48 -0700 (PDT)
Local: Sat, May 10 2008 9:02 am
Subject: Re: prolog reading a file the ISO style
On May 10, 1:34 pm, Bart Demoen <b...@cs.kuleuven.ac.be> wrote:

Another problem: it doesn't find the file (although I checked, it's
there). I even tried using double blackslahses, but I got:

ERROR: seeing/1: Domain error: `stream' expected, found `C:\Documents
and Settings\Levente\My Documents\parse.pl'

I even tried to change "\" to "/".

The current version of my code looks like:

fussal(X):-
        X = 'C:\Documents and Settings\Levente\My Documents\parse.pl',
        see(X),
        seeing(X),
        read(T),display(T).


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
levilista@gmail.com  
View profile  
 More options May 10 2008, 2:33 pm
Newsgroups: comp.lang.prolog
From: "levili...@gmail.com" <levili...@gmail.com>
Date: Sat, 10 May 2008 11:33:15 -0700 (PDT)
Local: Sat, May 10 2008 2:33 pm
Subject: Re: prolog reading a file the ISO style
I fixed my program. I copy it hereby for the benefit of my fellow
noobs:

fussal(X):-
        X = 'c:/parse.pl',
        see(X),
% This will give an error, because it expects a stream;
%       seeing(X),
        repeat,
        get_char(T),print(T),T=end_of_file,!,seen.

The conclusions:
1,
If you omit the "seen" from the end of the end of the last line, the
next time you run the program you'll experience that the program only
reads "end_of_file" signs. This is because the "cursor position" of
file reading is assigned to the opened stream. (And a stream acts like
a global variable.)

2,
read/1 is for parsing prolog files. (It can handle the DCG syntax as
well.)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jan Wielemaker  
View profile  
 More options May 11 2008, 3:57 am
Newsgroups: comp.lang.prolog
From: Jan Wielemaker <j...@nospam.ct.xs4all.nl>
Date: 11 May 2008 07:57:27 GMT
Local: Sun, May 11 2008 3:57 am
Subject: Re: prolog reading a file the ISO style
On 2008-05-10, levili...@gmail.com <levili...@gmail.com> wrote:

But you started with ISO style.  The typical loop using read/2 is:

process(File) :-
        open(File, read, In),
        read(In, Term1),
        process_stream(Term1, In),
        close(In).

process_stream(end_of_file, _) :- !.
process_stream(Term, In) :-
        <do something with Term>
        read(In, Term2),
        process_stream(Term2, In).

ISO says nothing on how files are specified, though most systems accept
a (quoted) atom holding the filename. Generally they accept OS native
syntax, which means in Windows you need 'C:\\Program Files\\...'. Often
they also accept the POSIX / syntax as a portable syntax.

        Cheers --- Jan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
levilista@gmail.com  
View profile  
 More options May 16 2008, 8:53 am
Newsgroups: comp.lang.prolog
From: "levili...@gmail.com" <levili...@gmail.com>
Date: Fri, 16 May 2008 05:53:43 -0700 (PDT)
Local: Fri, May 16 2008 8:53 am
Subject: Re: prolog reading a file the ISO style
On May 11, 9:57 am, Jan Wielemaker <j...@nospam.ct.xs4all.nl> wrote:

Thank you.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »