experimental/sexp_parse

  Source   Edit

Note: Import experimental/sexp_parse to use this module

Types

SexpError = enum
  errNone,                  ## no error
  errInvalidToken,          ## invalid token
  errParensRiExpected,      ## ``)`` expected
  errQuoteExpected,         ## ``"`` expected
  errEofExpected             ## EOF expected
enumeration that lists all errors that can occur   Source   Edit
SexpEventKind = enum
  sexpError,                ## an error occurred during parsing
  sexpEof,                  ## end of file reached
  sexpString,               ## a string literal
  sexpSymbol,               ## a symbol
  sexpKeyword,              ## `:keyword` event
  sexpInt,                  ## an integer literal
  sexpFloat,                ## a float literal
  sexpNil,                  ## the value ``nil``
  sexpDot,                  ## the dot to separate car/cdr
  sexpListStart,            ## start of a list: the ``(`` token
  sexpListEnd                ## end of a list: the ``)`` token
enumeration of all events that may occur when parsing   Source   Edit
SexpParser = object of BaseLexer
  str: string
  tok: TTokKind              ## Current token that lexer has processed
  kind: SexpEventKind
  err: SexpError
the parser object.   Source   Edit
TTokKind = enum
  tkError, tkEof, tkString, tkSymbol, tkKeyword, tkInt, tkFloat, tkNil, tkDot,
  tkParensLe, tkParensRi, tkSpace
  Source   Edit

Procs

proc captureCurrString(p: var SexpParser): string {....raises: [], tags: [].}
  Source   Edit
proc close(parser: var SexpParser) {.inline,
                                     ...raises: [Exception, IOError, OSError],
                                     tags: [WriteIOEffect].}
closes the parser parser and its associated input stream.   Source   Edit
func currString(p: SexpParser): string {.inline, ...raises: [], tags: [].}
the last string that was parsed   Source   Edit
func currToken(p: SexpParser): TTokKind {.inline, ...raises: [], tags: [].}
the last token that was parsed   Source   Edit
func error(p: SexpParser): SexpError {.inline, ...raises: [], tags: [].}
most recent error kind   Source   Edit
proc getColumn(parser: SexpParser): int {.inline, ...raises: [], tags: [].}
get the current column the parser has arrived at.   Source   Edit
proc getFloat(parser: SexpParser): float {.inline, ...raises: [ValueError],
    tags: [].}
returns the number for the event: sexpFloat   Source   Edit
proc getInt(parser: SexpParser): BiggestInt {.inline, ...raises: [ValueError],
    tags: [].}
returns the number for the event: sexpInt   Source   Edit
proc getLine(parser: SexpParser): int {.inline, ...raises: [], tags: [].}
get the current line the parser has arrived at.   Source   Edit
proc getTok(parser: var SexpParser): TTokKind {....raises: [IOError, OSError],
    tags: [ReadIOEffect].}
  Source   Edit
func isTok(p: SexpParser; tok: TTokKind): bool {.inline, ...raises: [], tags: [].}
  Source   Edit
proc kind(parser: SexpParser): SexpEventKind {.inline, ...raises: [], tags: [].}
returns the current event type for the SEXP parser   Source   Edit
proc open(parser: var SexpParser; input: Stream) {....raises: [IOError, OSError],
    tags: [ReadIOEffect].}
initializes the parser with an input stream.   Source   Edit
proc space(p: var SexpParser) {....raises: [IOError, OSError], tags: [ReadIOEffect].}
Skip all space tokens from the current point onwards   Source   Edit
proc str(parser: SexpParser): string {.inline, ...raises: [], tags: [].}
returns the character data for the events: sexpInt, sexpFloat, sexpString   Source   Edit