parser: lazy support

This commit is contained in:
2023-10-14 03:28:07 -07:00
parent e96bcd8754
commit 9338b01b48
25 changed files with 159 additions and 118 deletions

View File

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