sexp

    Dark Mode
Search:

Note: Import nimsuggest/sexp to use this module

Types

SexpEventKind = enum
  sexpError, sexpEof, sexpString, sexpSymbol, sexpInt, sexpFloat, sexpNil,
  sexpDot, sexpListStart, sexpListEnd
enumeration of all events that may occur when parsing   Source Edit
SexpError = enum
  errNone, errInvalidToken, errParensRiExpected, errQuoteExpected,
  errEofExpected
enumeration that lists all errors that can occur   Source Edit
SexpParser = object of BaseLexer
  a: string
  tok: TTokKind
  kind: SexpEventKind
  err: SexpError
the parser object.   Source Edit
SexpNodeKind = enum
  SNil, SInt, SFloat, SString, SSymbol, SList, SCons
possible SEXP node types   Source Edit
SexpNode = ref SexpNodeObj
SEXP node   Source Edit
SexpNodeObj {...}{.acyclic.} = object
  case kind*: SexpNodeKind
  of SString:
      str*: string

  of SSymbol:
      symbol*: string

  of SInt:
      num*: BiggestInt

  of SFloat:
      fnum*: float

  of SList:
      elems*: seq[SexpNode]

  of SCons:
      car: SexpNode
      cdr: SexpNode

  of SNil:
      nil

  
  Source Edit
SexpParsingError = object of ValueError
is raised for a SEXP error   Source Edit

Procs

proc close(my: var SexpParser) {...}{.inline, raises: [Exception, IOError, OSError],
                                 tags: [WriteIOEffect].}
closes the parser my and its associated input stream.   Source Edit
proc str(my: SexpParser): string {...}{.inline, raises: [], tags: [].}
returns the character data for the events: sexpInt, sexpFloat, sexpString   Source Edit
proc getInt(my: SexpParser): BiggestInt {...}{.inline, raises: [ValueError], tags: [].}
returns the number for the event: sexpInt   Source Edit
proc getFloat(my: SexpParser): float {...}{.inline, raises: [ValueError], tags: [].}
returns the number for the event: sexpFloat   Source Edit
proc kind(my: SexpParser): SexpEventKind {...}{.inline, raises: [], tags: [].}
returns the current event type for the SEXP parser   Source Edit
proc getColumn(my: SexpParser): int {...}{.inline, raises: [], tags: [].}
get the current column the parser has arrived at.   Source Edit
proc getLine(my: SexpParser): int {...}{.inline, raises: [], tags: [].}
get the current line the parser has arrived at.   Source Edit
proc errorMsg(my: SexpParser): string {...}{.raises: [ValueError], tags: [].}
returns a helpful error message for the event sexpError   Source Edit
proc errorMsgExpected(my: SexpParser; e: string): string {...}{.raises: [ValueError],
    tags: [].}
returns an error message "e expected" in the same format as the other error messages   Source Edit
proc raiseParseErr(p: SexpParser; msg: string) {...}{.noinline, noreturn,
    raises: [SexpParsingError, ValueError], tags: [].}
raises an ESexpParsingError exception.   Source Edit
proc newSString(s: string): SexpNode {...}{.raises: [], tags: [].}
Creates a new SString SexpNode.   Source Edit
proc newSInt(n: BiggestInt): SexpNode {...}{.raises: [], tags: [].}
Creates a new SInt SexpNode.   Source Edit
proc newSFloat(n: float): SexpNode {...}{.raises: [], tags: [].}
Creates a new SFloat SexpNode.   Source Edit
proc newSNil(): SexpNode {...}{.raises: [], tags: [].}
Creates a new SNil SexpNode.   Source Edit
proc newSCons(car, cdr: SexpNode): SexpNode {...}{.raises: [], tags: [].}
Creates a new SCons SexpNode   Source Edit
proc newSList(): SexpNode {...}{.raises: [], tags: [].}
Creates a new SList SexpNode   Source Edit
proc newSSymbol(s: string): SexpNode {...}{.raises: [], tags: [].}
  Source Edit
proc getStr(n: SexpNode; default: string = ""): string {...}{.raises: [], tags: [].}

Retrieves the string value of a SString SexpNode.

Returns default if n is not a SString.

  Source Edit
proc getNum(n: SexpNode; default: BiggestInt = 0): BiggestInt {...}{.raises: [],
    tags: [].}

Retrieves the int value of a SInt SexpNode.

Returns default if n is not a SInt.

  Source Edit
