[m-users.] Understanding string literals and name tokens

Xiaofeng Yang n.akr.akiiya at gmail.com
Sun Dec 14 23:15:00 AEDT 2014

I've read some code in lexer.m (if this is the correct code that I should
read) not so carefully, and found something I may misunderstand. Whereas,
any help or comments is appreciated.

     Best regards,
Xiaofeng Yang

2014-12-13 22:31 GMT+08:00 Xiaofeng Yang <n.akr.akiiya at gmail.com>:
> Hi, all
> I have confused by the Mercury Reference Manual (14.01.1). I found it
> seems not so up-to-date with the implementation. Now I have some questions
> about string literals and name tokens need to be helped.
> Do the differences between a string literal and a quoted name is only
>     * quoted by single/double quotes
>     * '' can appears in a quoted name (but not a string literal), whereas
> "" can appears in a string literal (but not a quoted name)
> ?
​It seems to be Yes, right ?​

> I found some usage not be mentioned in the refman, e.g.
> I write "\\" but it interpreted as \\, this is not mentioned.

​This is a mistake I made in my proof-the-concept code. I use io.write not
io.write_string so that the printed string is quoted. Sorry.​

I write "\" but it errors while compiling, so how the backslash works?
> I write "\143\" and it is interpreted as "c", this is what mentioned in
> refman 2.3. But I write "\143" is also interpreted as "c", whereas "\43"
> will interpreted as "#", these are what not mentioned in the refman.

​\143 and \43 is​ a bug of the lexer. But for compatibility with NU-Prolog,
this bug is leaving there. Right ?

> I found the max value for the rule "\x....\" is \xfffff\, and the max
> value for the rule "\....\" is \x777777\, this is what not mentioned in the
> refman.

​The actual max value is \x10ffff\ and \4177777\. ​The value should not
greater than 0x10ffff. This is not mentioned in the refman (the refman only
specifies 0x10ffff at the paragraph which introduces \u and \U). Right ?

> Do I miss something ? Or really not mentioned ? Or something I
> misunderstand ? How can I understand all the syntax rules? Any resource I
> could read? I'm doing some work on parsing Mercury code now (using some
> lexer/parser generator), so, understanding all the syntax rules correctly
> is the most important thing.
> Any help appreciated.
>      Best regards,
> Xiaofeng Yang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20141214/03127c3a/attachment.html>

More information about the users mailing list