diff options
Diffstat (limited to 'format/fastxml/parser.ha')
-rw-r--r-- | format/fastxml/parser.ha | 76 |
1 files changed, 39 insertions, 37 deletions
diff --git a/format/fastxml/parser.ha b/format/fastxml/parser.ha index 8f7705a..f970ac5 100644 --- a/format/fastxml/parser.ha +++ b/format/fastxml/parser.ha @@ -518,48 +518,50 @@ fn quote(par: *parser) (rune | error) = { }; }; -fn want(par: *parser, tok: (rune | str | whitespace)...) (bool | error) = { +fn want(par: *parser, tokens: (rune | str | whitespace)...) (bool | error) = { let hadws = false; - for (let i = 0z; i < len(tok); i += 1) match (tok[i]) { - case let x: rune => - let have = match (scanrune(par)?) { - case io::EOF => - return par.line: syntaxerr; - case let rn: rune => - yield rn; - }; - if (have != x) { - return par.line: syntaxerr; - }; - if (x == '\n') { - par.line += 1; - }; - case let x: str => - let iter = strings::iter(x); - for (true) match (strings::next(&iter)) { - case let rn: rune => - want(par, rn)?; - case void => - break; - }; - case let ws: whitespace => - let n = 0; - for (true; n += 1) match (scanrune(par)?) { - case io::EOF => - break; - case let rn: rune => - if (!ascii::isspace(rn)) { - unreadrune(par, rn); - break; + for (let tok .. tokens) { + match (tok) { + case let x: rune => + let have = match (scanrune(par)?) { + case io::EOF => + return par.line: syntaxerr; + case let rn: rune => + yield rn; }; - if (rn == '\n') { + if (have != x) { + return par.line: syntaxerr; + }; + if (x == '\n') { par.line += 1; }; + case let x: str => + let iter = strings::iter(x); + for (true) match (strings::next(&iter)) { + case let rn: rune => + want(par, rn)?; + case done => + break; + }; + case let ws: whitespace => + let n = 0; + for (true; n += 1) match (scanrune(par)?) { + case io::EOF => + break; + case let rn: rune => + if (!ascii::isspace(rn)) { + unreadrune(par, rn); + break; + }; + if (rn == '\n') { + par.line += 1; + }; + }; + if (ws && n < 1) { + return par.line: syntaxerr; + }; + hadws = n >= 1; }; - if (ws && n < 1) { - return par.line: syntaxerr; - }; - hadws = n >= 1; }; return hadws; }; |