[swift-evolution] multi-line string literals.

L Mihalkovic laurent.mihalkovic at gmail.com
Fri May 6 12:13:48 CDT 2016


As I (believe I) start to understand the parser, I somehow think that doing something like the following would 
not violate (not take too much risk) the current Lexer/Parser
be somewhat reasonable to implement
address many of the reqs I read 
leave some infrastructure in the Lexer/Parser to add more feature without needing to go back to square 0 next time

Any thoughts?!


#!/usr/bin/env xcrun swift

let s1 = "{\"key1\": \"stringValue\"}"

let s2 = _"{"key1": "stringValue"}"_

let s3 =
    /* this is the same template */
    _"{"key1": "stringValue"}"_

let s4 =
/* this is (almost) the same template */
_"
{
  "key1": "stringValue"
  , "key2": "stringValue"
}
"_

let s5 = @literal(json)
  /* this is exactly the same template as s4 */
  _"
  {
    "key1": "stringValue"
    , "key2": "stringValue"
  }
  "_

let s6 = @literal(json)
  /* this is exactly the same template as s5&s4 */
  _"
  |{
  |  "key1": "stringValue"
  |  , "key2": "stringValue"
  |}
  "_

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160506/7384c26a/attachment.html>


More information about the swift-evolution mailing list