mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
parse: Always use *ListNode for Term's
This commit is contained in:
parent
585e047ca5
commit
c925871ef4
|
@ -45,8 +45,7 @@ func evalFactor(n *parse.FactorNode) ([]string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func evalTerm(n_ parse.Node) ([]string, error) {
|
||||
n := n_.(*parse.ListNode)
|
||||
func evalTerm(n *parse.ListNode) ([]string, error) {
|
||||
words := make([]string, 0, len(n.Nodes))
|
||||
words = append(words, "")
|
||||
for _, m := range n.Nodes {
|
||||
|
@ -75,7 +74,7 @@ func evalTerm(n_ parse.Node) ([]string, error) {
|
|||
func evalTermList(ln *parse.ListNode) ([]string, error) {
|
||||
words := make([]string, 0, len(ln.Nodes))
|
||||
for _, n := range ln.Nodes {
|
||||
a, e := evalTerm(n)
|
||||
a, e := evalTerm(n.(*parse.ListNode))
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
|
|
|
@ -89,6 +89,8 @@ func newCommand(pos Pos) *CommandNode {
|
|||
return &CommandNode{ListNode: *newList(pos)}
|
||||
}
|
||||
|
||||
// A Term is represented by a ListNode of *FactorNode's.
|
||||
|
||||
// FactorNode represents a Factor. The embedded Node is either *ListNode or
|
||||
// *StringNode.
|
||||
type FactorNode struct {
|
||||
|
|
|
@ -257,7 +257,7 @@ loop:
|
|||
}
|
||||
|
||||
// Term = Factor { Factor }
|
||||
func (t *Tree) term() Node {
|
||||
func (t *Tree) term() *ListNode {
|
||||
term := newList(t.peek().Pos)
|
||||
term.append(t.factor())
|
||||
loop:
|
||||
|
|
|
@ -41,9 +41,9 @@ func newCloseRedir(fd uintptr) *CloseRedir {
|
|||
type FilenameRedir struct {
|
||||
redir
|
||||
Flag int
|
||||
Filename Node
|
||||
Filename *ListNode // a Term
|
||||
}
|
||||
|
||||
func newFilenameRedir(fd uintptr, flag int, filename Node) *FilenameRedir {
|
||||
func newFilenameRedir(fd uintptr, flag int, filename *ListNode) *FilenameRedir {
|
||||
return &FilenameRedir{redir{fd}, flag, filename}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user