parser, compiler: Support Table Actions
Continuous Integration / Grammar Tests (push) Has been cancelled
Continuous Integration / Library Tests (push) Has been cancelled
Continuous Integration / Library Format Tests (push) Has been cancelled

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-04-30 05:38:29 -04:00
parent 833979a5c9
commit b97aa1af72
6 changed files with 342 additions and 17 deletions
+17
View File
@@ -51,4 +51,21 @@ public struct Walker {
}
return Result.Ok(())
}
public func try_map<T>(n: Int, onlyNamed: Bool = false, todo: (Node) -> Result<T>) -> ([T], [Error]) {
var errors: [Error] = Array()
var results: [T] = Array()
for currentChildIdx in currentChildIdx..<n {
let currentChild = node.child(at: currentChildIdx)!
if onlyNamed && !currentChild.isNamed {
continue
}
switch todo(currentChild) {
case .Ok(let r): results.append(r)
case .Error(let e): errors.append(e)
}
}
return (results, errors)
}
}