Skip to content

Commit

Permalink
Update README to include mention of logging
Browse files Browse the repository at this point in the history
This is one of the features missing from the original library.
Seems to be a feature desired by the community according to:
serenadeai/java-tree-sitter#28.
Therefore, it makes sense to advertise this in the README.
  • Loading branch information
dabico committed Feb 15, 2024
1 parent 85eb8e4 commit ac4540c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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).

0 comments on commit ac4540c

Please sign in to comment.