ttypemodifiers.nim 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. discard """
  2. nimout: '''
  3. StmtList
  4. TypeSection
  5. TypeDef
  6. Ident "BarePtr"
  7. Empty
  8. PtrTy
  9. TypeDef
  10. Ident "GenericPtr"
  11. Empty
  12. PtrTy
  13. Bracket
  14. Ident "int"
  15. TypeDef
  16. Ident "PrefixPtr"
  17. Empty
  18. PtrTy
  19. Ident "int"
  20. TypeDef
  21. Ident "PtrTuple"
  22. Empty
  23. PtrTy
  24. Par
  25. Ident "int"
  26. Ident "string"
  27. TypeDef
  28. Ident "BareRef"
  29. Empty
  30. RefTy
  31. TypeDef
  32. Ident "GenericRef"
  33. Empty
  34. RefTy
  35. Bracket
  36. Ident "int"
  37. TypeDef
  38. Ident "RefTupleCl"
  39. Empty
  40. RefTy
  41. TupleTy
  42. TypeDef
  43. Ident "RefTupleType"
  44. Empty
  45. RefTy
  46. Par
  47. Ident "int"
  48. Ident "string"
  49. TypeDef
  50. Ident "RefTupleVars"
  51. Empty
  52. RefTy
  53. Par
  54. Ident "a"
  55. Ident "b"
  56. TypeDef
  57. Ident "BareStatic"
  58. Empty
  59. Ident "static"
  60. TypeDef
  61. Ident "GenericStatic"
  62. Empty
  63. BracketExpr
  64. Ident "static"
  65. Ident "int"
  66. TypeDef
  67. Ident "PrefixStatic"
  68. Empty
  69. Command
  70. Ident "static"
  71. Ident "int"
  72. TypeDef
  73. Ident "StaticTupleCl"
  74. Empty
  75. Command
  76. Ident "static"
  77. TupleClassTy
  78. TypeDef
  79. Ident "StaticTuple"
  80. Empty
  81. Command
  82. Ident "static"
  83. Par
  84. Ident "int"
  85. Ident "string"
  86. TypeDef
  87. Ident "BareType"
  88. Empty
  89. Ident "type"
  90. TypeDef
  91. Ident "GenericType"
  92. Empty
  93. BracketExpr
  94. Ident "type"
  95. Ident "float"
  96. TypeDef
  97. Ident "TypeTupleGen"
  98. Empty
  99. BracketExpr
  100. Ident "type"
  101. TupleClassTy
  102. TypeDef
  103. Ident "TypeTupleCl"
  104. Empty
  105. Command
  106. Ident "type"
  107. TupleClassTy
  108. TypeDef
  109. Ident "TypeInstance"
  110. Empty
  111. Command
  112. Ident "type"
  113. BracketExpr
  114. Ident "Foo"
  115. RefTy
  116. TypeDef
  117. Ident "bareTypeDesc"
  118. Empty
  119. Ident "typedesc"
  120. TypeDef
  121. Ident "TypeOfVar"
  122. Empty
  123. Call
  124. Ident "type"
  125. Ident "a"
  126. TypeDef
  127. Ident "TypeOfVarAlt"
  128. Empty
  129. Command
  130. Ident "type"
  131. Par
  132. Ident "a"
  133. TypeDef
  134. Ident "TypeOfTuple1"
  135. Empty
  136. Call
  137. Ident "type"
  138. Ident "a"
  139. TypeDef
  140. Ident "TypeOfTuple2"
  141. Empty
  142. Call
  143. Ident "type"
  144. Ident "a"
  145. Ident "b"
  146. TypeDef
  147. Ident "TypeOfTuple1A"
  148. Empty
  149. Command
  150. Ident "type"
  151. TupleConstr
  152. Ident "a"
  153. TypeDef
  154. Ident "TypeOfTuple2A"
  155. Empty
  156. Command
  157. Ident "type"
  158. Par
  159. Ident "a"
  160. Ident "b"
  161. TypeDef
  162. Ident "TypeTuple"
  163. Empty
  164. Command
  165. Ident "type"
  166. Par
  167. Ident "int"
  168. Ident "string"
  169. TypeDef
  170. Ident "GenericTypedesc"
  171. Empty
  172. BracketExpr
  173. Ident "typedesc"
  174. Ident "int"
  175. TypeDef
  176. Ident "T"
  177. Empty
  178. Ident "type"
  179. ProcDef
  180. Ident "foo"
  181. Empty
  182. Empty
  183. FormalParams
  184. Ident "type"
  185. IdentDefs
  186. Ident "bareType"
  187. Ident "type"
  188. Empty
  189. IdentDefs
  190. Ident "genType"
  191. BracketExpr
  192. Ident "type"
  193. Ident "int"
  194. Empty
  195. IdentDefs
  196. Ident "typeInt"
  197. Command
  198. Ident "type"
  199. Ident "int"
  200. Empty
  201. IdentDefs
  202. Ident "typeIntAlt"
  203. Call
  204. Ident "type"
  205. Ident "int"
  206. Empty
  207. IdentDefs
  208. Ident "typeOfVar"
  209. Call
  210. Ident "type"
  211. Ident "a"
  212. Empty
  213. IdentDefs
  214. Ident "typeDotType"
  215. DotExpr
  216. Ident "foo"
  217. Ident "type"
  218. Empty
  219. IdentDefs
  220. Ident "typeTupleCl"
  221. Command
  222. Ident "type"
  223. TupleClassTy
  224. Empty
  225. IdentDefs
  226. Ident "bareStatic"
  227. Ident "static"
  228. Empty
  229. IdentDefs
  230. Ident "genStatic"
  231. BracketExpr
  232. Ident "static"
  233. Ident "int"
  234. Empty
  235. IdentDefs
  236. Ident "staticInt"
  237. Command
  238. Ident "static"
  239. Ident "int"
  240. Empty
  241. IdentDefs
  242. Ident "staticVal1"
  243. Command
  244. Ident "static"
  245. IntLit 10
  246. Empty
  247. IdentDefs
  248. Ident "staticVal2"
  249. Call
  250. Ident "static"
  251. StrLit "str"
  252. Empty
  253. IdentDefs
  254. Ident "staticVal3"
  255. Command
  256. Ident "static"
  257. StrLit "str"
  258. Empty
  259. IdentDefs
  260. Ident "staticVal4"
  261. CallStrLit
  262. Ident "static"
  263. RStrLit "str"
  264. Empty
  265. IdentDefs
  266. Ident "staticDotVal"
  267. DotExpr
  268. IntLit 10
  269. Ident "static"
  270. Empty
  271. IdentDefs
  272. Ident "bareRef"
  273. RefTy
  274. Empty
  275. IdentDefs
  276. Ident "refTuple1"
  277. RefTy
  278. Par
  279. Ident "int"
  280. Empty
  281. IdentDefs
  282. Ident "refTuple1A"
  283. RefTy
  284. TupleConstr
  285. Ident "int"
  286. Empty
  287. IdentDefs
  288. Ident "refTuple2"
  289. RefTy
  290. Par
  291. Ident "int"
  292. Ident "string"
  293. Empty
  294. IdentDefs
  295. Ident "genRef"
  296. RefTy
  297. Bracket
  298. Ident "int"
  299. Empty
  300. IdentDefs
  301. Ident "refInt"
  302. RefTy
  303. Ident "int"
  304. Empty
  305. IdentDefs
  306. Ident "refCall"
  307. RefTy
  308. Par
  309. Ident "a"
  310. Empty
  311. IdentDefs
  312. Ident "macroCall1"
  313. Command
  314. Ident "foo"
  315. Ident "bar"
  316. Empty
  317. IdentDefs
  318. Ident "macroCall2"
  319. Call
  320. Ident "foo"
  321. Ident "bar"
  322. Empty
  323. IdentDefs
  324. Ident "macroCall3"
  325. Call
  326. DotExpr
  327. Ident "foo"
  328. Ident "bar"
  329. Ident "baz"
  330. Empty
  331. IdentDefs
  332. Ident "macroCall4"
  333. Call
  334. BracketExpr
  335. Ident "foo"
  336. Ident "bar"
  337. Ident "baz"
  338. Empty
  339. IdentDefs
  340. Ident "macroCall5"
  341. Command
  342. Ident "foo"
  343. Command
  344. Ident "bar"
  345. Ident "baz"
  346. IntLit 10
  347. Empty
  348. Empty
  349. StmtList
  350. Asgn
  351. Ident "staticTen"
  352. Command
  353. Ident "static"
  354. IntLit 10
  355. Asgn
  356. Ident "staticA"
  357. Call
  358. Ident "static"
  359. Ident "a"
  360. Asgn
  361. Ident "staticCall"
  362. Command
  363. Ident "static"
  364. Call
  365. Ident "foo"
  366. IntLit 1
  367. Asgn
  368. Ident "staticStrCall"
  369. Command
  370. Ident "static"
  371. CallStrLit
  372. Ident "foo"
  373. RStrLit "x"
  374. Asgn
  375. Ident "staticChainCall"
  376. Command
  377. Ident "static"
  378. Command
  379. Ident "foo"
  380. Ident "bar"
  381. Asgn
  382. Ident "typeTen"
  383. Command
  384. Ident "type"
  385. IntLit 10
  386. Asgn
  387. Ident "typeA"
  388. Call
  389. Ident "type"
  390. Ident "a"
  391. Asgn
  392. Ident "typeCall"
  393. Command
  394. Ident "type"
  395. Call
  396. Ident "foo"
  397. IntLit 1
  398. Asgn
  399. Ident "typeStrCall"
  400. Command
  401. Ident "type"
  402. CallStrLit
  403. Ident "foo"
  404. RStrLit "x"
  405. Asgn
  406. Ident "typeChainCall"
  407. Command
  408. Ident "type"
  409. Command
  410. Ident "foo"
  411. Ident "bar"
  412. Asgn
  413. Ident "normalChainCall"
  414. Command
  415. Ident "foo"
  416. Command
  417. Ident "bar"
  418. Ident "baz"
  419. Asgn
  420. Ident "normalTupleCall2"
  421. Call
  422. Ident "foo"
  423. Ident "a"
  424. Ident "b"
  425. StaticStmt
  426. StmtList
  427. Ident "singleStaticStmt"
  428. StaticStmt
  429. StmtList
  430. Ident "staticStmtList1"
  431. Ident "staticStmtList2"
  432. '''
  433. """
  434. import macros
  435. dumpTree:
  436. type
  437. BarePtr = ptr
  438. GenericPtr = ptr[int]
  439. PrefixPtr = ptr int
  440. PtrTuple = ptr (int, string)
  441. BareRef = ref
  442. GenericRef = ref[int]
  443. RefTupleCl = ref tuple
  444. RefTupleType = ref (int, string)
  445. RefTupleVars = ref (a, b)
  446. BareStatic = static # Used to be Error: invalid indentation
  447. GenericStatic = static[int]
  448. PrefixStatic = static int
  449. StaticTupleCl = static tuple
  450. StaticTuple = static (int, string)
  451. BareType = type
  452. GenericType = type[float]
  453. TypeTupleGen = type[tuple]
  454. TypeTupleCl = type tuple # Used to be Error: invalid indentation
  455. TypeInstance = type Foo[ref]
  456. bareTypeDesc = typedesc
  457. TypeOfVar = type(a)
  458. TypeOfVarAlt = type (a) # Used to be Error: invalid indentation
  459. TypeOfTuple1 = type(a,)
  460. TypeOfTuple2 = type(a,b)
  461. TypeOfTuple1A = type (a,) # Used to be Error: invalid indentation
  462. TypeOfTuple2A = type (a,b) # Used to be Error: invalid indentation
  463. TypeTuple = type (int, string) # Used to be Error: invalid indentation
  464. GenericTypedesc = typedesc[int]
  465. T = type
  466. proc foo(
  467. bareType : type,
  468. genType : type[int],
  469. typeInt : type int,
  470. typeIntAlt : type(int),
  471. typeOfVar : type(a),
  472. typeDotType : foo.type,
  473. typeTupleCl : type tuple, # Used to be Error: ')' expected
  474. bareStatic : static, # Used to be Error: expression expected, but found ','
  475. genStatic : static[int],
  476. staticInt : static int,
  477. staticVal1 : static 10,
  478. staticVal2 : static("str"),
  479. staticVal3 : static "str",
  480. staticVal4 : static"str", # Used to be Error: expression expected, but found 'str'
  481. staticDotVal : 10.static,
  482. bareRef : ref,
  483. refTuple1 : ref (int),
  484. refTuple1A : ref (int,),
  485. refTuple2 : ref (int,string),
  486. genRef : ref[int],
  487. refInt : ref int,
  488. refCall : ref(a),
  489. macroCall1 : foo bar,
  490. macroCall2 : foo(bar),
  491. macroCall3 : foo.bar(baz),
  492. macroCall4 : foo[bar](baz),
  493. macroCall5 : foo bar baz = 10
  494. ): type =
  495. staticTen = static 10
  496. staticA = static(a)
  497. # staticAspace = static (a) # With newTypedesc: Error: invalid indentation
  498. # staticAtuple = static (a,) # With newTypedesc: Error: invalid indentation
  499. # staticTuple = static (a,b) # With newTypedesc: Error: invalid indentation
  500. # staticTypeTuple = static (int,string) # With newTypedesc: Error: invalid indentation
  501. staticCall = static foo(1)
  502. staticStrCall = static foo"x"
  503. staticChainCall = static foo bar
  504. typeTen = type 10
  505. typeA = type(a)
  506. # typeAspace = type (a) # Error: invalid indentation
  507. # typeAtuple = type (a,) # Error: invalid indentation
  508. # typeTuple = type (a,b) # Error: invalid indentation
  509. # typeTypeTuple = type (int,string) # Error: invalid indentation
  510. typeCall = type foo(1)
  511. typeStrCall = type foo"x"
  512. typeChainCall = type foo bar
  513. normalChainCall = foo bar baz
  514. # normalTupleCall1 = foo(a,) # Error: invalid indentation
  515. normalTupleCall2 = foo(a,b)
  516. # normalTupleCall3 = foo (a,b) # Error: invalid indentation
  517. static: singleStaticStmt
  518. static:
  519. staticStmtList1
  520. staticStmtList2