src/argparse/macrohelp

    Dark Mode
Search:
Group by:

Types

UnfinishedCase = object
  root*: NimNode
  cases*: seq[NimNode]
  elsebody*: NimNode
UnfinishedObjectTypeDef = object
  root*: NimNode
  insertion*: NimNode

Consts

ident = ident
newIdentNode = newIdentNode

Procs

proc add(n: ref UnfinishedCase; opt: int; body: NimNode) {....raises: [], tags: [].}
Adds an integer branch to an UnfinishedCase
proc add(n: ref UnfinishedCase; opt: NimNode; body: NimNode) {....raises: [],
    tags: [].}
Adds a branch to an UnfinishedCase
proc add(n: ref UnfinishedCase; opt: seq[NimNode]; body: NimNode) {....raises: [],
    tags: [].}
Adds a branch to an UnfinishedCase
Usage:
var c = newCaseStatement("foo")
c.add(@[newLit("apple"), newLit("banana")], quote do:
echo "apple or banana"

)

proc add(n: ref UnfinishedCase; opt: string; body: NimNode) {....raises: [],
    tags: [].}
Adds a branch to an UnfinishedCase
c.add("foo", quote do:
echo "value was foo"

)

proc add(n: ref UnfinishedCase; opts: seq[string]; body: NimNode) {....raises: [],
    tags: [].}
Adds a branch to an UnfinishedCase
c.add(@["foo", "foo-also"], quote do:
echo "value was foo"

)

proc add(n: ref UnfinishedIf; cond: NimNode; body: NimNode) {....raises: [],
    tags: [].}

Add a branch to an if statement

var f = newIfStatement() f.add()

proc addElse(n: ref UnfinishedCase; body: NimNode) {....raises: [], tags: [].}
Add an else: to an UnfinishedCase
proc addElse(n: ref UnfinishedIf; body: NimNode) {....raises: [], tags: [].}
Add an else: to an UnfinishedIf
proc addObjectField(objtypedef: UnfinishedObjectTypeDef; name: string;
                    kind: NimNode) {.compileTime, ...raises: [], tags: [].}
Adds a field to an object definition created by newObjectTypeDef
proc addObjectField(objtypedef: UnfinishedObjectTypeDef; name: string;
                    kind: string; isref: bool = false) {.compileTime,
    ...raises: [], tags: [].}
Adds a field to an object definition created by newObjectTypeDef
proc clear(point: InsertionPoint): int {....raises: [], tags: [].}
proc finalize(n: ref UnfinishedCase): NimNode {....raises: [], tags: [].}
proc finalize(n: ref UnfinishedIf): NimNode {....raises: [], tags: [].}
Finish an If statement
proc getInsertionPoint(node: var NimNode; name: string): InsertionPoint {.
    ...raises: [], tags: [].}
Return a node pair that you can replace with something else
proc hasElse(n: ref UnfinishedCase): bool {....raises: [], tags: [].}
proc isValid(n: ref UnfinishedCase): bool {....raises: [], tags: [].}
proc isValid(n: ref UnfinishedIf): bool {....raises: [], tags: [].}
proc newCaseStatement(key: NimNode): ref UnfinishedCase {....raises: [], tags: [].}

Create a new, unfinished case statement. Call finalize to finish it.

case(key)

proc newCaseStatement(key: string): ref UnfinishedCase {....raises: [], tags: [].}
proc newIfStatement(): ref UnfinishedIf {....raises: [], tags: [].}
Create an unfinished if statement.
proc newObjectTypeDef(name: string; isref: bool = false): UnfinishedObjectTypeDef {.
    compileTime, ...raises: [], tags: [].}
Creates:
root ->
type
{name} = object

insertion -> ...

proc nimRepr(n: NimNode): string {....raises: [ValueError], tags: [].}
proc parentOf(node: NimNode; child: NimNode): InsertionPoint {....raises: [],
    tags: [].}
Recursively search for an ident node of the given name and return the parent of that node.
proc parentOf(node: NimNode; name: string): InsertionPoint {....raises: [],
    tags: [].}
Recursively search for an ident node of the given name and return the parent of that node.
proc replace(point: InsertionPoint; newnode: NimNode) {....raises: [], tags: [].}
Replace the child
proc replaceNodes(ast: NimNode): NimNode {....raises: [], tags: [].}

Replace NimIdent and NimSym by a fresh ident node

Use with the results of quote do: ... to get ASTs without symbol resolution having been done already.