summary refs log tree commit diff stats
path: root/tests/accept/compile
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.comy>2011-09-05 15:56:02 +0300
committerZahary Karadjov <zahary@gmail.comy>2011-09-20 14:13:45 +0300
commitd541815e4b61b8378ed79af642cc2e0f3b4e09df (patch)
tree0bbb99e90fa72efb49d67424550d1ed215134114 /tests/accept/compile
parentdaa2c8732d0f4feef20f68e75e9c491e95b95a0d (diff)
downloadNim-d541815e4b61b8378ed79af642cc2e0f3b4e09df.tar.gz
Added AST introspection routines as a part of the standard library
Diffstat (limited to 'tests/accept/compile')
-rwxr-xr-xtests/accept/compile/tdumpast.nim23
1 files changed, 3 insertions, 20 deletions
diff --git a/tests/accept/compile/tdumpast.nim b/tests/accept/compile/tdumpast.nim
index fb31af0ec..a56438773 100755
--- a/tests/accept/compile/tdumpast.nim
+++ b/tests/accept/compile/tdumpast.nim
@@ -1,29 +1,12 @@
 # Dump the contents of a PNimrodNode
 
 import macros
-
-proc dumpit(n: PNimrodNode): string {.compileTime.} = 
-  if n == nil: return "nil"
-  result = $n.kind
-  add(result, "(")
-  case n.kind
-  of nnkEmpty: nil # same as nil node in this representation 
-  of nnkNilLit:                  add(result, "nil")
-  of nnkCharLit..nnkInt64Lit:    add(result, $n.intVal)
-  of nnkFloatLit..nnkFloat64Lit: add(result, $n.floatVal)
-  of nnkStrLit..nnkTripleStrLit: add(result, $n.strVal)
-  of nnkIdent:                   add(result, $n.ident)
-  of nnkSym, nnkNone:            assert false
-  else:
-    add(result, dumpit(n[0]))
-    for j in 1..n.len-1:
-      add(result, ", ")
-      add(result, dumpit(n[j]))
-  add(result, ")")
   
 macro dumpAST(n: stmt): stmt = 
   # dump AST as a side-effect and return the inner node
-  echo dumpit(n)
+  echo n.prettyPrint
+  echo n.toYaml
+
   result = n[1]
   
 dumpAST:
I module finished' href='/ahoang/Nim/commit/lib/pure/smtp.nim?h=devel&id=1dd9ec85b28335baae23d1e8d7bdb00a74c16cbf'>1dd9ec85b ^
d68782cd3 ^
1dd9ec85b ^

d68782cd3 ^


1dd9ec85b ^



d68782cd3 ^
1dd9ec85b ^
d68782cd3 ^
fa111b906 ^
d68782cd3 ^
1dd9ec85b ^
d68782cd3 ^




1dd9ec85b ^

d68782cd3 ^
1dd9ec85b ^
d68782cd3 ^




1dd9ec85b ^

d68782cd3 ^




beb9e3d32 ^
d68782cd3 ^

1dd9ec85b ^
d68782cd3 ^







1dd9ec85b ^

d68782cd3 ^
2f066395b ^
d68782cd3 ^




1dd9ec85b ^






d68782cd3 ^






1dd9ec85b ^

d68782cd3 ^










4922b52de ^

d68782cd3 ^
1dd9ec85b ^

d68782cd3 ^












2f066395b ^


d68782cd3 ^
8733886e5 ^



d68782cd3 ^
1dd9ec85b ^

d68782cd3 ^








1dd9ec85b ^

d68782cd3 ^






1dd9ec85b ^
5b96eaa95 ^
d68782cd3 ^



1dd9ec85b ^
d68782cd3 ^




1dd9ec85b ^

d68782cd3 ^


4922b52de ^

d68782cd3 ^





4922b52de ^


d68782cd3 ^



4922b52de ^

2f066395b ^
d68782cd3 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206