parser: lazy support

This commit is contained in:
alex committed 2023-10-14 03:28:07 -07:00
1 parent e96bcd8754
commit 9338b01b48
25 files changed
+159 -118

No files matched your search

@@ -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)) }