# 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 open*(L: var TBaseLexer; input: PStream; bufLen: int = 8192)

  inits the TBaseLexer with a stream to read from

    proc close*(L: var TBaseLexer)

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

    proc getCurrentLine*(L: TBaseLexer; marker: bool = true): string

  retrieves the current line.

    proc getColNumber*(L: TBaseLexer; pos: int): int

  retrieves the current column.

    proc HandleCR*(L: var TBaseLexer; pos: int): int

  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

  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'.

Generated: 2012-09-23 21:47:54 UTC