proc getFNum(n: SexpNode; default: float = 0.0): float {...}{.raises: [], tags: [].}

Retrieves the float value of a SFloat SexpNode.

Returns default if n is not a SFloat.

  Source Edit
proc getSymbol(n: SexpNode; default: string = ""): string {...}{.raises: [], tags: [].}

Retrieves the int value of a SList SexpNode.

Returns default if n is not a SList.

  Source Edit
proc getElems(n: SexpNode; default: seq[SexpNode] = @[]): seq[SexpNode] {...}{.
    raises: [], tags: [].}

Retrieves the int value of a SList SexpNode.

Returns default if n is not a SList.

  Source Edit
proc getCons(n: SexpNode; defaults: Cons = (newSNil(), newSNil())): Cons {...}{.
    raises: [], tags: [].}

Retrieves the cons value of a SList SexpNode.

Returns default if n is not a SList.

  Source Edit
proc sexp(s: string): SexpNode {...}{.raises: [], tags: [].}
Generic constructor for SEXP data. Creates a new SString SexpNode.   Source Edit
proc sexp(n: BiggestInt): SexpNode {...}{.raises: [], tags: [].}
Generic constructor for SEXP data. Creates a new SInt SexpNode.   Source Edit
proc sexp(n: float): SexpNode {...}{.raises: [], tags: [].}
Generic constructor for SEXP data. Creates a new SFloat SexpNode.   Source Edit
proc sexp(b: bool): SexpNode {...}{.raises: [], tags: [].}
Generic constructor for SEXP data. Creates a new SSymbol SexpNode with value t or SNil SexpNode.   Source Edit
proc sexp(elements: openArray[SexpNode]): SexpNode {...}{.raises: [], tags: [].}
Generic constructor for SEXP data. Creates a new SList SexpNode   Source Edit
proc sexp(s: SexpNode): SexpNode {...}{.raises: [], tags: [].}
  Source Edit
proc `==`(a, b: SexpNode): bool {...}{.raises: [], tags: [].}
Check two nodes for equality   Source Edit
proc hash(n: SexpNode): Hash {...}{.raises: [], tags: [].}
Compute the hash for a SEXP node   Source Edit
proc len(n: SexpNode): int {...}{.raises: [], tags: [].}
If n is a SList, it returns the number of elements. If n is a JObject, it returns the number of pairs. Else it returns 0.   Source Edit
proc `[]`(node: SexpNode; index: int): SexpNode {...}{.raises: [], tags: [].}
Gets the node at index in a List. Result is undefined if index is out of bounds   Source Edit
proc add(father, child: SexpNode) {...}{.raises: [], tags: [].}
Adds child to a SList node father.   Source Edit
proc escapeJson(s: string): string {...}{.raises: [], tags: [].}
Converts a string s to its JSON representation.   Source Edit
proc copy(p: SexpNode): SexpNode {...}{.raises: [], tags: [].}
Performs a deep copy of a.   Source Edit
proc pretty(node: SexpNode; indent = 2): string {...}{.raises: [], tags: [].}
Converts node to its Sexp Representation, with indentation and on multiple lines.   Source Edit
proc `$`(node: SexpNode): string {...}{.raises: [], tags: [].}
Converts node to its SEXP Representation on one line.   Source Edit
proc open(my: var SexpParser; input: Stream) {...}{.raises: [IOError, OSError],
    tags: [ReadIOEffect].}
initializes the parser with an input stream.   Source Edit
proc parseSexp(s: Stream): SexpNode {...}{.raises: [IOError, OSError, ValueError,
    SexpParsingError, Exception], tags: [ReadIOEffect, WriteIOEffect].}
Parses from a buffer s into a SexpNode.   Source Edit
proc parseSexp(buffer: string): SexpNode {...}{.
    raises: [IOError, OSError, ValueError, SexpParsingError, Exception],
    tags: [ReadIOEffect, WriteIOEffect].}
Parses Sexp from buffer.   Source Edit

Iterators

iterator items(node: SexpNode): SexpNode {...}{.raises: [], tags: [].}
Iterator for the items of node. node has to be a SList.   Source Edit
iterator mitems(node: var SexpNode): var SexpNode {...}{.raises: [], tags: [].}
Iterator for the items of node. node has to be a SList. Items can be modified.   Source Edit

Macros

macro convertSexp(x: untyped): untyped
Convert an expression to a SexpNode directly, without having to specify % for every element.   Source Edit