(step hcl.Traverser, toks Tokens)
| 312 | } |
| 313 | |
| 314 | func appendTokensForTraversalStep(step hcl.Traverser, toks Tokens) Tokens { |
| 315 | switch ts := step.(type) { |
| 316 | case hcl.TraverseRoot: |
| 317 | toks = append(toks, &Token{ |
| 318 | Type: hclsyntax.TokenIdent, |
| 319 | Bytes: []byte(ts.Name), |
| 320 | }) |
| 321 | case hcl.TraverseAttr: |
| 322 | toks = append( |
| 323 | toks, |
| 324 | &Token{ |
| 325 | Type: hclsyntax.TokenDot, |
| 326 | Bytes: []byte{'.'}, |
| 327 | }, |
| 328 | &Token{ |
| 329 | Type: hclsyntax.TokenIdent, |
| 330 | Bytes: []byte(ts.Name), |
| 331 | }, |
| 332 | ) |
| 333 | case hcl.TraverseIndex: |
| 334 | toks = append(toks, &Token{ |
| 335 | Type: hclsyntax.TokenOBrack, |
| 336 | Bytes: []byte{'['}, |
| 337 | }) |
| 338 | toks = appendTokensForValue(ts.Key, toks) |
| 339 | toks = append(toks, &Token{ |
| 340 | Type: hclsyntax.TokenCBrack, |
| 341 | Bytes: []byte{']'}, |
| 342 | }) |
| 343 | default: |
| 344 | panic(fmt.Sprintf("unsupported traversal step type %T", step)) |
| 345 | } |
| 346 | |
| 347 | return toks |
| 348 | } |
| 349 | |
| 350 | func escapeQuotedStringLit(s string) []byte { |
| 351 | if len(s) == 0 { |
no test coverage detected