diff --git a/src/main/doc/README.md b/src/main/doc/README.md index 0cd16f94..d40c2062 100644 --- a/src/main/doc/README.md +++ b/src/main/doc/README.md @@ -9,6 +9,7 @@ while introducing support for those that were completely absent from the origina Highlights include: - Incremental abstract syntax tree edits +- Parser and lexer debugging through loggers - APIs for querying parsed abstract syntax trees - Support for both macOS and Linux out of the box - A wide range of languages [supported](.gitmodules) out of the box @@ -205,5 +206,27 @@ public class Example { } ``` +If you would like to debug the parsing process, you can attach loggers directly to a `Parser`: + +```java +import ch.usi.si.seart.treesitter.*; +import org.slf4j.*; + +public class Example { + + // init omitted... + + public static void main(String[] args) { + Logger logger = LoggerFactory.getLogger(Example.class); + try (Parser parser = Parser.getFor(Language.PYTHON)) { + parser.setLogger(logger); + parser.parse("pass").close(); + } catch (Exception ex) { + // ... + } + } +} +``` + For more usage examples, take a look at the [tests](src/test/java/ch/usi/si/seart/treesitter). You can also refer to the full documentation [here](https://javadoc.io/doc/ch.usi.si.seart/java-tree-sitter/latest/index.html).