Skip to content

Commit

Permalink
$ to print Node ast
Browse files Browse the repository at this point in the history
Signed-off-by: George Lemon <[email protected]>
  • Loading branch information
georgelemon committed Aug 4, 2023
1 parent d336f30 commit 785c98b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/bropkg/engine/ast.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export critbits

when not defined release:
import std/jsonutils
else:
import pkg/jsony

type
NodeType* = enum
Expand Down Expand Up @@ -273,10 +275,11 @@ proc newBool*(bVal: bool): Node
proc call*(node: Node, scope: ScopeTable): Node
proc walkAccessorStorage*(node: Node, index: Node, scope: ScopeTable): Node

when not defined release:
proc `$`*(node: Node): string =
# print nodes while in dev mode
result = pretty(toJson(node), 2)
proc `$`*(node: Node): string =
when not defined release:
pretty(toJson(node), 2)
else:
toJson(node)

proc prefixed*(tk: TokenTuple): string =
result = case tk.kind
Expand Down

0 comments on commit 785c98b

Please sign in to comment.