Skip to content

Commit ac4540c

Browse files
committed
Update README to include mention of logging
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.
1 parent 85eb8e4 commit ac4540c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/main/doc/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ while introducing support for those that were completely absent from the origina
99
Highlights include:
1010

1111
- Incremental abstract syntax tree edits
12+
- Parser and lexer debugging through loggers
1213
- APIs for querying parsed abstract syntax trees
1314
- Support for both macOS and Linux out of the box
1415
- A wide range of languages [supported](.gitmodules) out of the box
@@ -205,5 +206,27 @@ public class Example {
205206
}
206207
```
207208

209+
If you would like to debug the parsing process, you can attach loggers directly to a `Parser`:
210+
211+
```java
212+
import ch.usi.si.seart.treesitter.*;
213+
import org.slf4j.*;
214+
215+
public class Example {
216+
217+
// init omitted...
218+
219+
public static void main(String[] args) {
220+
Logger logger = LoggerFactory.getLogger(Example.class);
221+
try (Parser parser = Parser.getFor(Language.PYTHON)) {
222+
parser.setLogger(logger);
223+
parser.parse("pass").close();
224+
} catch (Exception ex) {
225+
// ...
226+
}
227+
}
228+
}
229+
```
230+
208231
For more usage examples, take a look at the [tests](src/test/java/ch/usi/si/seart/treesitter).
209232
You can also refer to the full documentation [here](https://javadoc.io/doc/ch.usi.si.seart/java-tree-sitter/latest/index.html).

0 commit comments

Comments
 (0)