Splits a string into a list of strings which are whitespace-separated tokens.
(self, s)
| 449 | t = self.token() |
| 450 | |
| 451 | def split(self, s): |
| 452 | """Splits a string into a list of strings which are whitespace-separated |
| 453 | tokens. |
| 454 | """ |
| 455 | vals = [] |
| 456 | self.input(s) |
| 457 | l = c = -1 |
| 458 | ws = "WS" |
| 459 | nl = "\n" |
| 460 | for t in self: |
| 461 | if t.type == ws: |
| 462 | continue |
| 463 | elif l < t.lineno: |
| 464 | vals.append(t.value) |
| 465 | elif len(vals) > 0 and c == t.lexpos: |
| 466 | vals[-1] = vals[-1] + t.value |
| 467 | else: |
| 468 | vals.append(t.value) |
| 469 | nnl = t.value.count(nl) |
| 470 | if nnl == 0: |
| 471 | l = t.lineno |
| 472 | c = t.lexpos + len(t.value) |
| 473 | else: |
| 474 | l = t.lineno + nnl |
| 475 | c = len(t.value.rpartition(nl)[-1]) |
| 476 | return vals |
| 477 | |
| 478 | # |
| 479 | # All the tokens recognized by the lexer |
no test coverage detected