Tree-sitter: Documentation about tree node fields

Created on 10 Aug 2019  路  6Comments  路  Source: tree-sitter/tree-sitter

There are several grammars that use a field(...)-function to produce labelled syntax tree nodes, including Java and JS. The Grammar DSL docs do not mention it, however.

Am I missing something?

Most helpful comment

Yeah, I have a lot of documentation to write, after the last several months of changes. I guess I was waiting to write the docs until I've been using the feature internally for a while to get all of the problems worked out.

But it's pretty much done. So in the meantime, here's some info:

  • The concept was introduced in https://github.com/tree-sitter/tree-sitter/pull/271.
  • The only change to the Grammar API is the new field function which you pointed out.
  • The new C library APIs for dealing with fields are here and here.
  • If you're using the Node.js binding, its new APIs are described here.
  • If you're using the Rust binding, the new APIs are here and here.

All 6 comments

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

Yeah, I have a lot of documentation to write, after the last several months of changes. I guess I was waiting to write the docs until I've been using the feature internally for a while to get all of the problems worked out.

But it's pretty much done. So in the meantime, here's some info:

  • The concept was introduced in https://github.com/tree-sitter/tree-sitter/pull/271.
  • The only change to the Grammar API is the new field function which you pointed out.
  • The new C library APIs for dealing with fields are here and here.
  • If you're using the Node.js binding, its new APIs are described here.
  • If you're using the Rust binding, the new APIs are here and here.

@maxbrunsfeld Thanks for the quick response and the links!

As far as I can tell wasm only has field name? https://github.com/tree-sitter/tree-sitter/blame/master/lib/binding_web/tree-sitter-web.d.ts#L100

Will we get the id (no idea what's that for) and the child by field name function too?

Will we get the id (no idea what's that for) and the child by field name function too?

Yeah, I added the remaining bindings in https://github.com/tree-sitter/tree-sitter/commit/82fab90c0b91cc57a949b9d96768d7f3b7a621e4.

Was this page helpful?
0 / 5 - 0 ratings