aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/scripts/test_ports/vcpkg-ci-tree-sitter/project/main.c
blob: cab3ce6878b4645e0910be170c957de4d56b973e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <string.h>
#include <tree_sitter/api.h>
#include <tree_sitter/tree-sitter-c.h>

int main()
{
    TSParser *parser = ts_parser_new();
    ts_parser_set_language(parser, tree_sitter_c());

    const char *source_code = "int main() { return -1; }\n";
    TSTree *tree = ts_parser_parse_string(parser, NULL, source_code, strlen(source_code));
    TSNode root_node = ts_tree_root_node(tree);
    char *string = ts_node_string(root_node);
    printf("Syntax tree: %s\n", string);

    free(string);
    ts_tree_delete(tree);
    ts_parser_delete(parser);
    return 0;
}