@@ -98,25 +98,25 @@ def buildRow[R] { body: => R / RowBuilder }: (R, CsvRow) = {
9898
9999def unbuild(v: CsvValue): Unit / CsvBuilder = v match {
100100 case rows => rows.foreach { row =>
101- do rows {
101+ do rows {
102102 row.foreach { cell =>
103- do cell(cell)
103+ do cell(cell)
104104 }
105105 }
106106 }
107107}
108108
109- def readUntil { shouldStop: Char => Bool }: String / Scan[Char] =
109+ def readUntil { shouldStop: Char => Bool }: String / Scan[Char] =
110110 collectString { readMany[Char] { c => not(shouldStop(c)) } }
111111
112112/// Read and unescape a string in ""
113113/// Stolen from 'json'
114114def readQuotedString(): Unit / { Scan[Char], emit[Char], Exception[WrongFormat] } = {
115115 try {
116116 expect("Expected \"") { readIf('"') }
117- while(read[Char]() is c and c != '"') {
117+ while(do read[Char]() is c and c != '"') {
118118 c match {
119- case '\\' => read[Char]() match {
119+ case '\\' => do read[Char]() match {
120120 case '"' => do emit('\"')
121121 case '\\' => do emit('\\')
122122 case '/' => do emit('/')
@@ -140,9 +140,9 @@ def decodeRow(): Unit / {Scan[Char], RowBuilder, Exception[WrongFormat]} = loop
140140 do cell(cell)
141141
142142 do peek[Char]() match {
143- case ',' => do skip[Char]()
143+ case ',' => skip[Char]()
144144 case '\n' =>
145- do skip[Char]()
145+ skip[Char]()
146146 do stop()
147147 case '"' =>
148148 do cell(collectString { readQuotedString() })
@@ -153,10 +153,10 @@ def decodeRow(): Unit / {Scan[Char], RowBuilder, Exception[WrongFormat]} = loop
153153
154154def decodeCsv(): Unit / {Scan[Char], CsvBuilder, Exception[WrongFormat]} = loop {
155155 do peek[Char]() match {
156- case '\n' =>
156+ case '\n' =>
157157 // do skip[Char]()
158158 do rows { decodeRow() } // technically could be `do rows { () }`
159- case _ =>
159+ case _ =>
160160 do rows { decodeRow() }
161161 }
162162 // QUESTION TODO: Why doesn't just this work instead of the match, huh?!
@@ -171,7 +171,7 @@ def encodeCsv[R] { csv: => R / CsvBuilder }: R / emit[String] = {
171171 }
172172
173173 try csv() with CsvBuilder {
174- def rows[R]() = resume { {row} =>
174+ def rows[R]() = resume { {row} =>
175175 sep(); encodeRow {row}
176176 }
177177 }
@@ -185,7 +185,7 @@ def encodeRow[R] { row: => R / RowBuilder }: R / emit[String] = {
185185 }
186186
187187 try row() with RowBuilder { // TODO: quoting?!
188- def cell(s) = { sep(); do emit(s); resume(()) }
188+ def cell(s) = { sep(); do emit(s); resume(()) }
189189 }
190190}
191191
@@ -250,7 +250,7 @@ def getColumnOf[R](columnName: String) { csv: => R / CsvBuilder }: R / {emit[Str
250250}
251251
252252/// Not in PR, added by myself
253- ///
253+ ///
254254/// Get multiple columns by their names
255255def getColumnsOf[R](columnNames: List[String]) { csv: => R / CsvBuilder }: R / {emit[Map[String, String]], Exception[WrongFormat]} = {
256256 with on[MissingValue].panic() // should never happen
0 commit comments