compiler/ast/renderer

  Source   Edit

This module implements the renderer of the standard Nim representation.

Types

TRenderFlag = enum
  renderNone, renderNoBody, renderNoComments, renderDocComments,
  renderNoPragmas, renderIds, renderNoProcDefs, renderSyms,
  renderRunnableExamples, renderIr, renderWithoutErrorPrefix
  Source   Edit
TRenderTok = object
  kind*: TokType
  length*: int16
  sym*: PSym
  Source   Edit
TSrcGen = object
  indent*: int
  lineLen*: int
  col: int
  pos*: int
  idx*: int
  tokens*: TRenderTokSeq
  buf*: string
  pendingNL*: int
  pendingWhitespace: int
  comStack*: seq[PNode]
  flags*: TRenderFlags
  inGenericParams: bool
  checkAnon: bool
  inPragma: int
  fid*: FileIndex
  config*: ConfigRef
  mangler: seq[PSym]
  Source   Edit

Procs

proc `$`(n: PNode): string {....raises: [Exception, KeyError], tags: [RootEffect].}
  Source   Edit
proc bracketKind(g: TSrcGen; n: PNode): BracketKind {....raises: [], tags: [].}
  Source   Edit
proc getNextTok(r: var TSrcGen; kind: var TokType; literal: var string) {.
    ...raises: [], tags: [].}
  Source   Edit
proc getTokSym(r: TSrcGen): PSym {....raises: [], tags: [].}
  Source   Edit
proc initTokRender(r: var TSrcGen; n: PNode; renderFlags: TRenderFlags = {}) {.
    ...raises: [Exception], tags: [RootEffect].}
  Source   Edit
proc renderDefinitionName(s: PSym; noQuotes = false): string {....raises: [],
    tags: [].}

Returns the definition name of the symbol.

If noQuotes is false the symbol may be returned in backticks. This will happen if the name happens to be a keyword or the first character is not part of the SymStartChars set.

  Source   Edit
proc renderModule(n: PNode; outfile: string; renderFlags: TRenderFlags = {};
                  fid = FileIndex(-1); conf: ConfigRef = nil) {.
    ...raises: [Exception, KeyError, IOError, ERecoverableError],
    tags: [RootEffect, WriteIOEffect].}
  Source   Edit
proc renderTree(n: PNode; renderFlags: TRenderFlags = {}): string {.
    ...raises: [Exception, KeyError], tags: [RootEffect].}
  Source   Edit