ast.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. // Abstract Syntax tree for the MUESLI interpreter
  2. package muesli
  3. import (
  4. "fmt"
  5. "strings"
  6. )
  7. type AstBasicMetaKind string
  8. type AstMetaKindNone AstBasicMetaKind
  9. type AstMetaKindProgram AstBasicMetaKind
  10. type AstMetaKindStatements AstBasicMetaKind
  11. type AstMetaKindStatement AstBasicMetaKind
  12. type AstMetaKindOperation AstBasicMetaKind
  13. type AstMetaKindClosed AstBasicMetaKind
  14. type AstMetaKindSet AstBasicMetaKind
  15. type AstMetaKindGet AstBasicMetaKind
  16. type AstMetaKindTarget AstBasicMetaKind
  17. type AstMetaKindCommand AstBasicMetaKind
  18. type AstMetaKindArguments AstBasicMetaKind
  19. type AstMetaKindArgument AstBasicMetaKind
  20. type AstMetaKindExpression AstBasicMetaKind
  21. type AstMetaKindBlock AstBasicMetaKind
  22. type AstMetaKindParenthesis AstBasicMetaKind
  23. type AstMetaKindList AstBasicMetaKind
  24. type AstMetaKindCapture AstBasicMetaKind
  25. type AstMetaKindWordValue AstBasicMetaKind
  26. type AstMetaKindWord AstBasicMetaKind
  27. type AstMetaKindType AstBasicMetaKind
  28. type AstMetaKindValue AstBasicMetaKind
  29. type AstMetaKindEnd AstBasicMetaKind
  30. type AstMetaKindError AstBasicMetaKind
  31. type AstMetaKindFlatten AstBasicMetaKind
  32. /* The actual types are defined as constants, the meta types are used to be
  33. * able to have different behavior for them. */
  34. const (
  35. AstKindNone = AstMetaKindNone("None")
  36. AstKindProgram = AstMetaKindProgram("Program")
  37. AstKindStatements = AstMetaKindStatements("Statements")
  38. AstKindStatement = AstMetaKindStatement("Statement")
  39. AstKindOperation = AstMetaKindOperation("Operation")
  40. AstKindSet = AstMetaKindSet("Set")
  41. AstKindGet = AstMetaKindGet("Get")
  42. AstKindTarget = AstMetaKindTarget("Target")
  43. AstKindCommand = AstMetaKindCommand("Command")
  44. AstKindArguments = AstMetaKindArguments("Arguments")
  45. AstKindBlock = AstMetaKindBlock("Block")
  46. AstKindParenthesis = AstMetaKindParenthesis("Parenthesis")
  47. AstKindList = AstMetaKindList("List")
  48. AstKindWordValue = AstMetaKindWordValue("WordValue")
  49. AstKindWord = AstMetaKindWord("Word")
  50. AstKindType = AstMetaKindType("Type")
  51. AstKindValue = AstMetaKindValue("Value")
  52. AstKindEnd = AstMetaKindEnd("End")
  53. AstKindError = AstMetaKindError("Error")
  54. AstKindFlatten = AstMetaKindFlatten("Flatten")
  55. )
  56. func (astkind AstBasicMetaKind) String() string {
  57. return string(astkind)
  58. }
  59. func (astkind AstBasicMetaKind) Eval(vm *VM, ast Ast, val ...Value) []Value {
  60. return []Value{}
  61. }
  62. func (astkind AstMetaKindNone) String() string { return "AstNone " }
  63. func (astkind AstMetaKindProgram) String() string { return "AstProgram " }
  64. func (astkind AstMetaKindStatements) String() string { return "AstStatements " }
  65. func (astkind AstMetaKindStatement) String() string { return "AstStatement " }
  66. func (astkind AstMetaKindOperation) String() string { return "AstOperation " }
  67. func (astkind AstMetaKindClosed) String() string { return "AstClosed " }
  68. func (astkind AstMetaKindSet) String() string { return "AstSet " }
  69. func (astkind AstMetaKindGet) String() string { return "AstGet " }
  70. func (astkind AstMetaKindTarget) String() string { return "AstTarget " }
  71. func (astkind AstMetaKindCommand) String() string { return "AstCommand " }
  72. func (astkind AstMetaKindArguments) String() string { return "AstArguments " }
  73. func (astkind AstMetaKindArgument) String() string { return "AstArgument " }
  74. func (astkind AstMetaKindExpression) String() string { return "AstExpression " }
  75. func (astkind AstMetaKindBlock) String() string { return "AstBlock " }
  76. func (astkind AstMetaKindParenthesis) String() string{ return "AstParenthesis"}
  77. func (astkind AstMetaKindList) String() string { return "AstList " }
  78. func (astkind AstMetaKindCapture) String() string { return "AstCapture " }
  79. func (astkind AstMetaKindWordValue) String() string { return "AstWordValue " }
  80. func (astkind AstMetaKindWord) String() string { return "AstWord " }
  81. func (astkind AstMetaKindType) String() string { return "AstType " }
  82. func (astkind AstMetaKindValue) String() string { return "AstValue " }
  83. func (astkind AstMetaKindEnd) String() string { return "AstEnd " }
  84. func (astkind AstMetaKindError) String() string { return "AstError " }
  85. func (astkind AstMetaKindFlatten) String() string { return "AstFlatten " }
  86. func (astkind AstMetaKindNone) IsLeaf() bool { return false }
  87. func (astkind AstMetaKindProgram) IsLeaf() bool { return false }
  88. func (astkind AstMetaKindStatements) IsLeaf() bool { return false }
  89. func (astkind AstMetaKindStatement) IsLeaf() bool { return false }
  90. func (astkind AstMetaKindOperation) IsLeaf() bool { return false }
  91. func (astkind AstMetaKindClosed) IsLeaf() bool { return false }
  92. func (astkind AstMetaKindSet) IsLeaf() bool { return false }
  93. func (astkind AstMetaKindGet) IsLeaf() bool { return false }
  94. func (astkind AstMetaKindTarget) IsLeaf() bool { return false }
  95. func (astkind AstMetaKindCommand) IsLeaf() bool { return false }
  96. func (astkind AstMetaKindArguments) IsLeaf() bool { return false }
  97. func (astkind AstMetaKindArgument) IsLeaf() bool { return false }
  98. func (astkind AstMetaKindExpression) IsLeaf() bool { return false }
  99. func (astkind AstMetaKindBlock) IsLeaf() bool { return true }
  100. func (astkind AstMetaKindParenthesis) IsLeaf() bool { return false }
  101. func (astkind AstMetaKindList) IsLeaf() bool { return false }
  102. func (astkind AstMetaKindCapture) IsLeaf() bool { return false }
  103. func (astkind AstMetaKindWordValue) IsLeaf() bool { return true }
  104. func (astkind AstMetaKindWord) IsLeaf() bool { return true }
  105. func (astkind AstMetaKindType) IsLeaf() bool { return true }
  106. func (astkind AstMetaKindValue) IsLeaf() bool { return true }
  107. func (astkind AstMetaKindEnd) IsLeaf() bool { return true }
  108. func (astkind AstMetaKindError) IsLeaf() bool { return true }
  109. func (astkind AstMetaKindFlatten) IsLeaf() bool { return false }
  110. func lastValue(val []Value) []Value {
  111. if len(val) < 1 {
  112. return ReturnEmpty()
  113. }
  114. return []Value{val[len(val) - 1]}
  115. }
  116. func firstValue(val []Value) []Value {
  117. if len(val) < 1 {
  118. return ReturnEmpty()
  119. }
  120. return []Value{val[0]}
  121. }
  122. func (astkind AstMetaKindNone) Eval(vm *VM, ast Ast, val ...Value) []Value { return ReturnEmpty() }
  123. func (astkind AstMetaKindProgram) Eval(vm *VM, ast Ast, val ...Value) []Value {
  124. return lastValue(val)
  125. }
  126. func (astkind AstMetaKindStatements) Eval(vm *VM, ast Ast, val ...Value) []Value {
  127. return lastValue(val)
  128. }
  129. func (astkind AstMetaKindStatement) Eval(vm *VM, ast Ast, val ...Value) []Value {
  130. return val
  131. }
  132. func (astkind AstMetaKindOperation) Eval(vm *VM, ast Ast, val ...Value) []Value {
  133. operatorName := ast.Value()
  134. arguments := val
  135. vm.Trace("Operator execute: %s %v", operatorName.String(), arguments)
  136. res := vm.CallNamed(operatorName.String(), arguments...)
  137. return res
  138. }
  139. func (astkind AstMetaKindClosed) Eval(vm *VM, ast Ast, val ...Value) []Value {return ReturnEmpty() }
  140. func (astkind AstMetaKindSet) Eval(vm *VM, ast Ast, val ...Value) []Value {
  141. values := val
  142. if len(values) < 2 {
  143. return Fail(fmt.Errorf("set needs at least 2 arguments: received %v", values))
  144. }
  145. target := values[0].String()
  146. value := values[1]
  147. if target == "(" || target == "$" {
  148. if len(values) < 3 {
  149. return Fail(fmt.Errorf("indirect get needs results: received %v", values))
  150. }
  151. target = values[1].String()
  152. value = values[2]
  153. }
  154. // log.Printf("(astkind AstMetaKindSet) Run: %v %v", target, value)
  155. vm.Register(target, value)
  156. return Ok(value)
  157. }
  158. func (astkind AstMetaKindGet) Eval(vm *VM, ast Ast, val ...Value) []Value {
  159. targets := val
  160. target := targets[0].String()
  161. if target == "(" || target == "$" {
  162. if len(targets) < 2 {
  163. return Fail(fmt.Errorf("indirect get needs results: received %v", targets))
  164. }
  165. target = targets[1].String()
  166. }
  167. // log.Printf("(astkind AstMetaKindGet) Run: target %s", target)
  168. return Ok(vm.Lookup(target))
  169. }
  170. func (astkind AstMetaKindTarget) Eval(vm *VM, ast Ast, val ...Value) []Value {
  171. values := val
  172. values = append([]Value{ast.Value()}, values...)
  173. return values
  174. }
  175. func (astkind AstMetaKindCommand) Eval(vm *VM, ast Ast, val ...Value) []Value {
  176. commandName := ast.Value()
  177. arguments := val
  178. vm.Trace("Command execute: %s %v", commandName.String(), arguments)
  179. res := vm.CallNamed(commandName.String(), arguments...)
  180. return res
  181. }
  182. func (astkind AstMetaKindArguments) Eval(vm *VM, ast Ast, val ...Value) []Value {
  183. return val
  184. }
  185. func (astkind AstMetaKindArgument) Eval(vm *VM, ast Ast, val ...Value) []Value {
  186. panic("AstMetaKindArgument")
  187. return ReturnEmpty()
  188. }
  189. func (astkind AstMetaKindExpression) Eval(vm *VM, ast Ast, val ...Value) []Value {
  190. panic("AstMetaKindExpression")
  191. return ReturnEmpty()
  192. }
  193. func (astkind AstMetaKindBlock) Eval(vm *VM, ast Ast, val ...Value) []Value {
  194. // A block encountered in the AST is not executed.
  195. // It results in an anonymous runnable with a clone of the AST embedded.
  196. return Ok(NewBlockValue(&ast))
  197. }
  198. func (astkind AstMetaKindParenthesis) Eval(vm *VM, ast Ast, val ...Value) []Value {
  199. return lastValue(val)
  200. }
  201. func (astkind AstMetaKindList) Eval(vm *VM, ast Ast, val ...Value) []Value {
  202. list := NewListValue(val...)
  203. return []Value{list}
  204. }
  205. func (astkind AstMetaKindCapture) Eval(vm *VM, ast Ast, val ...Value) []Value {
  206. return val
  207. }
  208. func (astkind AstMetaKindWordValue) Eval(vm *VM, ast Ast, val ...Value) []Value {
  209. return []Value{ast.Value()}
  210. }
  211. func (astkind AstMetaKindWord) Eval(vm *VM, ast Ast, val ...Value) []Value {
  212. return []Value{ast.Value()}
  213. }
  214. func (astkind AstMetaKindType) Eval(vm *VM, ast Ast, val ...Value) []Value {
  215. return []Value{ast.Value()}
  216. }
  217. func (astkind AstMetaKindValue) Eval(vm *VM, ast Ast, val ...Value) []Value {
  218. return []Value{ast.Value()}
  219. }
  220. func (astkind AstMetaKindEnd) Eval(vm *VM, ast Ast, val ...Value) []Value {
  221. return val
  222. }
  223. func (astkind AstMetaKindError) Eval(vm *VM, ast Ast, val ...Value) []Value {
  224. return []Value{ast.Value()}
  225. }
  226. func (astkind AstMetaKindFlatten) Eval(vm *VM, ast Ast, val ...Value) []Value {
  227. return ReturnEmpty()
  228. }
  229. type AstKind interface {
  230. String() string
  231. Eval(vm *VM, ast Ast, val ...Value) []Value
  232. IsLeaf() bool
  233. }
  234. /*
  235. func (Ast Ast) String() string {
  236. switch astkind {
  237. case AstMetaKindProgram:
  238. return "AstMetaKindProgram"
  239. case AstMetaKindStatements:
  240. return "AstMetaKindStatements"
  241. case AstMetaKindStatement:
  242. return "AstMetaKindStatement"
  243. case AstMetaKindSet:
  244. return "AstMetaKindSet"
  245. case AstMetaKindGet:
  246. return "AstMetaKindGet"
  247. case AstMetaKindTarget:
  248. return "AstMetaKindTarget"
  249. case AstMetaKindCommand:
  250. return "AstMetaKindCommand"
  251. case AstMetaKindArguments:
  252. return "AstMetaKindArguments"
  253. case AstMetaKindArgument:
  254. return "AstMetaKindArgument"
  255. case AstMetaKindExpression:
  256. return "AstMetaKindExpression"
  257. case AstMetaKindBlock:
  258. return "AstMetaKindBlock"
  259. case AstMetaKindParenthesis:
  260. return "AstMetaKindParenthesis"
  261. case AstMetaKindList:
  262. return "AstMetaKindList"
  263. case AstMetaKindCapture:
  264. return "AstMetaKindCapture"
  265. case AstMetaKindWordValue:
  266. return "AstMetaKindWordValue"
  267. case AstMetaKindWord:
  268. return "AstMetaKindWord"
  269. case AstMetaKindType:
  270. return "AstMetaKindType"
  271. case AstMetaKindValue:
  272. return "AstMetaKindValue"
  273. case AstMetaKindEnd:
  274. return "AstMetaKindEnd"
  275. case AstMetaKindError:
  276. return "AstMetaKindError"
  277. default:
  278. return "Unknown AstMetaKind"
  279. }
  280. }
  281. */
  282. /*
  283. func AstAppendChild(parent Ast, child Ast) Ast {
  284. basicParent := parent.(*Ast)
  285. return basicParent.AppendChild(child)
  286. }
  287. func AstNewChild(parent Ast, kind AstMetaKind, token Token) Ast {
  288. basicParent := parent.(*Ast)
  289. return basicParent.NewChild(kind, token)
  290. }
  291. */
  292. /* AST node kind */
  293. type Ast struct {
  294. AstKind
  295. parent *Ast
  296. children []*Ast
  297. token Token
  298. }
  299. func (ast Ast) Value() Value {
  300. return ast.token.Value
  301. }
  302. func NewAst(kind AstKind, parent *Ast, children []*Ast, token Token) *Ast {
  303. ast := &Ast{AstKind: kind, parent: parent, token: token}
  304. return ast.AppendChildren(children...)
  305. }
  306. func (ast *Ast) AppendChildren(children ...*Ast) *Ast {
  307. for _, child := range children {
  308. ast.AppendChild(child)
  309. }
  310. return ast
  311. }
  312. func (ast *Ast) AppendChild(child * Ast) *Ast {
  313. child.SetParent(ast)
  314. ast.children = append(ast.children, child)
  315. return child
  316. }
  317. func (ast *Ast) NewChild(kind AstKind, token Token) *Ast {
  318. child := NewAst(kind, ast, make([]*Ast, 0), token)
  319. ast.AppendChild(child)
  320. return child
  321. }
  322. func (ast Ast) IsKind(astkind AstKind) bool {
  323. return ast.AstKind == astkind
  324. }
  325. func (ast Ast) IsError() bool {
  326. return ast.AstKind == AstKindError
  327. }
  328. func (ast Ast) IsNone() bool {
  329. return ast.AstKind == AstKindNone
  330. }
  331. func (ast Ast) IsFlatten() bool {
  332. return ast.AstKind == AstKindFlatten
  333. }
  334. func (ast Ast) Token() Token {
  335. return ast.token
  336. }
  337. func (ast Ast) Parent() *Ast {
  338. return ast.parent
  339. }
  340. func (ast Ast) Children() []*Ast {
  341. return ast.children
  342. }
  343. func (ast Ast) Kind() AstKind {
  344. return ast.AstKind
  345. }
  346. func (ast *Ast) SetParent(parent *Ast) {
  347. ast.parent = parent
  348. }
  349. func (ast Ast) Child(index int) *Ast {
  350. count := ast.CountChildren()
  351. if index < 0 || index > count {
  352. return nil
  353. }
  354. return ast.children[index]
  355. }
  356. func (ast Ast) Eval(vm *VM, val ...Value) []Value {
  357. res := ast.AstKind.Eval(vm, ast, val...)
  358. if vm != nil && vm.Tracer != nil {
  359. vm.Trace("%v: Eval: %v", ast, res)
  360. }
  361. return res
  362. }
  363. func (ast *Ast) Walk(walker func(node *Ast) *Ast) *Ast {
  364. if found := walker(ast); found != nil {
  365. return found
  366. }
  367. for _, child := range ast.children {
  368. if found := child.Walk(walker); found != nil {
  369. return found
  370. }
  371. }
  372. return nil
  373. }
  374. func (ast Ast) String() string {
  375. return fmt.Sprintf("Ast %s: %s", ast.AstKind.String(), ast.token.String())
  376. }
  377. func (ast Ast) Display() {
  378. ast.Walk(func(node *Ast) *Ast {
  379. depth := node.Depth()
  380. fmt.Printf("%s", strings.Repeat("--", depth))
  381. if node != nil {
  382. fmt.Printf("Ast: %s\n", node.String())
  383. } else {
  384. fmt.Printf("Ast: nil node\n")
  385. }
  386. return nil
  387. })
  388. }
  389. func (ast Ast) Dump() string {
  390. result := ""
  391. ast.Walk(func(node *Ast) *Ast {
  392. depth := node.Depth()
  393. result += fmt.Sprintf("%s", strings.Repeat("--", depth))
  394. if node != nil {
  395. result += fmt.Sprintf("Ast: %s\n", node.String())
  396. } else {
  397. result += fmt.Sprintf("Ast: nil node\n")
  398. }
  399. return nil
  400. })
  401. return result
  402. }
  403. func (ast Ast) Depth() int {
  404. var depth int = 0
  405. parent := ast.Parent()
  406. for parent != nil {
  407. depth++
  408. parent = parent.Parent()
  409. }
  410. return depth
  411. }
  412. func (ast Ast) CountChildren() int {
  413. return len(ast.children)
  414. }
  415. func AstIsError(ast * Ast) bool {
  416. return ast.IsError()
  417. }
  418. func (ast Ast) Errors() []*Ast {
  419. res := make([]*Ast, 0)
  420. ast.Walk(func(node *Ast) *Ast {
  421. if node != nil && ast.IsError() {
  422. res = append(res, node)
  423. }
  424. return nil
  425. })
  426. return res
  427. }
  428. func EmptyAstArray() []*Ast {
  429. return make([]*Ast, 0)
  430. }
  431. func NewEmptyAst(astkind AstKind) *Ast {
  432. return NewAst(astkind, nil, EmptyAstArray(), NoToken())
  433. }
  434. func NewAstNone() *Ast {
  435. return NewEmptyAst(AstKindNone)
  436. }
  437. func NewAstWithToken(astkind AstKind, token Token) *Ast {
  438. return NewAst(astkind, nil, EmptyAstArray(), token)
  439. }
  440. // If AST has errors, return it as a merged error, otherwise returns nil
  441. func (ast *Ast) ToError() error {
  442. errlist := ast.Errors()
  443. if len(errlist) < 1 {
  444. return nil
  445. }
  446. sep := ""
  447. res := ""
  448. for _, err := range errlist {
  449. res = fmt.Sprintf("%s%s%s", res, sep, err)
  450. sep = "\n"
  451. }
  452. return fmt.Errorf("%s", res)
  453. }
  454. func (from Ast) Convert(to interface{}) error {
  455. switch toPtr := to.(type) {
  456. case *Ast:
  457. (*toPtr) = from
  458. default:
  459. return NewErrorValuef("Cannot convert Ast value %v to %v", from, to)
  460. }
  461. return nil
  462. }
  463. const TypeValueAst = TypeValue("Ast")
  464. func (ast Ast) Type() TypeValue {
  465. return TypeValueAst
  466. }
  467. /*
  468. type AstProgram struct{ Ast }
  469. type AstStatements struct{ Ast }
  470. type AstStatement struct{ Ast }
  471. type AstSet struct{ Ast }
  472. type AstGet struct{ Ast }
  473. type AstTarget struct{ Ast }
  474. type AstCommand struct{ Ast }
  475. type AstArguments struct{ Ast }
  476. type AstArgument struct{ Ast }
  477. type AstExpression struct{ Ast }
  478. type AstBlock struct{ Ast }
  479. type AstParenthesis struct{ Ast }
  480. type AstList struct{ Ast }
  481. type AstCapture struct{ Ast }
  482. type AstWordValue struct{ Ast }
  483. type AstWord struct{ Ast }
  484. type AstType struct{ Ast }
  485. type AstValue struct{ Ast }
  486. type AstEnd struct{ Ast }
  487. type AstError struct{ Ast }
  488. */
  489. var _ Ast = Ast{}
  490. /* The kind of an AST is also it's constructor function. This is so deep I'm almost
  491. getting scared. :) */
  492. // The type is defined as a constructor
  493. /*
  494. type AstMetaKind func(parent Ast, children []Ast, token Token) Ast
  495. type AstMetaKind2 interface {
  496. New(parent Ast, children []Ast, token Token) Ast
  497. }
  498. type AstTypeProgramImp struct{}
  499. func (ap AstTypeProgramImp) New(parent Ast, children []Ast, token Token) Ast {
  500. return AstProgram{NewBasicAst(parent, children, token)}
  501. }
  502. func NewAstProgram(parent Ast, children []Ast, token Token) Ast {
  503. return AstProgram{NewBasicAst(parent, children, token)}
  504. }
  505. var AstMetaKindBasic = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast { return NewBasicAst(parent, children, token) })
  506. var AstMetaKindProgram = AstMetaKind(NewAstProgram)
  507. var AstMetaKindProgram2 = AstMetaKind2(AstTypeProgramImp{})
  508. var AstMetaKindStatements = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  509. return &AstStatements{NewBasicAst(parent, children, token)}
  510. })
  511. var AstMetaKindStatement = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  512. return &AstStatement{NewBasicAst(parent, children, token)}
  513. })
  514. var AstMetaKindSet = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  515. return &AstSet{NewBasicAst(parent, children, token)}
  516. })
  517. var AstMetaKindGet = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  518. return &AstGet{NewBasicAst(parent, children, token)}
  519. })
  520. var AstMetaKindTarget = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  521. return &AstTarget{NewBasicAst(parent, children, token)}
  522. })
  523. var AstMetaKindCommand = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  524. return &AstCommand{NewBasicAst(parent, children, token)}
  525. })
  526. var AstMetaKindArguments = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  527. return &AstArguments{NewBasicAst(parent, children, token)}
  528. })
  529. var AstMetaKindArgument = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  530. return &AstArgument{NewBasicAst(parent, children, token)}
  531. })
  532. var AstMetaKindExpression = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  533. return &AstExpression{NewBasicAst(parent, children, token)}
  534. })
  535. var AstMetaKindBlock = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  536. return &AstBlock{NewBasicAst(parent, children, token)}
  537. })
  538. var AstMetaKindParenthesis = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  539. return &AstParenthesis{NewBasicAst(parent, children, token)}
  540. })
  541. var AstMetaKindList = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  542. return &AstList{NewBasicAst(parent, children, token)}
  543. })
  544. var AstMetaKindCapture = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  545. return &AstCapture{NewBasicAst(parent, children, token)}
  546. })
  547. var AstMetaKindWordValue = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  548. return &AstWordValue{NewBasicAst(parent, children, token)}
  549. })
  550. var AstMetaKindWord = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  551. return &AstWord{NewBasicAst(parent, children, token)}
  552. })
  553. var AstMetaKindType = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  554. return &AstType{NewBasicAst(parent, children, token)}
  555. })
  556. var AstMetaKindValue = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  557. return &AstValue{NewBasicAst(parent, children, token)}
  558. })
  559. var AstMetaKindEnd = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  560. return &AstEnd{NewBasicAst(parent, children, token)}
  561. })
  562. var AstMetaKindError = AstMetaKind(func(parent Ast, children []Ast, token Token) Ast {
  563. return &AstError{NewBasicAst(parent, children, token)}
  564. })
  565. */