# Module lexbase

This module implements a base object of a lexer with efficient buffer handling. Only at line endings checks are necessary if the buffer needs refilling.

# Imports

strutils, streams

# Types

    TBaseLexer = object of TObject
      bufpos*: int                ## the current position within the buffer
      buf*: cstring               ## the buffer itself
      bufLen*: int                ## length of buffer in characters
      input: PStream              ## the input stream
      LineNumber*: int            ## the current line number
      sentinel: int
      lineStart: int
      fileOpened: bool

  the base lexer. Inherit your lexer from this object.

# Consts

    EndOfFile = '\0'

  end of file marker

    NewLines = {'\x0D', '\x0A'}

# Procs

    proc close(L: var TBaseLexer) {.raises: [E_Base], tags: [].}

  closes the base lexer. This closes L's associated stream too.

    proc HandleCR(L: var TBaseLexer; pos: int): int {.raises: [E_Base],
        tags: [FReadIO].}

  Call this if you scanned over 'c' in the buffer; it returns the the position to continue the scanning from. pos must be the position of the 'c'.

    proc HandleLF(L: var TBaseLexer; pos: int): int {.raises: [E_Base],
        tags: [FReadIO].}

  Call this if you scanned over 'L' in the buffer; it returns the the position to continue the scanning from. pos must be the position of the 'L'.

    proc open(L: var TBaseLexer; input: PStream; bufLen: int = 8192) {.
        raises: [E_Base], tags: [FReadIO].}

  inits the TBaseLexer with a stream to read from

    proc getColNumber(L: TBaseLexer; pos: int): int {.raises: [], tags: [].}

  retrieves the current column.

    proc getCurrentLine(L: TBaseLexer; marker: bool = true): string {.raises: [],
        tags: [].}

  retrieves the current line.

Generated: 2013-05-21 09:55:10 UTC