- From: Dave Beckett <dave.beckett@bristol.ac.uk>
- Date: Fri, 25 Feb 2005 09:56:18 +0000
- To: Graham Klyne <GK-lists@ninebynine.org>
- Cc: public-cwm-talk@w3.org
On Tue, 2005-02-22 at 11:09 +0000, Graham Klyne wrote: > FWIW, here is the triple-quote string parser from the Notation3 parser in > my Swish implementation. I don't recall if this came from any formal spec > but I think it reasonably matches a range of actual data. Within the > string, it allows: > stringLetter (non-control, non-", non-\) > escape (\c, \uxxxx, \Uxxxxxxxx) > " followed by non-" > "" followed by non-" > newline (\n) Uhoh. This is the kind of thing I was worrying about. I wasn't sure if \-escapes would be allowed in """...""" especially the unicode chars ones \u and \U - those are the ones I can see good justification for. I've never heard of \c. > [[ > -- Triple-quoted string -- may include line breaks, '"' or '""'. ... > -- \c > charEsc = choice (map parseEsc escMap) > where > parseEsc (c,code) = do { char c; return code } > escMap = zip ("nrt\\\"\'") ("\n\r\t\\\"\'") ... I can't decode what that means but is it allowing \n \r \r \\ \" and \' ? Somehow this seems to defeat the purpose of triple-quotes as delimiting a verbatim string, if that's what I understood it to be. However it seems I was wrong, at least for python: [[In triple-quoted strings, unescaped newlines and quotes are allowed (and are retained), except that three unescaped quotes in a row terminate the string. (A ``quote'' is the character used to open the string, i.e. either ' or " ]] -- http://www.python.org/doc/2.4/ref/strings.html and that's the only difference from a single-quoted string. So Turtle should follow the same rule; same as single-quoted string however unescaped newlines and quotes are retained. Unless N3 does something different and is implemented that way. Dave
Received on Friday, 25 February 2005 09:56:56 UTC