Пример #1
0
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
// 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
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
func isFormHead(compound *parse.Compound) bool {
	if form, ok := compound.Parent().(*parse.Form); ok {
		return form.Head == compound
	}
	return false
}