src/regex/scanner

Types

Scanner[T] = ref object
  raw*: string
  s*: seq[T]
  pos*: int
A scanner is a common construct for reading data

Procs

func curr[T](sc: Scanner[T]): T
func find(sc: Scanner[Rune]; r: Rune): int {....raises: [], tags: [].}
return number of consumed chars. The scanner's position is not moved. -1 is returned when char is not found
func finished[T](sc: Scanner[T]): bool
proc newScanner[T](s: seq[T]): Scanner[T]
func next[T](sc: Scanner[T]): T
return current item and consume it
func peek(sc: Scanner[Node]): Node {....raises: [], tags: [].}
func peek(sc: Scanner[Rune]): Rune {....raises: [], tags: [].}
func peek(sc: Scanner[Rune]; n: int): Rune {....raises: [], tags: [].}
func prev[T](sc: Scanner[T]): T
proc scan(raw: string; bytesMode = false): Scanner[Rune] {....raises: [], tags: [].}
proc scan[T](s: seq[T]): Scanner[T]

Iterators

iterator items[T](sc: Scanner[T]): T
the yielded item gets consumed
iterator mitems[T](sc: var Scanner[T]): var T
the yielded item gets consumed
iterator peek[T](sc: Scanner[T]): (T, T)