buildParserFor
Creates the default lexer and parser for source, then invokes continuation with both.
This helper does not translate exceptions thrown by lexing, parsing, or continuation.
Return
the value returned by continuation
Throws
if requested source text is invalid
Creates the default lexer and parser for a synchronous chunk source.
Input remains lazy and is pulled only when continuation requests tokens.
Return
the value returned by continuation
Throws
if reading, lexing, or parsing requested input fails
Creates the default lexer and parser for input, identified diagnostically by id.
val tree = buildParserFor("f(X).", id = "query") { parser, source ->
parser.parseClause(source)
}Return
the value returned by continuation
Throws
if requested input is invalid
Creates a lazy lexer and parser over input, then invokes continuation.
FileReader("program.pl").use { reader ->
buildParserFor(reader, autoClose = false) { parser, source ->
parser.parseTheory(source)
}
}autoClose controls whether EOF closes input. Reading and lexing still occur only as tokens are requested by continuation.
Return
the value returned by continuation
Throws
if chunkSize is not positive
if reading, lexing, or parsing requested input fails