renderer

Imports

lexer, options, idents, ast, msgs, lineinfos

Types

TRenderFlag = enum
  renderNone, renderNoBody, renderNoComments, renderDocComments,
  renderNoPragmas, renderIds, renderNoProcDefs, renderSyms,
  renderRunnableExamples, renderIr
Source Edit
TRenderFlags = set[TRenderFlag]
Source Edit
TRenderTok = object
  kind*: TokType
  length*: int16
  sym*: PSym
Source Edit
TRenderTokSeq = seq[TRenderTok]
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
  when defined(nimpretty):
      pendingNewlineCount: int

  fid*: FileIndex
  config*: ConfigRef
  mangler: seq[PSym]
Source Edit

Procs

proc isKeyword(i: PIdent): bool {...}{.raises: [], tags: [].}
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 bracketKind(g: TSrcGen; n: PNode): BracketKind {...}{.raises: [], tags: [].}
Source Edit
proc renderTree(n: PNode; renderFlags: TRenderFlags = {}): string {...}{.
    raises: [Exception], tags: [RootEffect].}
Source Edit
proc `$`(n: PNode): string {...}{.raises: [Exception], tags: [RootEffect].}
Source Edit
proc renderModule(n: PNode; infile, outfile: string;
                  renderFlags: TRenderFlags = {}; fid = FileIndex(-1);
                  conf: ConfigRef = nil) {...}{.
    raises: [Exception, IOError, ValueError, ERecoverableError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect].}
Source Edit
proc initTokRender(r: var TSrcGen; n: PNode; renderFlags: TRenderFlags = {}) {...}{.
    raises: [Exception], tags: [RootEffect].}
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 quoteExpr(a: string): string {...}{.inline, raises: [], tags: [].}
can be used for quoting expressions in error msgs. Source Edit
proc genFieldDefect(field: PSym; disc: PSym): string {...}{.raises: [], tags: [].}
this needs to be in a module accessible by jsgen, ccgexprs, and vm to provide this error msg FieldDefect; msgs would be better but it does not import ast Source Edit

© 2006–2021 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/compiler/renderer.html