Subject: Re: [SWIPL] DCG rules and error reporting

From: "tim menzies" <[email-masked]>
Date: Tue, 9 Oct 2001 09:01:54 -0700

in swi prolog, the predicate here/2 will return the name and line numebr of
the current file being read.

here(File,Line) :-
 source_location(Path,Line),
 file_base_name(Path,File).

----- Original Message -----
From: "Lyosha" <[email-masked]>
To: <[email-masked]>
Sent: Tuesday, October 09, 2001 3:57 AM
Subject: [SWIPL] DCG rules and error reporting

> Hi,
>
> I have a question about parsing with DCG rules.
> Maybe someone can suggest me a solution. I know
> it's something simple, but I just can't see it.
>
> I use DCG rules in my parser. Is there a way to implement
> error reporting mechanism refering to lines in the source stream?
> I want my parser to point me at the specific line where the error
> happened.
>
> For example, I could define:
> newline --> "\n".
> and put a counter for lines in there, but it won't work with
> combination of rollback and cut that I use in my other DCG rules.
>
> Thanks,
> Lyosha
>
>
> ----------------
> * To UNSUBSCRIBE, please use the HTML form at
>
>     http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist
>
> or send mail to [email-masked] using the Subject:
"unsubscribe"
> (without the quotes) and *no* message body.
>
> ** An ARCHIVE of this list is maintained at
>
>     http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/
>
>