ast.odin 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938
  1. package odin_ast
  2. import "core:odin/tokenizer"
  3. Proc_Tag :: enum {
  4. Bounds_Check,
  5. No_Bounds_Check,
  6. Optional_Ok,
  7. Optional_Second,
  8. }
  9. Proc_Tags :: distinct bit_set[Proc_Tag; u32]
  10. Proc_Inlining :: enum u32 {
  11. None = 0,
  12. Inline = 1,
  13. No_Inline = 2,
  14. }
  15. Proc_Calling_Convention_Extra :: enum i32 {
  16. Foreign_Block_Default,
  17. }
  18. Proc_Calling_Convention :: union {
  19. string,
  20. Proc_Calling_Convention_Extra,
  21. }
  22. Node_State_Flag :: enum {
  23. Bounds_Check,
  24. No_Bounds_Check,
  25. }
  26. Node_State_Flags :: distinct bit_set[Node_State_Flag]
  27. Node :: struct {
  28. pos: tokenizer.Pos,
  29. end: tokenizer.Pos,
  30. state_flags: Node_State_Flags,
  31. derived: Any_Node,
  32. }
  33. Comment_Group :: struct {
  34. using node: Node,
  35. list: []tokenizer.Token,
  36. }
  37. Package_Kind :: enum {
  38. Normal,
  39. Runtime,
  40. Init,
  41. }
  42. Package :: struct {
  43. using node: Node,
  44. kind: Package_Kind,
  45. id: int,
  46. name: string,
  47. fullpath: string,
  48. files: map[string]^File,
  49. user_data: rawptr,
  50. }
  51. File :: struct {
  52. using node: Node,
  53. id: int,
  54. pkg: ^Package,
  55. fullpath: string,
  56. src: string,
  57. docs: ^Comment_Group,
  58. pkg_decl: ^Package_Decl,
  59. pkg_token: tokenizer.Token,
  60. pkg_name: string,
  61. decls: [dynamic]^Stmt,
  62. imports: [dynamic]^Import_Decl,
  63. directive_count: int,
  64. comments: [dynamic]^Comment_Group,
  65. syntax_warning_count: int,
  66. syntax_error_count: int,
  67. }
  68. // Base Types
  69. Expr :: struct {
  70. using expr_base: Node,
  71. derived_expr: Any_Expr,
  72. }
  73. Stmt :: struct {
  74. using stmt_base: Node,
  75. derived_stmt: Any_Stmt,
  76. }
  77. Decl :: struct {
  78. using decl_base: Stmt,
  79. }
  80. // Expressions
  81. Bad_Expr :: struct {
  82. using node: Expr,
  83. }
  84. Ident :: struct {
  85. using node: Expr,
  86. name: string,
  87. }
  88. Implicit :: struct {
  89. using node: Expr,
  90. tok: tokenizer.Token,
  91. }
  92. Undef :: struct {
  93. using node: Expr,
  94. tok: tokenizer.Token_Kind,
  95. }
  96. Basic_Lit :: struct {
  97. using node: Expr,
  98. tok: tokenizer.Token,
  99. }
  100. Basic_Directive :: struct {
  101. using node: Expr,
  102. tok: tokenizer.Token,
  103. name: string,
  104. }
  105. Ellipsis :: struct {
  106. using node: Expr,
  107. tok: tokenizer.Token_Kind,
  108. expr: ^Expr,
  109. }
  110. Proc_Lit :: struct {
  111. using node: Expr,
  112. type: ^Proc_Type,
  113. body: ^Stmt,
  114. tags: Proc_Tags,
  115. inlining: Proc_Inlining,
  116. where_token: tokenizer.Token,
  117. where_clauses: []^Expr,
  118. }
  119. Comp_Lit :: struct {
  120. using node: Expr,
  121. type: ^Expr,
  122. open: tokenizer.Pos,
  123. elems: []^Expr,
  124. close: tokenizer.Pos,
  125. tag: ^Expr,
  126. }
  127. Tag_Expr :: struct {
  128. using node: Expr,
  129. op: tokenizer.Token,
  130. name: string,
  131. expr: ^Expr,
  132. }
  133. Unary_Expr :: struct {
  134. using node: Expr,
  135. op: tokenizer.Token,
  136. expr: ^Expr,
  137. }
  138. Binary_Expr :: struct {
  139. using node: Expr,
  140. left: ^Expr,
  141. op: tokenizer.Token,
  142. right: ^Expr,
  143. }
  144. Paren_Expr :: struct {
  145. using node: Expr,
  146. open: tokenizer.Pos,
  147. expr: ^Expr,
  148. close: tokenizer.Pos,
  149. }
  150. Selector_Expr :: struct {
  151. using node: Expr,
  152. expr: ^Expr,
  153. op: tokenizer.Token,
  154. field: ^Ident,
  155. }
  156. Implicit_Selector_Expr :: struct {
  157. using node: Expr,
  158. field: ^Ident,
  159. }
  160. Selector_Call_Expr :: struct {
  161. using node: Expr,
  162. expr: ^Expr,
  163. call: ^Call_Expr,
  164. modified_call: bool,
  165. }
  166. Index_Expr :: struct {
  167. using node: Expr,
  168. expr: ^Expr,
  169. open: tokenizer.Pos,
  170. index: ^Expr,
  171. close: tokenizer.Pos,
  172. }
  173. Deref_Expr :: struct {
  174. using node: Expr,
  175. expr: ^Expr,
  176. op: tokenizer.Token,
  177. }
  178. Slice_Expr :: struct {
  179. using node: Expr,
  180. expr: ^Expr,
  181. open: tokenizer.Pos,
  182. low: ^Expr,
  183. interval: tokenizer.Token,
  184. high: ^Expr,
  185. close: tokenizer.Pos,
  186. }
  187. Matrix_Index_Expr :: struct {
  188. using node: Expr,
  189. expr: ^Expr,
  190. open: tokenizer.Pos,
  191. row_index: ^Expr,
  192. column_index: ^Expr,
  193. close: tokenizer.Pos,
  194. }
  195. Call_Expr :: struct {
  196. using node: Expr,
  197. inlining: Proc_Inlining,
  198. expr: ^Expr,
  199. open: tokenizer.Pos,
  200. args: []^Expr,
  201. ellipsis: tokenizer.Token,
  202. close: tokenizer.Pos,
  203. }
  204. Field_Value :: struct {
  205. using node: Expr,
  206. field: ^Expr,
  207. sep: tokenizer.Pos,
  208. value: ^Expr,
  209. }
  210. Ternary_If_Expr :: struct {
  211. using node: Expr,
  212. x: ^Expr,
  213. op1: tokenizer.Token,
  214. cond: ^Expr,
  215. op2: tokenizer.Token,
  216. y: ^Expr,
  217. }
  218. Ternary_When_Expr :: struct {
  219. using node: Expr,
  220. x: ^Expr,
  221. op1: tokenizer.Token,
  222. cond: ^Expr,
  223. op2: tokenizer.Token,
  224. y: ^Expr,
  225. }
  226. Or_Else_Expr :: struct {
  227. using node: Expr,
  228. x: ^Expr,
  229. token: tokenizer.Token,
  230. y: ^Expr,
  231. }
  232. Or_Return_Expr :: struct {
  233. using node: Expr,
  234. expr: ^Expr,
  235. token: tokenizer.Token,
  236. }
  237. Type_Assertion :: struct {
  238. using node: Expr,
  239. expr: ^Expr,
  240. dot: tokenizer.Pos,
  241. open: tokenizer.Pos,
  242. type: ^Expr,
  243. close: tokenizer.Pos,
  244. }
  245. Type_Cast :: struct {
  246. using node: Expr,
  247. tok: tokenizer.Token,
  248. open: tokenizer.Pos,
  249. type: ^Expr,
  250. close: tokenizer.Pos,
  251. expr: ^Expr,
  252. }
  253. Auto_Cast :: struct {
  254. using node: Expr,
  255. op: tokenizer.Token,
  256. expr: ^Expr,
  257. }
  258. Inline_Asm_Dialect :: enum u8 {
  259. Default = 0,
  260. ATT = 1,
  261. Intel = 2,
  262. }
  263. Inline_Asm_Expr :: struct {
  264. using node: Expr,
  265. tok: tokenizer.Token,
  266. param_types: []^Expr,
  267. return_type: ^Expr,
  268. has_side_effects: bool,
  269. is_align_stack: bool,
  270. dialect: Inline_Asm_Dialect,
  271. open: tokenizer.Pos,
  272. constraints_string: ^Expr,
  273. asm_string: ^Expr,
  274. close: tokenizer.Pos,
  275. }
  276. // Statements
  277. Bad_Stmt :: struct {
  278. using node: Stmt,
  279. }
  280. Empty_Stmt :: struct {
  281. using node: Stmt,
  282. semicolon: tokenizer.Pos, // Position of the following ';'
  283. }
  284. Expr_Stmt :: struct {
  285. using node: Stmt,
  286. expr: ^Expr,
  287. }
  288. Tag_Stmt :: struct {
  289. using node: Stmt,
  290. op: tokenizer.Token,
  291. name: string,
  292. stmt: ^Stmt,
  293. }
  294. Assign_Stmt :: struct {
  295. using node: Stmt,
  296. lhs: []^Expr,
  297. op: tokenizer.Token,
  298. rhs: []^Expr,
  299. }
  300. Block_Stmt :: struct {
  301. using node: Stmt,
  302. label: ^Expr,
  303. open: tokenizer.Pos,
  304. stmts: []^Stmt,
  305. close: tokenizer.Pos,
  306. uses_do: bool,
  307. }
  308. If_Stmt :: struct {
  309. using node: Stmt,
  310. label: ^Expr,
  311. if_pos: tokenizer.Pos,
  312. init: ^Stmt,
  313. cond: ^Expr,
  314. body: ^Stmt,
  315. else_pos: tokenizer.Pos,
  316. else_stmt: ^Stmt,
  317. }
  318. When_Stmt :: struct {
  319. using node: Stmt,
  320. when_pos: tokenizer.Pos,
  321. cond: ^Expr,
  322. body: ^Stmt,
  323. else_stmt: ^Stmt,
  324. }
  325. Return_Stmt :: struct {
  326. using node: Stmt,
  327. results: []^Expr,
  328. }
  329. Defer_Stmt :: struct {
  330. using node: Stmt,
  331. stmt: ^Stmt,
  332. }
  333. For_Stmt :: struct {
  334. using node: Stmt,
  335. label: ^Expr,
  336. for_pos: tokenizer.Pos,
  337. init: ^Stmt,
  338. cond: ^Expr,
  339. post: ^Stmt,
  340. body: ^Stmt,
  341. }
  342. Range_Stmt :: struct {
  343. using node: Stmt,
  344. label: ^Expr,
  345. for_pos: tokenizer.Pos,
  346. vals: []^Expr,
  347. in_pos: tokenizer.Pos,
  348. expr: ^Expr,
  349. body: ^Stmt,
  350. }
  351. Inline_Range_Stmt :: struct {
  352. using node: Stmt,
  353. label: ^Expr,
  354. inline_pos: tokenizer.Pos,
  355. for_pos: tokenizer.Pos,
  356. val0: ^Expr,
  357. val1: ^Expr,
  358. in_pos: tokenizer.Pos,
  359. expr: ^Expr,
  360. body: ^Stmt,
  361. }
  362. Case_Clause :: struct {
  363. using node: Stmt,
  364. case_pos: tokenizer.Pos,
  365. list: []^Expr,
  366. terminator: tokenizer.Token,
  367. body: []^Stmt,
  368. }
  369. Switch_Stmt :: struct {
  370. using node: Stmt,
  371. label: ^Expr,
  372. switch_pos: tokenizer.Pos,
  373. init: ^Stmt,
  374. cond: ^Expr,
  375. body: ^Stmt,
  376. partial: bool,
  377. }
  378. Type_Switch_Stmt :: struct {
  379. using node: Stmt,
  380. label: ^Expr,
  381. switch_pos: tokenizer.Pos,
  382. tag: ^Stmt,
  383. expr: ^Expr,
  384. body: ^Stmt,
  385. partial: bool,
  386. }
  387. Branch_Stmt :: struct {
  388. using node: Stmt,
  389. tok: tokenizer.Token,
  390. label: ^Ident,
  391. }
  392. Using_Stmt :: struct {
  393. using node: Stmt,
  394. list: []^Expr,
  395. }
  396. // Declarations
  397. Bad_Decl :: struct {
  398. using node: Decl,
  399. }
  400. Value_Decl :: struct {
  401. using node: Decl,
  402. docs: ^Comment_Group,
  403. attributes: [dynamic]^Attribute, // dynamic as parsing will add to them lazily
  404. names: []^Expr,
  405. type: ^Expr,
  406. values: []^Expr,
  407. comment: ^Comment_Group,
  408. is_using: bool,
  409. is_mutable: bool,
  410. }
  411. Package_Decl :: struct {
  412. using node: Decl,
  413. docs: ^Comment_Group,
  414. token: tokenizer.Token,
  415. name: string,
  416. comment: ^Comment_Group,
  417. }
  418. Import_Decl :: struct {
  419. using node: Decl,
  420. docs: ^Comment_Group,
  421. is_using: bool,
  422. import_tok: tokenizer.Token,
  423. name: tokenizer.Token,
  424. relpath: tokenizer.Token,
  425. fullpath: string,
  426. comment: ^Comment_Group,
  427. }
  428. Foreign_Block_Decl :: struct {
  429. using node: Decl,
  430. docs: ^Comment_Group,
  431. attributes: [dynamic]^Attribute, // dynamic as parsing will add to them lazily
  432. tok: tokenizer.Token,
  433. foreign_library: ^Expr,
  434. body: ^Stmt,
  435. }
  436. Foreign_Import_Decl :: struct {
  437. using node: Decl,
  438. docs: ^Comment_Group,
  439. attributes: [dynamic]^Attribute, // dynamic as parsing will add to them lazily
  440. foreign_tok: tokenizer.Token,
  441. import_tok: tokenizer.Token,
  442. name: ^Ident,
  443. collection_name: string,
  444. fullpaths: []string,
  445. comment: ^Comment_Group,
  446. }
  447. // Other things
  448. unparen_expr :: proc(expr: ^Expr) -> (val: ^Expr) {
  449. val = expr
  450. if expr == nil {
  451. return
  452. }
  453. for {
  454. e, ok := val.derived.(^Paren_Expr)
  455. if !ok || e.expr == nil {
  456. break
  457. }
  458. val = e.expr
  459. }
  460. return
  461. }
  462. Field_Flag :: enum {
  463. Ellipsis,
  464. Using,
  465. No_Alias,
  466. C_Vararg,
  467. Auto_Cast,
  468. Any_Int,
  469. Results,
  470. Tags,
  471. Default_Parameters,
  472. Typeid_Token,
  473. }
  474. Field_Flags :: distinct bit_set[Field_Flag]
  475. Field_Flags_Struct :: Field_Flags{
  476. .Using,
  477. .Tags,
  478. }
  479. Field_Flags_Record_Poly_Params :: Field_Flags{
  480. .Typeid_Token,
  481. .Default_Parameters,
  482. }
  483. Field_Flags_Signature :: Field_Flags{
  484. .Ellipsis,
  485. .Using,
  486. .No_Alias,
  487. .C_Vararg,
  488. .Auto_Cast,
  489. .Any_Int,
  490. .Default_Parameters,
  491. }
  492. Field_Flags_Signature_Params :: Field_Flags_Signature | {Field_Flag.Typeid_Token}
  493. Field_Flags_Signature_Results :: Field_Flags_Signature
  494. Proc_Group :: struct {
  495. using node: Expr,
  496. tok: tokenizer.Token,
  497. open: tokenizer.Pos,
  498. args: []^Expr,
  499. close: tokenizer.Pos,
  500. }
  501. Attribute :: struct {
  502. using node: Node,
  503. tok: tokenizer.Token_Kind,
  504. open: tokenizer.Pos,
  505. elems: []^Expr,
  506. close: tokenizer.Pos,
  507. }
  508. Field :: struct {
  509. using node: Node,
  510. docs: ^Comment_Group,
  511. names: []^Expr, // Could be polymorphic
  512. type: ^Expr,
  513. default_value: ^Expr,
  514. tag: tokenizer.Token,
  515. flags: Field_Flags,
  516. comment: ^Comment_Group,
  517. }
  518. Field_List :: struct {
  519. using node: Node,
  520. open: tokenizer.Pos,
  521. list: []^Field,
  522. close: tokenizer.Pos,
  523. }
  524. // Types
  525. Typeid_Type :: struct {
  526. using node: Expr,
  527. tok: tokenizer.Token_Kind,
  528. specialization: ^Expr,
  529. }
  530. Helper_Type :: struct {
  531. using node: Expr,
  532. tok: tokenizer.Token_Kind,
  533. type: ^Expr,
  534. }
  535. Distinct_Type :: struct {
  536. using node: Expr,
  537. tok: tokenizer.Token_Kind,
  538. type: ^Expr,
  539. }
  540. Poly_Type :: struct {
  541. using node: Expr,
  542. dollar: tokenizer.Pos,
  543. type: ^Ident,
  544. specialization: ^Expr,
  545. }
  546. Proc_Type :: struct {
  547. using node: Expr,
  548. tok: tokenizer.Token,
  549. calling_convention: Proc_Calling_Convention,
  550. params: ^Field_List,
  551. arrow: tokenizer.Pos,
  552. results: ^Field_List,
  553. tags: Proc_Tags,
  554. generic: bool,
  555. diverging: bool,
  556. }
  557. Pointer_Type :: struct {
  558. using node: Expr,
  559. pointer: tokenizer.Pos,
  560. elem: ^Expr,
  561. }
  562. Multi_Pointer_Type :: struct {
  563. using node: Expr,
  564. open: tokenizer.Pos,
  565. pointer: tokenizer.Pos,
  566. close: tokenizer.Pos,
  567. elem: ^Expr,
  568. }
  569. Array_Type :: struct {
  570. using node: Expr,
  571. open: tokenizer.Pos,
  572. tag: ^Expr,
  573. len: ^Expr, // Ellipsis node for [?]T arrray types, nil for slice types
  574. close: tokenizer.Pos,
  575. elem: ^Expr,
  576. }
  577. Dynamic_Array_Type :: struct {
  578. using node: Expr,
  579. tag: ^Expr,
  580. open: tokenizer.Pos,
  581. dynamic_pos: tokenizer.Pos,
  582. close: tokenizer.Pos,
  583. elem: ^Expr,
  584. }
  585. Struct_Type :: struct {
  586. using node: Expr,
  587. tok_pos: tokenizer.Pos,
  588. poly_params: ^Field_List,
  589. align: ^Expr,
  590. where_token: tokenizer.Token,
  591. where_clauses: []^Expr,
  592. is_packed: bool,
  593. is_raw_union: bool,
  594. fields: ^Field_List,
  595. name_count: int,
  596. }
  597. Union_Type_Kind :: enum u8 {
  598. Normal,
  599. maybe,
  600. no_nil,
  601. shared_nil,
  602. }
  603. Union_Type :: struct {
  604. using node: Expr,
  605. tok_pos: tokenizer.Pos,
  606. poly_params: ^Field_List,
  607. align: ^Expr,
  608. kind: Union_Type_Kind,
  609. where_token: tokenizer.Token,
  610. where_clauses: []^Expr,
  611. variants: []^Expr,
  612. }
  613. Enum_Type :: struct {
  614. using node: Expr,
  615. tok_pos: tokenizer.Pos,
  616. base_type: ^Expr,
  617. open: tokenizer.Pos,
  618. fields: []^Expr,
  619. close: tokenizer.Pos,
  620. is_using: bool,
  621. }
  622. Bit_Set_Type :: struct {
  623. using node: Expr,
  624. tok_pos: tokenizer.Pos,
  625. open: tokenizer.Pos,
  626. elem: ^Expr,
  627. underlying: ^Expr,
  628. close: tokenizer.Pos,
  629. }
  630. Map_Type :: struct {
  631. using node: Expr,
  632. tok_pos: tokenizer.Pos,
  633. key: ^Expr,
  634. value: ^Expr,
  635. }
  636. Relative_Type :: struct {
  637. using node: Expr,
  638. tag: ^Expr,
  639. type: ^Expr,
  640. }
  641. Matrix_Type :: struct {
  642. using node: Expr,
  643. tok_pos: tokenizer.Pos,
  644. row_count: ^Expr,
  645. column_count: ^Expr,
  646. elem: ^Expr,
  647. }
  648. Any_Node :: union {
  649. ^Package,
  650. ^File,
  651. ^Comment_Group,
  652. ^Bad_Expr,
  653. ^Ident,
  654. ^Implicit,
  655. ^Undef,
  656. ^Basic_Lit,
  657. ^Basic_Directive,
  658. ^Ellipsis,
  659. ^Proc_Lit,
  660. ^Comp_Lit,
  661. ^Tag_Expr,
  662. ^Unary_Expr,
  663. ^Binary_Expr,
  664. ^Paren_Expr,
  665. ^Selector_Expr,
  666. ^Implicit_Selector_Expr,
  667. ^Selector_Call_Expr,
  668. ^Index_Expr,
  669. ^Deref_Expr,
  670. ^Slice_Expr,
  671. ^Matrix_Index_Expr,
  672. ^Call_Expr,
  673. ^Field_Value,
  674. ^Ternary_If_Expr,
  675. ^Ternary_When_Expr,
  676. ^Or_Else_Expr,
  677. ^Or_Return_Expr,
  678. ^Type_Assertion,
  679. ^Type_Cast,
  680. ^Auto_Cast,
  681. ^Inline_Asm_Expr,
  682. ^Proc_Group,
  683. ^Typeid_Type,
  684. ^Helper_Type,
  685. ^Distinct_Type,
  686. ^Poly_Type,
  687. ^Proc_Type,
  688. ^Pointer_Type,
  689. ^Multi_Pointer_Type,
  690. ^Array_Type,
  691. ^Dynamic_Array_Type,
  692. ^Struct_Type,
  693. ^Union_Type,
  694. ^Enum_Type,
  695. ^Bit_Set_Type,
  696. ^Map_Type,
  697. ^Relative_Type,
  698. ^Matrix_Type,
  699. ^Bad_Stmt,
  700. ^Empty_Stmt,
  701. ^Expr_Stmt,
  702. ^Tag_Stmt,
  703. ^Assign_Stmt,
  704. ^Block_Stmt,
  705. ^If_Stmt,
  706. ^When_Stmt,
  707. ^Return_Stmt,
  708. ^Defer_Stmt,
  709. ^For_Stmt,
  710. ^Range_Stmt,
  711. ^Inline_Range_Stmt,
  712. ^Case_Clause,
  713. ^Switch_Stmt,
  714. ^Type_Switch_Stmt,
  715. ^Branch_Stmt,
  716. ^Using_Stmt,
  717. ^Bad_Decl,
  718. ^Value_Decl,
  719. ^Package_Decl,
  720. ^Import_Decl,
  721. ^Foreign_Block_Decl,
  722. ^Foreign_Import_Decl,
  723. ^Attribute,
  724. ^Field,
  725. ^Field_List,
  726. }
  727. Any_Expr :: union {
  728. ^Bad_Expr,
  729. ^Ident,
  730. ^Implicit,
  731. ^Undef,
  732. ^Basic_Lit,
  733. ^Basic_Directive,
  734. ^Ellipsis,
  735. ^Proc_Lit,
  736. ^Comp_Lit,
  737. ^Tag_Expr,
  738. ^Unary_Expr,
  739. ^Binary_Expr,
  740. ^Paren_Expr,
  741. ^Selector_Expr,
  742. ^Implicit_Selector_Expr,
  743. ^Selector_Call_Expr,
  744. ^Index_Expr,
  745. ^Deref_Expr,
  746. ^Slice_Expr,
  747. ^Matrix_Index_Expr,
  748. ^Call_Expr,
  749. ^Field_Value,
  750. ^Ternary_If_Expr,
  751. ^Ternary_When_Expr,
  752. ^Or_Else_Expr,
  753. ^Or_Return_Expr,
  754. ^Type_Assertion,
  755. ^Type_Cast,
  756. ^Auto_Cast,
  757. ^Inline_Asm_Expr,
  758. ^Proc_Group,
  759. ^Typeid_Type,
  760. ^Helper_Type,
  761. ^Distinct_Type,
  762. ^Poly_Type,
  763. ^Proc_Type,
  764. ^Pointer_Type,
  765. ^Multi_Pointer_Type,
  766. ^Array_Type,
  767. ^Dynamic_Array_Type,
  768. ^Struct_Type,
  769. ^Union_Type,
  770. ^Enum_Type,
  771. ^Bit_Set_Type,
  772. ^Map_Type,
  773. ^Relative_Type,
  774. ^Matrix_Type,
  775. }
  776. Any_Stmt :: union {
  777. ^Bad_Stmt,
  778. ^Empty_Stmt,
  779. ^Expr_Stmt,
  780. ^Tag_Stmt,
  781. ^Assign_Stmt,
  782. ^Block_Stmt,
  783. ^If_Stmt,
  784. ^When_Stmt,
  785. ^Return_Stmt,
  786. ^Defer_Stmt,
  787. ^For_Stmt,
  788. ^Range_Stmt,
  789. ^Inline_Range_Stmt,
  790. ^Case_Clause,
  791. ^Switch_Stmt,
  792. ^Type_Switch_Stmt,
  793. ^Branch_Stmt,
  794. ^Using_Stmt,
  795. ^Bad_Decl,
  796. ^Value_Decl,
  797. ^Package_Decl,
  798. ^Import_Decl,
  799. ^Foreign_Block_Decl,
  800. ^Foreign_Import_Decl,
  801. }