diff --git a/docs/section-2-using-parsers.md b/docs/section-2-using-parsers.md index 499ddce6..5d351720 100644 --- a/docs/section-2-using-parsers.md +++ b/docs/section-2-using-parsers.md @@ -267,7 +267,7 @@ For example, consider this ERB document: ``` -Conceptually, it can be represented by three syntax trees with overlapping ranges: an ERB syntax tree, a Ruby syntax tree, and an HTML syntax tree. You could generate these syntax trees as follows: +Conceptually, it can be represented by three syntax trees with overlapping ranges: an ERB syntax tree, a Ruby syntax tree, and an HTML syntax tree. You could generate these syntax trees with the following code: ```c #include @@ -288,9 +288,9 @@ int main(int argc, const char **argv) { TSTree *erb_tree = ts_parser_parse_string(parser, NULL, text, len); TSNode erb_root_node = ts_tree_root_node(erb_tree); - // Find the ranges of the `content` nodes, which represent - // the underlying HTML, and the `code` nodes, which represent - // the interpolated Ruby. + // In the ERB syntax tree, find the ranges of the `content` nodes, + // which represent the underlying HTML, and the `code` nodes, which + // represent the interpolated Ruby. TSRange html_ranges[10]; TSRange ruby_ranges[10]; unsigned html_range_count = 0; @@ -340,6 +340,8 @@ int main(int argc, const char **argv) { } ``` +This API allows for great flexibility in how languages can be composed. Tree-sitter is not responsible for mediating the interactions between languages. Instead, you are free to do that using arbitrary application-specific logic. + ## Concurrency Tree-sitter supports multi-threaded use cases by making syntax trees very cheap to copy.