Literal quote character causes exception.

View: New views
5 Messages — Rating Filter:   Alert me  

Literal quote character causes exception.

by Nicolas Pelletier-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I found the following behaviour both in GNU Prolog 1.3.1 and GNU
Prolog 20090310, which I believe is incorrect:

nicolas@tamago:~/tmp$ gprolog
GNU Prolog 1.3.2
By Daniel Diaz
Copyright (C) 1999-2009 Daniel Diaz
| ?- X = 0''.
uncaught exception: error(syntax_error('user_input:1 (char:8) quote
character expected here'),read_term/3)

I expected the substitution X = 39 as the result of my query. Would
you please look into this problem ?

Thanks in advance.

--
Nicolas


_______________________________________________
Bug-prolog mailing list
Bug-prolog@...
http://lists.gnu.org/mailman/listinfo/bug-prolog

Re: Literal quote character causes exception.

by Daniel Diaz-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for this bug report.

Will be fixed

Daniel

Nicolas Pelletier wrote:

> Hello,
>
> I found the following behaviour both in GNU Prolog 1.3.1 and GNU
> Prolog 20090310, which I believe is incorrect:
>
> nicolas@tamago:~/tmp$ gprolog
> GNU Prolog 1.3.2
> By Daniel Diaz
> Copyright (C) 1999-2009 Daniel Diaz
> | ?- X = 0''.
> uncaught exception: error(syntax_error('user_input:1 (char:8) quote
> character expected here'),read_term/3)
>
> I expected the substitution X = 39 as the result of my query. Would
> you please look into this problem ?
>
> Thanks in advance.
>
>  


--
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.



_______________________________________________
Bug-prolog mailing list
Bug-prolog@...
http://lists.gnu.org/mailman/listinfo/bug-prolog

Re: Literal quote character causes exception.

by Daniel Diaz-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Nicolas,

after looking carefully at the ISO standard, there is no bug here. ISO
says the syntax is:

0'<single quoted char>

where <single quoted char> is a character that could appear in a quoted
string. So if you want to use ' inside either you have to write it twice
('') or to escape it \'

You should use one of the valid forms: 0''' or 0'\'

I agree the result is not very nice...
In 1.3.2 I will relax the lexer to also accept 0'' (to remain compatible
with other Prolog systems).

Daniel

Daniel Diaz wrote:

> Thanks for this bug report.
>
> Will be fixed
>
> Daniel
>
> Nicolas Pelletier wrote:
>> Hello,
>>
>> I found the following behaviour both in GNU Prolog 1.3.1 and GNU
>> Prolog 20090310, which I believe is incorrect:
>>
>> nicolas@tamago:~/tmp$ gprolog
>> GNU Prolog 1.3.2
>> By Daniel Diaz
>> Copyright (C) 1999-2009 Daniel Diaz
>> | ?- X = 0''.
>> uncaught exception: error(syntax_error('user_input:1 (char:8) quote
>> character expected here'),read_term/3)
>>
>> I expected the substitution X = 39 as the result of my query. Would
>> you please look into this problem ?
>>
>> Thanks in advance.
>>
>>  
>
>


--
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.



_______________________________________________
Bug-prolog mailing list
Bug-prolog@...
http://lists.gnu.org/mailman/listinfo/bug-prolog

Re: Literal quote character causes exception.

by Nicolas Pelletier-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

On Tue, Oct 6, 2009 at 19:46, Daniel Diaz <Daniel.Diaz@...> wrote:

>
> after looking carefully at the ISO standard, there is no bug here. ISO says
> the syntax is:
>
> 0'<single quoted char>
>
> where <single quoted char> is a character that could appear in a quoted
> string. So if you want to use ' inside either you have to write it twice
> ('') or to escape it \'
>
> You should use one of the valid forms: 0''' or 0'\'

I see... Yes, on re-reading, I was wrong.

> I agree the result is not very nice...
> In 1.3.2 I will relax the lexer to also accept 0'' (to remain compatible
> with other Prolog systems).

Thank you. Compatibility is indeed how I ran into this case: Logtalk
includes in its contributions directory a XML parser, which loaded
fine when used over SWI Prolog, but failed to load when user over GNU
Prolog. Running further tests now with XSB shows there are varying
interpretations on what the standard says...

Regards,

--
Nicolas


_______________________________________________
Bug-prolog mailing list
Bug-prolog@...
http://lists.gnu.org/mailman/listinfo/bug-prolog

Re: Literal quote character causes exception.

by Paulo Moura :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 2009/10/06, at 13:18, Nicolas Pelletier wrote:

> Hello,
>
> On Tue, Oct 6, 2009 at 19:46, Daniel Diaz <Daniel.Diaz@univ-
> paris1.fr> wrote:
>>
>> after looking carefully at the ISO standard, there is no bug here.  
>> ISO says
>> the syntax is:
>>
>> 0'<single quoted char>
>>
>> where <single quoted char> is a character that could appear in a  
>> quoted
>> string. So if you want to use ' inside either you have to write it  
>> twice
>> ('') or to escape it \'
>>
>> You should use one of the valid forms: 0''' or 0'\'
>
> I see... Yes, on re-reading, I was wrong.

I don't have the standard with me right now, but I seem to remember  
that the ('') and \' is only used within quoted atoms.

>> I agree the result is not very nice...
>> In 1.3.2 I will relax the lexer to also accept 0'' (to remain  
>> compatible
>> with other Prolog systems).
>
> Thank you. Compatibility is indeed how I ran into this case: Logtalk
> includes in its contributions directory a XML parser, which loaded
> fine when used over SWI Prolog, but failed to load when user over GNU
> Prolog. Running further tests now with XSB shows there are varying
> interpretations on what the standard says...


Unfortunately, yes. Nevertheless, GNU Prolog is the first compiler I  
have found that chokes on 0''. Relaxing the lexer seems the sensible  
thing to do until the standard is clarified/rectified/updated.

Best regards,

Paulo


-----------------------------------------------------------------
Paulo Jorge Lopes de Moura, PhD
Assistant Professor
Dep. of Computer Science, University of Beira Interior
6201-001 Covilhã, Portugal

Office 3.18  Ext. 3276
Phone: +351 275319891 Fax: +351 275319899
Email: <mailto:pmoura@...>

Home page: <http://www.di.ubi.pt/~pmoura>
Research:  <http://logtalk.org/> Blog: <http://blog.logtalk.org/>
-----------------------------------------------------------------



_______________________________________________
Bug-prolog mailing list
Bug-prolog@...
http://lists.gnu.org/mailman/listinfo/bug-prolog