tpostexprblocks.nim 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. discard """
  2. nimout: '''
  3. StmtList
  4. Ident "foo010"
  5. Call
  6. Ident "foo020"
  7. Call
  8. Ident "foo030"
  9. Ident "x"
  10. Command
  11. Ident "foo040"
  12. Ident "x"
  13. Call
  14. Ident "foo050"
  15. StmtList
  16. DiscardStmt
  17. Empty
  18. Call
  19. Ident "foo060"
  20. StmtList
  21. DiscardStmt
  22. Empty
  23. Call
  24. Ident "foo070"
  25. StrLit "test"
  26. StmtList
  27. DiscardStmt
  28. Empty
  29. Call
  30. Ident "foo080"
  31. StrLit "test"
  32. StmtList
  33. DiscardStmt
  34. Empty
  35. Command
  36. Ident "foo090"
  37. StrLit "test"
  38. StmtList
  39. DiscardStmt
  40. Empty
  41. Command
  42. Ident "foo100"
  43. Call
  44. StrLit "test"
  45. StmtList
  46. DiscardStmt
  47. Empty
  48. Command
  49. Ident "foo101"
  50. Call
  51. IntLit 10
  52. StmtList
  53. DiscardStmt
  54. Empty
  55. Command
  56. Ident "foo110"
  57. IntLit 1
  58. Par
  59. Infix
  60. Ident "+"
  61. IntLit 2
  62. IntLit 3
  63. StmtList
  64. DiscardStmt
  65. Empty
  66. Command
  67. Ident "foo120"
  68. IntLit 1
  69. Call
  70. Par
  71. Infix
  72. Ident "+"
  73. IntLit 2
  74. IntLit 3
  75. StmtList
  76. DiscardStmt
  77. Empty
  78. Call
  79. Ident "foo130"
  80. Do
  81. Empty
  82. Empty
  83. Empty
  84. FormalParams
  85. Empty
  86. IdentDefs
  87. Ident "x"
  88. Empty
  89. Empty
  90. Empty
  91. Empty
  92. StmtList
  93. DiscardStmt
  94. Empty
  95. Call
  96. Ident "foo140"
  97. Do
  98. Empty
  99. Empty
  100. Empty
  101. FormalParams
  102. Empty
  103. IdentDefs
  104. Ident "x"
  105. Ident "int"
  106. Empty
  107. Empty
  108. Empty
  109. StmtList
  110. DiscardStmt
  111. Empty
  112. Call
  113. Ident "foo150"
  114. Do
  115. Empty
  116. Empty
  117. Empty
  118. FormalParams
  119. Ident "int"
  120. IdentDefs
  121. Ident "x"
  122. Ident "int"
  123. Empty
  124. Empty
  125. Empty
  126. StmtList
  127. DiscardStmt
  128. Empty
  129. Command
  130. Ident "foo160"
  131. Call
  132. Ident "x"
  133. Do
  134. Empty
  135. Empty
  136. Empty
  137. FormalParams
  138. Empty
  139. IdentDefs
  140. Ident "y"
  141. Empty
  142. Empty
  143. Empty
  144. Empty
  145. StmtList
  146. DiscardStmt
  147. Empty
  148. Call
  149. Ident "foo170"
  150. StmtList
  151. DiscardStmt
  152. Empty
  153. Else
  154. StmtList
  155. DiscardStmt
  156. Empty
  157. Call
  158. Ident "foo180"
  159. StmtList
  160. DiscardStmt
  161. Empty
  162. StmtList
  163. DiscardStmt
  164. Empty
  165. Else
  166. StmtList
  167. DiscardStmt
  168. Empty
  169. Command
  170. Ident "foo190"
  171. Call
  172. Ident "x"
  173. Do
  174. Empty
  175. Empty
  176. Empty
  177. FormalParams
  178. Empty
  179. IdentDefs
  180. Ident "y"
  181. Empty
  182. Empty
  183. Empty
  184. Empty
  185. StmtList
  186. DiscardStmt
  187. Empty
  188. Do
  189. Empty
  190. Empty
  191. Empty
  192. FormalParams
  193. Ident "int"
  194. IdentDefs
  195. Ident "z"
  196. Empty
  197. Empty
  198. Empty
  199. Empty
  200. StmtList
  201. DiscardStmt
  202. Empty
  203. Do
  204. Empty
  205. Empty
  206. Empty
  207. FormalParams
  208. Ident "int"
  209. IdentDefs
  210. Ident "w"
  211. Ident "int"
  212. Empty
  213. Empty
  214. Empty
  215. StmtList
  216. DiscardStmt
  217. Empty
  218. StmtList
  219. DiscardStmt
  220. Empty
  221. Else
  222. StmtList
  223. DiscardStmt
  224. Empty
  225. Call
  226. Ident "foo200"
  227. Ident "x"
  228. Call
  229. Ident "bar"
  230. StmtList
  231. DiscardStmt
  232. Empty
  233. Else
  234. StmtList
  235. DiscardStmt
  236. Empty
  237. VarSection
  238. IdentDefs
  239. Ident "a"
  240. Empty
  241. Ident "foo210"
  242. VarSection
  243. IdentDefs
  244. Ident "a"
  245. Empty
  246. Call
  247. Ident "foo220"
  248. VarSection
  249. IdentDefs
  250. Ident "a"
  251. Empty
  252. Call
  253. Ident "foo230"
  254. Ident "x"
  255. VarSection
  256. IdentDefs
  257. Ident "a"
  258. Empty
  259. Command
  260. Ident "foo240"
  261. Ident "x"
  262. VarSection
  263. IdentDefs
  264. Ident "a"
  265. Empty
  266. Call
  267. Ident "foo250"
  268. StmtList
  269. DiscardStmt
  270. Empty
  271. VarSection
  272. IdentDefs
  273. Ident "a"
  274. Empty
  275. Call
  276. Ident "foo260"
  277. StmtList
  278. DiscardStmt
  279. Empty
  280. VarSection
  281. IdentDefs
  282. Ident "a"
  283. Empty
  284. Call
  285. Ident "foo270"
  286. StmtList
  287. DiscardStmt
  288. Empty
  289. Else
  290. StmtList
  291. DiscardStmt
  292. Empty
  293. VarSection
  294. IdentDefs
  295. Ident "a"
  296. Empty
  297. Command
  298. Ident "foo280"
  299. Call
  300. Ident "x"
  301. Do
  302. Empty
  303. Empty
  304. Empty
  305. FormalParams
  306. Empty
  307. IdentDefs
  308. Ident "y"
  309. Empty
  310. Empty
  311. Empty
  312. Empty
  313. StmtList
  314. DiscardStmt
  315. Empty
  316. Else
  317. StmtList
  318. DiscardStmt
  319. Empty
  320. Asgn
  321. Ident "a"
  322. Ident "foo290"
  323. Asgn
  324. Ident "a"
  325. Call
  326. Ident "foo300"
  327. Asgn
  328. Ident "a"
  329. Call
  330. Ident "foo310"
  331. Ident "x"
  332. Asgn
  333. Ident "a"
  334. Command
  335. Ident "foo320"
  336. Ident "x"
  337. Asgn
  338. Ident "a"
  339. Call
  340. Ident "foo330"
  341. StmtList
  342. DiscardStmt
  343. Empty
  344. Asgn
  345. Ident "a"
  346. Call
  347. Ident "foo340"
  348. StmtList
  349. DiscardStmt
  350. Empty
  351. Asgn
  352. Ident "a"
  353. Call
  354. Ident "foo350"
  355. StmtList
  356. DiscardStmt
  357. Empty
  358. Else
  359. StmtList
  360. DiscardStmt
  361. Empty
  362. Asgn
  363. Ident "a"
  364. Command
  365. Ident "foo360"
  366. Call
  367. DotExpr
  368. Ident "x"
  369. Ident "bar"
  370. Do
  371. Empty
  372. Empty
  373. Empty
  374. FormalParams
  375. Empty
  376. IdentDefs
  377. Ident "y"
  378. Empty
  379. Empty
  380. Empty
  381. Empty
  382. StmtList
  383. DiscardStmt
  384. Empty
  385. Else
  386. StmtList
  387. DiscardStmt
  388. Empty
  389. Command
  390. DotExpr
  391. Ident "foo370"
  392. Ident "add"
  393. Call
  394. Ident "quote"
  395. StmtList
  396. DiscardStmt
  397. Empty
  398. Call
  399. DotExpr
  400. Ident "foo380"
  401. Ident "add"
  402. BracketExpr
  403. Call
  404. Ident "quote"
  405. StmtList
  406. DiscardStmt
  407. Empty
  408. IntLit 0
  409. '''
  410. """
  411. import macros
  412. dumpTree:
  413. # simple calls
  414. foo010
  415. foo020()
  416. foo030(x)
  417. foo040 x
  418. foo050:
  419. discard
  420. foo060 do:
  421. discard
  422. foo070("test"):
  423. discard
  424. foo080("test") do:
  425. discard
  426. foo090 "test":
  427. discard
  428. foo100 "test" do:
  429. discard
  430. foo101 10 do:
  431. discard
  432. # more complicated calls
  433. foo110 1, (2+3):
  434. discard
  435. foo120 1, (2+3) do:
  436. discard
  437. foo130 do (x):
  438. discard
  439. foo140 do (x: int):
  440. discard
  441. foo150 do (x: int) -> int:
  442. discard
  443. foo160 x do (y):
  444. discard
  445. # extra blocks
  446. foo170:
  447. discard
  448. else:
  449. discard
  450. foo180 do:
  451. discard
  452. do:
  453. discard
  454. else:
  455. discard
  456. foo190 x do (y):
  457. discard
  458. do (z) -> int:
  459. discard
  460. do (w: int) -> int:
  461. discard
  462. do:
  463. discard
  464. else:
  465. discard
  466. # call with blocks as a param
  467. foo200(x, bar do:
  468. discard
  469. else:
  470. discard
  471. )
  472. # introduce a variable
  473. var a = foo210
  474. var a = foo220()
  475. var a = foo230(x)
  476. var a = foo240 x
  477. var a = foo250:
  478. discard
  479. var a = foo260 do:
  480. discard
  481. var a = foo270 do:
  482. discard
  483. else:
  484. discard
  485. var a = foo280 x do (y):
  486. discard
  487. else:
  488. discard
  489. # assignments
  490. a = foo290
  491. a = foo300()
  492. a = foo310(x)
  493. a = foo320 x
  494. a = foo330:
  495. discard
  496. a = foo340 do:
  497. discard
  498. a = foo350 do:
  499. discard
  500. else:
  501. discard
  502. a = foo360 x.bar do (y):
  503. discard
  504. else:
  505. discard
  506. foo370.add quote do:
  507. discard
  508. # some edge cases
  509. foo380.add((quote do:
  510. discard
  511. )[0])