command.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package node
  2. type VariousCommand struct {
  3. Node `part:"command"`
  4. Command Command `use:"first"`
  5. }
  6. type Command interface { Command() }
  7. func (impl Import) Command() {}
  8. type Import struct {
  9. Node `part:"import"`
  10. Name Identifier `part:"name"`
  11. Path StringLiteral `part:"string"`
  12. }
  13. type MaybeIdentifier interface { MaybeIdentifier() }
  14. func (impl Identifier) MaybeIdentifier() {}
  15. type Identifier struct {
  16. Node `part:"name"`
  17. Name [] rune `content:"Name"`
  18. }
  19. func (impl DeclConst) Command() {}
  20. type DeclConst struct {
  21. Node `part:"decl_const"`
  22. IsPublic bool `option:"scope.@public"`
  23. Name Identifier `part:"name"`
  24. Type VariousType `part:"type"`
  25. Value VariousConstValue `part:"const_value"`
  26. }
  27. type VariousConstValue struct {
  28. Node `part:"const_value"`
  29. ConstValue ConstValue `use:"first"`
  30. }
  31. type ConstValue interface { ConstValue() }
  32. func (impl NativeRef) ConstValue() {}
  33. func (impl NativeRef) Body() {}
  34. type NativeRef struct {
  35. Node `part:"native"`
  36. Id StringLiteral `part:"string"`
  37. }
  38. func (impl Do) Command() {}
  39. type Do struct {
  40. Node `part:"do"`
  41. Effect Expr `part:"expr"`
  42. }
  43. func (impl DeclFunction) Command() {}
  44. type DeclFunction struct {
  45. Node `part:"decl_func"`
  46. Public bool `option:"scope.@public"`
  47. Name Identifier `part:"name"`
  48. Params [] Identifier `list_more:"type_params" item:"name"`
  49. Repr ReprFunc `part:"signature.repr_func"`
  50. Body VariousBody `part:"body"`
  51. }
  52. type VariousBody struct {
  53. Node `part:"body"`
  54. Body Body `part:"lambda" fallback:"native"`
  55. }
  56. type Body interface { Body() }
  57. func (impl DeclType) Command() {}
  58. type DeclType struct {
  59. Node `part:"decl_type"`
  60. Name Identifier `part:"name"`
  61. Params [] Identifier `list_more:"type_params" item:"name"`
  62. TypeValue VariousTypeValue `part:"type_value"`
  63. }
  64. type VariousTypeValue struct {
  65. Node `part:"type_value"`
  66. TypeValue TypeValue `use:"first"`
  67. }
  68. type TypeValue interface { TypeValue() }
  69. func (impl NativeType) TypeValue() {}
  70. type NativeType struct {
  71. Node `part:"native_type"`
  72. }
  73. func (impl BoxedType) TypeValue() {}
  74. type BoxedType struct {
  75. Node `part:"boxed_type"`
  76. Protected bool `option:"box_option.@protected"`
  77. Opaque bool `option:"box_option.@opaque"`
  78. Inner MaybeType `part_opt:"inner_type.type"`
  79. }
  80. func (impl UnionType) TypeValue() {}
  81. type UnionType struct {
  82. Node `part:"union_type"`
  83. Items [] DeclType `list_more:"" item:"decl_type"`
  84. }