github.com/elves/Elvish@v0.12.0/parse/node.go (about)

     1  package parse
     2  
     3  // Node represents a parse tree as well as an AST.
     4  type Node interface {
     5  	n() *node
     6  	Parent() Node
     7  	Begin() int
     8  	End() int
     9  	SourceText() string
    10  	Children() []Node
    11  }
    12  
    13  type node struct {
    14  	parent     Node
    15  	begin, end int
    16  	sourceText string
    17  	children   []Node
    18  }
    19  
    20  func (n *node) n() *node {
    21  	return n
    22  }
    23  
    24  func (n *node) Parent() Node {
    25  	return n.parent
    26  }
    27  
    28  func (n *node) Begin() int {
    29  	return n.begin
    30  }
    31  
    32  func (n *node) End() int {
    33  	return n.end
    34  }
    35  
    36  func (n *node) SourceText() string {
    37  	return n.sourceText
    38  }
    39  
    40  func (n *node) Children() []Node {
    41  	return n.children
    42  }