@@ -547,9 +547,9 @@ func readDigits(source: Source, start: Int, firstCode: UInt8) throws -> Int {
547547 * augmented to support blockstrings """ """ and return `.blockString` token if found.
548548 */
549549func readString( source: Source , start: Int , line: Int , col: Int , prev: Token ) throws -> Token {
550- let token = try readRawString ( source: source, start: start, line: line, col: col, prev: prev)
550+ let ( token, isBlockString ) = try readRawString ( source: source, start: start, line: line, col: col, prev: prev)
551551
552- if token . kind == . blockString ,
552+ if isBlockString ,
553553 let rawString = token. value {
554554 let valueString = blockStringValue ( rawValue: rawString)
555555 return Token ( kind: token. kind,
@@ -569,9 +569,9 @@ func readString(source: Source, start: Int, line: Int, col: Int, prev: Token) th
569569 * Doesn't do any clean up of leading indentations or trailing whitespace for blockstring lines;
570570 * so if `token.kind` == `.blockString`, call `blockStringValue` with `token.value` for that.
571571 *
572- * returns: Token of kind `.string` or `.blockString`
572+ * returns: tuple of Token of kind `.string and Bool of true if it was a block string or not
573573 */
574- func readRawString( source: Source , start: Int , line: Int , col: Int , prev: Token ) throws -> Token {
574+ func readRawString( source: Source , start: Int , line: Int , col: Int , prev: Token ) throws -> ( token : Token , isBlockString : Bool ) {
575575 let body = source. body
576576 var positionIndex = body. utf8. index ( body. utf8. startIndex, offsetBy: start + 1 )
577577 var chunkStartIndex = positionIndex
@@ -586,7 +586,7 @@ func readRawString(source: Source, start: Int, line: Int, col: Int, prev: Token)
586586 body. charCode ( at: body. utf8. index ( after: positionIndex) ) == 34 {
587587 blockString = true
588588 positionIndex = body. utf8. index ( positionIndex, offsetBy: 2 )
589-
589+
590590 // if the first character after the """ is a newline, then it is not included in the value
591591 if let code = body. charCode ( at: positionIndex) ,
592592 ( code == 0x000A || code == 0x000D ) {
@@ -705,14 +705,15 @@ func readRawString(source: Source, start: Int, line: Int, col: Int, prev: Token)
705705 } else {
706706 value += String ( body. utf8 [ chunkStartIndex ..< positionIndex] ) !
707707 }
708-
709- return Token ( kind: blockString ? . blockString : . string,
710- start: start,
711- end: body. offset ( of: positionIndex) + 1 ,
712- line: line,
713- column: col,
714- value: value,
715- prev: prev)
708+
709+ return ( token: Token ( kind: . string,
710+ start: start,
711+ end: body. offset ( of: positionIndex) + 1 ,
712+ line: line,
713+ column: col,
714+ value: value,
715+ prev: prev) ,
716+ isBlockString: blockString)
716717}
717718
718719/**
0 commit comments