示例#1
0
文件: must.go 项目: zhsj/elvish
func mustPrimary(cp *compiler, cn *parse.Compound, msg string) *parse.Primary {
	p := onePrimary(cn)
	if p == nil {
		cp.errorpf(cn.Begin(), cn.End(), msg)
	}
	return p
}
示例#2
0
文件: must.go 项目: zhsj/elvish
// mustString musts that a Compound contains exactly one Primary of type
// Variable.
func mustString(cp *compiler, cn *parse.Compound, msg string) string {
	s, ok := oneString(cn)
	if !ok {
		cp.errorpf(cn.Begin(), cn.End(), msg)
	}
	return s
}
示例#3
0
文件: stylist.go 项目: elves/elvish
func (s *Stylist) formHead(n *parse.Compound) {
	simple, head, err := simpleCompound(n, nil)
	st := styles{}
	if simple {
		if goodFormHead(head, s.editor) {
			st = styleForGoodCommand
		} else {
			st = styleForBadCommand
		}
	} else if err != nil {
		st = styleForBadCommand
	}
	if len(st) > 0 {
		s.add(st.String(), n.Begin(), n.End())
	}
}
示例#4
0
func (cp *compiler) compoundOp(n *parse.Compound) ValuesOp {
	return ValuesOp{cp.compound(n), n.Begin(), n.End()}
}
示例#5
0
文件: nodeutil.go 项目: zhsj/elvish
func isFormHead(compound *parse.Compound) bool {
	if form, ok := compound.Parent().(*parse.Form); ok {
		return form.Head == compound
	}
	return false
}