about summary refs log tree commit diff
path: root/format
diff options
context:
space:
mode:
authorAlexey Yerin <yyp@disroot.org>2024-04-01 21:34:51 +0300
committerAlexey Yerin <yyp@disroot.org>2024-04-01 21:35:25 +0300
commit5b7571b7d91deef34ef92c8d9cf897320d3c8fab (patch)
tree4084b9717a2c79fd4ae98e9474e412e0fd43ba2b /format
parent49ae43171514e882c795166014edf94da0125033 (diff)
Update per for-each changes
Diffstat (limited to 'format')
-rw-r--r--format/fastxml/parser.ha76
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;
 };