MCPcopy Create free account
hub / github.com/decomp/decomp / split

Function split

cmd/go-post/typecheck.go:630–665  ·  view source on GitHub ↗

split splits "int, float" into ["int", "float"] and splits "" into [].

(s string)

Source from the content-addressed store, hash-verified

628
629// split splits "int, float" into ["int", "float"] and splits "" into [].
630func split(s string) []string {
631 out := []string{}
632 i := 0 // current type being scanned is s[i:j].
633 nparen := 0
634 for j := 0; j < len(s); j++ {
635 switch s[j] {
636 case ' ':
637 if i == j {
638 i++
639 }
640 case '(':
641 nparen++
642 case ')':
643 nparen--
644 if nparen < 0 {
645 // probably can't happen
646 return nil
647 }
648 case ',':
649 if nparen == 0 {
650 if i < j {
651 out = append(out, s[i:j])
652 }
653 i = j + 1
654 }
655 }
656 }
657 if nparen != 0 {
658 // probably can't happen
659 return nil
660 }
661 if i < len(s) {
662 out = append(out, s[i:])
663 }
664 return out
665}
666
667// join is the inverse of split.
668func join(x []string) string {

Callers 2

typecheck1Function · 0.85
splitFuncFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected