parse: More godoc.

This commit is contained in:
Qi Xiao 2018-10-13 14:03:58 +01:00
parent 15dd028dcb
commit 16f5c8c149
2 changed files with 11 additions and 1 deletions

View File

@ -24,6 +24,8 @@ func (n *node) n() *node {
return n
}
// Parent returns the parent node. If the node is the root of the syntax tree,
// the parent is nil.
func (n *node) Parent() Node {
return n.parent
}
@ -37,15 +39,17 @@ func (n *node) End() int {
}
// Range returns the range within the original (full) source text that parses
// into the node.
// to the node.
func (n *node) Range() diag.Ranging {
return diag.Ranging{n.begin, n.end}
}
// SourceText returns the part of the source text that parses to the node.
func (n *node) SourceText() string {
return n.sourceText
}
// Children returns all children of the node in the parse tree.
func (n *node) Children() []Node {
return n.children
}

View File

@ -1,4 +1,10 @@
// Package parse implements the elvish parser.
//
// The parser builds a hybrid of AST (abstract syntax tree) and parse tree
// (a.k.a. concrete syntax tree). The AST part only includes parts that are
// semantically important, and is embodied in the fields of each *Node type. The
// parse tree part corresponds to all the text in the original source text, and
// is embodied in the children of each *Node type.
package parse
//go:generate ./boilerplate.py