Beispiel #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
}
Beispiel #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
}
Beispiel #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())
	}
}
Beispiel #4
0
func (cp *compiler) compoundOp(n *parse.Compound) ValuesOp {
	return ValuesOp{cp.compound(n), n.Begin(), n.End()}
}