ast.go 18 KB

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