()
| 236 | func (p Pattern) Verb() string { return p.verb } |
| 237 | |
| 238 | func (p Pattern) String() string { |
| 239 | var stack []string |
| 240 | for _, op := range p.ops { |
| 241 | switch op.code { |
| 242 | case utilities.OpNop: |
| 243 | continue |
| 244 | case utilities.OpPush: |
| 245 | stack = append(stack, "*") |
| 246 | case utilities.OpLitPush: |
| 247 | stack = append(stack, p.pool[op.operand]) |
| 248 | case utilities.OpPushM: |
| 249 | stack = append(stack, "**") |
| 250 | case utilities.OpConcatN: |
| 251 | n := op.operand |
| 252 | l := len(stack) - n |
| 253 | stack = append(stack[:l], strings.Join(stack[l:], "/")) |
| 254 | case utilities.OpCapture: |
| 255 | n := len(stack) - 1 |
| 256 | stack[n] = fmt.Sprintf("{%s=%s}", p.vars[op.operand], stack[n]) |
| 257 | } |
| 258 | } |
| 259 | segs := strings.Join(stack, "/") |
| 260 | if p.verb != "" { |
| 261 | return fmt.Sprintf("/%s:%s", segs, p.verb) |
| 262 | } |
| 263 | return "/" + segs |
| 264 | } |
| 265 | |
| 266 | /* |
| 267 | * The following code is adopted and modified from Go's standard library |
no outgoing calls