equal
deleted
inserted
replaced
207 extends input.Position |
207 extends input.Position |
208 { |
208 { |
209 def column = 0 |
209 def column = 0 |
210 def lineContents = "" |
210 def lineContents = "" |
211 |
211 |
212 def advance(token: Token): Pos = |
212 def advance(token: Token): Pos = advance(token.source) |
|
213 def advance(source: String): Pos = |
213 { |
214 { |
214 var line1 = line |
215 var line1 = line |
215 var offset1 = offset |
216 var offset1 = offset |
216 for (s <- Symbol.iterator(token.source)) { |
217 for (s <- Symbol.iterator(source)) { |
217 if (line1 > 0 && Symbol.is_newline(s)) line1 += 1 |
218 if (line1 > 0 && Symbol.is_newline(s)) line1 += 1 |
218 if (offset1 > 0) offset1 += 1 |
219 if (offset1 > 0) offset1 += 1 |
219 } |
220 } |
220 if (line1 == line && offset1 == offset) this |
221 if (line1 == line && offset1 == offset) this |
221 else new Pos(line1, offset1, file, id) |
222 else new Pos(line1, offset1, file, id) |
228 (if (file != "") Position.File(file) else Nil) ::: |
229 (if (file != "") Position.File(file) else Nil) ::: |
229 (if (id != "") Position.Id_String(id) else Nil) |
230 (if (id != "") Position.Id_String(id) else Nil) |
230 |
231 |
231 def position(): Position.T = position(0) |
232 def position(): Position.T = position(0) |
232 def position(token: Token): Position.T = position(advance(token).offset) |
233 def position(token: Token): Position.T = position(advance(token).offset) |
|
234 def position(source: String): Position.T = position(advance(source).offset) |
233 |
235 |
234 override def toString: String = Position.here(position(), delimited = false) |
236 override def toString: String = Position.here(position(), delimited = false) |
235 } |
237 } |
236 |
238 |
237 abstract class Reader extends input.Reader[Token] |
239 abstract class Reader extends input.Reader[Token] |