ast.go 20 KB

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