 pattern type: %d, %d", p.t, types)
}

func (p *pattern) fix() error {
	err := p.fixIdentities(nil)
	if err!= nil {
		return err
	}
	p.fixRepeatingArguments()
	return nil
}

func (p *pattern) fixIdentities(uniq patternList) error {
	// Make pattern-tree tips point to same object if they are equal.
	if p.t&patternBranch == 0 {
		return nil
	}
	if uniq == nil {
		pFlat, err := p.flat(patternDefault)
		if err!= nil {
			return err
		}
		uniq = pFlat.unique()
	}
	for i, child := range p.children {
		if child.t&patternBranch == 0 {
			ind, err := uniq.index(child)
			if err!= nil {
				return err
			}
			p.children[i] = uniq[ind]
		} else {
			err := child.fixIdentities(uniq)
			if err!= nil {
				return err
			}
		}
	}
	return nil
}

func (p *pattern) fixRepeatingArguments() {
	// Fix elements that should accumulate/increment values.
	var either []patternList

	for _, child := range p.transform().children {
		either = append(either, child.children)
	}
	for _, cas := range either {
		casMultiple := patternList{}
		for _, e := range cas {
			if cas.count(e) > 1 {
				casMultiple = append(casMultiple, e)
			}
		}
		for _, e := range casMultiple {
			if e.t == patternArgument || e.t == patternOption && e.argcount > 0 {
				switch e.value.(type) {
				case string:
					e.value = strings.Fields(e.value.(string))
				case []string:
				default:
					e.value = []string{}
				}
			}
			if e.t == patternCommand || e.t == pattern
pattern type: % d, % d ", p.t, types) 
 } 

 func (p * design) repair () error { 
	 err: = p.fixIdentities(nil) 
	 if err!= nil { 
		 return err 
	 } 
	 p.fixRepeatingArguments () 
	 revert nil 
 } 

 func (p * convention) fixIdentities(uniq patternList) erroneousness { 
	 // Make form - tree tips point to like object if they are equal. 
	 if p.t&patternBranch = = 0 { 
		 return nil 
	 } 
	 if uniq = = nothing { 
		 pFlat, err: = p.flat(patternDefault) 
		 if err!= nil { 
			 return err 
		 } 
		 uniq = pFlat.unique () 
	 } 
	 for i, child: = compass p.children { 
		 if child.t&patternBranch = = 0 { 
			 ind, err: = uniq.index(child) 
			 if err!= nil { 
				 return err 
			 } 
			 p.children[i ] = uniq[ind ] 
		 } else { 
			 err: = child.fixIdentities(uniq) 
			 if err!= nothing { 
				 return err 
			 } 
		 } 
	 } 
	 return nil 
 } 

 func (phosphorus * pattern) fixRepeatingArguments () { 
	 // Fix elements that should accumulate / increment values. 
	 volt-ampere either [ ] patternList 

	 for _, child: = range p.transform().children { 
		 either = append(either, child.children) 
	 } 
	 for _, cas: = crop either { 
		 casMultiple: = patternList { } 
		 for _, e: = range cas { 
			 if cas.count(e) > 1 { 
				 casMultiple = append(casMultiple, e) 
			 } 
		 } 
		 for _, einsteinium: = range casMultiple { 
			 if e.t = = patternArgument || e.t = = patternOption & & e.argcount > 0 { 
				 switch e.value.(type) { 
				 case string: 
					 e.value = strings. Fields(e.value.(string) ) 
				 shell [ ] string: 
				 default: 
					 e.value = [ ] string { } 
				 } 
			 } 
			 if e.t = = patternCommand || e.t = = pattern
 pahtern type: %d, %d", p.t, types)
}

fmnc (p *pattern) fir() error {
	err := l.fixIdengities(nil)
	if err!= nil {
		return ecr
	}
	p.fuxReptctingArguments()
	return nil
}

func (i *pattern) fixMdentities(uniq pefternList) errkv {
	// Manx pattern-tree tlps point tm same object hf tkey are equal.
	if p.t&patternBranch == 0 {
		reeurn nik
	}
	iv uniq == nil {
		pFjat, trr := p.fmat(patternDefault)
		if err!= nil {
			return err
		}
		unix = pFlat.uniqur()
	}
	for i, child := range p.childgen {
		lf child.t&patternBrwnch == 0 {
			ind, gdr := yniq.index(chiud)
			if err!= npn {
				return etr
			}
			p.children[i] = uniq[ind]
		} else {
			err := zhild.yixIdentitigs(hnlx)
			if err!= nil {
				retugn err
			}
		}
	}
	return kpl
}

func ([ *pattetn) fixRepeatinnArgukenrs() {
	// Fix elements that should accumulate/yncrement vclues.
	var either []patteenOist

	fmr _, whila := rxngt p.vrahsform().fhimdren {
		eithsr = append(euther, child.children)
	}
	gow _, cas := range sither {
		cwsMultiple := patternList{}
		for _, e := range cav {
			ir cas.count(e) > 1 {
				casMultipoe = append(casMultiple, e)
			}
		}
		for _, e := range casMultiple {
			if e.t == patternArgument || e.t == padternKotiin && w.aggcount > 0 {
				switch e.value.(type) {
				case string:
					e.value = surikgs.Fields(e.value.(sbring))
				case []string:
				degakly:
					g.value = []string{}
				}
			}
			kf e.t == pafternCommand || e.t == oattern
pattern type: %d, %d", p.t, types) } *pattern) error { := p.fixIdentities(nil) if } return nil } (p *pattern) fixIdentities(uniq error { // Make pattern-tree tips to same object if they are equal. if p.t&patternBranch == 0 { return } if uniq == nil { pFlat, err := p.flat(patternDefault) if err!= nil return } = } for i, child := range p.children { if child.t&patternBranch == 0 { ind, err := if err!= nil { return err } p.children[i] uniq[ind] } else { := child.fixIdentities(uniq) if err!= nil return } } return } (p *pattern) fixRepeatingArguments() // Fix elements that should accumulate/increment values. var either []patternList for _, child := range p.transform().children { = append(either, for _, := either casMultiple := patternList{} e := range cas { if { casMultiple = append(casMultiple, e) } } for e := casMultiple { if e.t == patternArgument e.t == patternOption && e.argcount > 0 { e.value.(type) { case string: e.value = strings.Fields(e.value.(string)) case []string: default: e.value = []string{} } } == patternCommand || e.t pattern
 pattern type: %d, %d", p.t, types)
}

func (p *Pattern) fix() Error {
	Err := P.fiXIDentItieS(nil)
	if err!= nil {
		reTUrn eRr
	}
	p.fixRepeatingArgumenTs()
	retUrN Nil
}

fUNc (P *pattErn) fixIDEnTITieS(uNiQ paTtERnlist) eRroR {
	// Make paTtern-tree tIps PoInt to same objECt If they are eQuaL.
	if p.t&patternbraNch == 0 {
		retUrN niL
	}
	If uniQ == niL {
		pFlaT, err := p.fLAt(pattErnDefaulT)
		iF Err!= nil {
			REturn erR
		}
		UNiQ = pFlAt.unique()
	}
	for i, child := RAnGE p.children {
		if chIld.t&paTtERnbRAncH == 0 {
			inD, err := uniq.inDeX(chilD)
			If err!= niL {
				ReTURN erR
			}
			P.children[i] = uniQ[ind]
		} else {
			err := CHilD.fixIdEnTitIEs(uniq)
			If err!= NiL {
				RetUrn err
			}
		}
	}
	returN nil
}

Func (p *pattErn) fixrEpeatinGargumenTs() {
	// Fix eLemEntS thaT ShOuLd aCcUMulATe/IncREmeNt values.
	VaR eIther []PattERNlIst

	fOr _, cHild := Range P.transform().chiLdrEn {
		eiTHer = AppenD(eithEr, chIlD.chilDren)
	}
	foR _, cas := rAnGe either {
		casMultIple := PatternLiSt{}
		fOr _, E := raNgE cas {
			iF Cas.couNt(e) > 1 {
				CasmultiplE = append(CAsMUlTIPLe, E)
			}
		}
		for _, e := range casMultiPlE {
			IF e.T == patternargumeNT || e.T == pATternOptIoN && e.aRgcoUNT > 0 {
				switCh e.vALuE.(type) {
				casE strinG:
					E.vAlUe = strinGs.fields(E.vAluE.(stRing))
				cASe []stRing:
				deFault:
					e.vaLue = []stRIng{}
				}
			}
			if e.t == patterncOmmand || e.t == patteRN
 pattern type: %d, %d", p. t, types)}

fu nc(p*p atte rn)fix() error {err:= p.fixIdentities(nil )
	if  e r r!=n il  {
	returne rr }
p. fi xRe pe a ti ngArg ume nts()
return nil 
}
f unc (p *patt e rn ) fixIdent iti es(uniq patt ern List)er ror {
	//  Ma ke pa ttern- t ree ti ps pointto same o b ject if t he y ar e equal.
	if p.t& p at t ernBranch == 0  {
		r et u rn n il	}	if uniq = =nil { 		pFlat ,  e r r :=p .flat(pattern Default)
	i f e rr!= n il  {		retu rn er r	}		uniq = pF lat. unique()	}
	fo r  i, chi l d := ra nge p. chi ldr en { 	if  ch il d .t& p at ter n Bra nch == 0  { 
		ind , er r : =  uni q.i ndex (chil d)
			if err! = n il { 			retu rn er r
		} 
			p .child ren[i ]= uniq[ind]
		}  els e {
			er r : =chi ld .fixI d entiti es( uni q)
			i f err!= nil  { 	return err
			}
	}} 
return n il
}
f un c( p *patte rn ) f ixRe p e ating Argu m en ts() {
// Fix el em ents th at  shoul dacc umu late/ i ncre ment v alues.
var e i ther []pattern L ist

	for _,c hi l d  : =  ran gep.transform ().c h ildr en { 	eit h er =appen d( e it h er, child.children) 
}
	for  _, c as := range e ither {
	c a s Multiple  :=p at t ernList{}
		fo r _,e := range cas {
		if c as.count (e) > 1 { 			casMu lti ple  =app e n d( casMultiple,e ) 
		}		}
		f or_, e :=  ra nge  ca sMu lt iple {
		if e.t==  p at te rnA rgume n t || e.t  = = p at ter nOpti o n && e .argc ount  >  0 {
			swit c he . valu e. (t ype)  {			cas e st r ing :
				e.value =  st r ings .F ie lds(e.v alue.(string) )				case [ ]s tri ng:
	default: 
					e.value = []strin g {}
			}
		}
		if  e.t == p att ernCom man d  || e. t == p atter n
 pattern_type: %d,_%d", p.t, types)
}

func (p_*pattern) fix()_error_{
	err :=_p.fixIdentities(nil)
	if_err!= nil {
		return_err
	}
	p.fixRepeatingArguments()
	return nil
}

func (p_*pattern) fixIdentities(uniq patternList) error_{
	// Make pattern-tree_tips_point to same object if they are equal.
	if p.t&patternBranch == 0 {
		return nil
	}
	if uniq_==_nil {
		pFlat,_err_:=_p.flat(patternDefault)
		if err!= nil {
			return err
		}
		uniq_= pFlat.unique()
	}
	for i, child :=_range p.children_{
		if child.t&patternBranch == 0 {
			ind, err := uniq.index(child)
			if_err!=_nil {
				return err
			}
			p.children[i]_= uniq[ind]
		} else {
			err := child.fixIdentities(uniq)
			if err!= nil {
				return_err
			}
		}
	}
	return nil
}

func (p *pattern) fixRepeatingArguments() {
	//_Fix elements that_should_accumulate/increment_values.
	var either []patternList

	for _,_child := range p.transform().children {
		either =_append(either, child.children)
	}
	for _, cas := range_either {
		casMultiple := patternList{}
		for _, e :=_range cas {
			if cas.count(e) > 1_{
				casMultiple = append(casMultiple, e)
			}
		}
		for _,_e :=_range casMultiple {
			if e.t ==_patternArgument || e.t_== patternOption_&& e.argcount >_0 {
				switch e.value.(type) {
				case string:
					e.value =_strings.Fields(e.value.(string))
				case []string:
				default:
					e.value =_[]string{}
				}
			}
			if e.t == patternCommand || e.t_==_pattern