Mercurial > p > roundup > code
comparison roundup/token_r.py @ 7859:9a74dfeb8620
feat: can use escaped tokens inside quotes including quotes.
Change tokenizer to support:
cmd with arg "string with embedded \" double quote"
works for single quotes too. Mixed quotes can skip the \" or \'
escaping.
Also:
quoted cmds args "can include \n newline, \t tab and \r return"
Added a doc example, also tests for new feature.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 06 Apr 2024 20:37:45 -0400 |
| parents | 07ce4e4110f5 |
| children |
comparison
equal
deleted
inserted
replaced
| 7858:376f70513242 | 7859:9a74dfeb8620 |
|---|---|
| 94 elif c == '\\': | 94 elif c == '\\': |
| 95 pos = pos + 1 | 95 pos = pos + 1 |
| 96 oldstate = state | 96 oldstate = state |
| 97 state = ESCAPE | 97 state = ESCAPE |
| 98 continue | 98 continue |
| 99 elif state == QUOTE and c == '\\': | |
| 100 # in a quoted token and found an escape sequence | |
| 101 pos = pos + 1 | |
| 102 oldstate = state | |
| 103 state = ESCAPE | |
| 104 continue | |
| 99 elif state == QUOTE and c == quotechar: | 105 elif state == QUOTE and c == quotechar: |
| 100 # in a quoted token and found a matching quote char | 106 # in a quoted token and found a matching quote char |
| 101 pos = pos + 1 | 107 pos = pos + 1 |
| 102 # now we're looking for whitespace | 108 # now we're looking for whitespace |
| 103 state = TOKEN | 109 state = TOKEN |
