func (t *template) write(re *syntax.Regexp) {
	switch re.Op {
	case syntax.OpLiteral:
		if t.level == 0 {
			for _, r := range re.Rune {
				t.buffer.WriteRune(r)
				if r == '%' {
					t.buffer.WriteRune('%')
				}
			}
		}
	case syntax.OpCapture:
		t.level++
		t.index++
		if t.level == 1 {
			t.groups = append(t.groups, re.Name)
			t.indices = append(t.indices, t.index)
			t.buffer.WriteString("%s")
		}
		for _, sub := range re.Sub {
			t.write(sub)
		}
		t.level--
	case syntax.OpConcat:
		for _, sub := range re.Sub {
			t.write(sub)
		}
	}
}
func (t *template) write(re *syntax.Regexp) {
	switch re.Op {
	case syntax.OpLiteral:
		if t.level == 0 {
			for _, r := range re.Rune {
				t.buffer.WriteRune(r)
				if r == '%' {
					t.buffer.WriteRune('%')
				}
			}
		}
	case syntax.OpCapture:
		t.level++
		t.index++
		if t.level == 1 {
			t.groups = append(t.groups, re.Name)
			t.indices = append(t.indices, t.index)
			t.buffer.WriteString("%s")
		}
		for _, sub := range re.Sub {
			t.write(sub)
		}
		t.level--
	case syntax.OpConcat:
		for _, sub := range re.Sub {
			t.write(sub)
		}
	}
}
func ( t * template ) write ( re * syntax . Regexp ) { switch re . Op { case syntax . OpLiteral : if t . level == 0 { for _ , r := range re . Rune { t . buffer . WriteRune ( r ) if r == '%' { t . buffer . WriteRune ( '%' ) } } } case syntax . OpCapture : t . level ++ t . index ++ if t . level == 1 { t . groups = append ( t . groups , re . Name ) t . indices = append ( t . indices , t . index ) t . buffer . WriteString ( " " ) } for _ , sub := range re . Sub { t . write ( sub ) } t . level -- case syntax . OpConcat : for _ , sub := range re . Sub { t . write ( sub ) } } }
// write writes a reverse template to the buffer.
write writes a reverse template to the buffer .