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.

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: 2014-03-11 21:26:40 UTC