gradle: 8.4 and parser: lazy tokenization

This commit is contained in:
2023-10-13 08:56:04 -07:00
parent 5078f38f61
commit e96bcd8754
8 changed files with 59 additions and 11 deletions

View File

@ -22,14 +22,14 @@ abstract class Tool {
val rootImportLocator: ImportLocator
get() = ImportLocator("local", rootFilePath())
fun tokenize(): TokenStream =
Tokenizer(createCharSource()).stream()
fun tokenize(): LazyTokenSource =
LazyTokenSource(Tokenizer(createCharSource()))
fun parse(attribution: NodeAttribution = DiscardNodeAttribution): CompilationUnit =
Parser(TokenStreamSource(tokenize()), attribution).parseCompilationUnit()
Parser(TokenStreamSource(tokenize().streamAllRemainingTokens()), attribution).parseCompilationUnit()
fun highlight(scheme: HighlightScheme): List<Highlight> =
Highlighter(scheme).highlight(tokenize())
Highlighter(scheme).highlight(tokenize().streamAllRemainingTokens())
fun reprint(): String = buildString { visit(Printer(this)) }