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 }
// 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 }
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()) } }
func (cp *compiler) compoundOp(n *parse.Compound) ValuesOp { return ValuesOp{cp.compound(n), n.Begin(), n.End()} }
func isFormHead(compound *parse.Compound) bool { if form, ok := compound.Parent().(*parse.Form); ok { return form.Head == compound } return false }