package parse

import 

// Node represents a parse tree as well as an AST.
type Node interface {
	diag.Ranger
	parse(*parser)
	n() *node
}

type node struct {
	diag.Ranging
	sourceText string
	parent     Node
	children   []Node
}

func ( *node) () *node { return  }

func ( *node) ( Node) { .children = append(.children, ) }

// Range returns the range within the full source text that parses to the node.
func ( *node) () diag.Ranging { return .Ranging }

// Parent returns the parent of a node. It returns nil if the node is the root
// of the parse tree.
func ( Node) Node { return .n().parent }

// SourceText returns the part of the source text that parses to the node.
func ( Node) string { return .n().sourceText }

// Children returns all children of the node in the parse tree.
func ( Node) []Node { return .n().children }