From 7bc619e79dbe751c037c3d61983baed3a7bc64d9 Mon Sep 17 00:00:00 2001 From: Ganesh Viswanathan Date: Wed, 6 Feb 2019 18:13:58 -0600 Subject: Rename tree-sitter runtime to api, add tsgen --- nimterop/all.nim | 2 +- nimterop/ast.nim | 2 +- nimterop/astold.nim | 2 +- nimterop/getters.nim | 2 +- nimterop/globals.nim | 2 +- nimterop/grammar.nim | 2 +- nimterop/toast.nim | 2 +- nimterop/treesitter/api.nim | 174 ++++++++++++++++++++++++++++++++++++++++ nimterop/treesitter/c.nim | 2 +- nimterop/treesitter/cpp.nim | 2 +- nimterop/treesitter/runtime.nim | 174 ---------------------------------------- nimterop/treesitter/tsgen.nim | 18 +++++ 12 files changed, 201 insertions(+), 183 deletions(-) create mode 100644 nimterop/treesitter/api.nim delete mode 100644 nimterop/treesitter/runtime.nim create mode 100644 nimterop/treesitter/tsgen.nim diff --git a/nimterop/all.nim b/nimterop/all.nim index 87564e0..dd42c03 100644 --- a/nimterop/all.nim +++ b/nimterop/all.nim @@ -4,4 +4,4 @@ Module that should import everything so that `nim doc --project nimtero/all` run # TODO: make sure it does import everything. -import "."/[cimport,git,plugin] +import "."/[cimport, git, types, plugin] diff --git a/nimterop/ast.nim b/nimterop/ast.nim index 94465a7..aede004 100644 --- a/nimterop/ast.nim +++ b/nimterop/ast.nim @@ -2,7 +2,7 @@ import os, sequtils, sets, strformat, strutils, tables, times import regex -import "."/[getters, globals, grammar, treesitter/runtime] +import "."/[getters, globals, grammar, treesitter/api] proc saveNodeData(node: TSNode, nimState: NimState): bool = let name = $node.tsNodeType() diff --git a/nimterop/astold.nim b/nimterop/astold.nim index 069ecba..a0c5b93 100644 --- a/nimterop/astold.nim +++ b/nimterop/astold.nim @@ -1,6 +1,6 @@ import macros, os, strformat, strutils -import treesitter/runtime +import treesitter/api import getters, globals diff --git a/nimterop/getters.nim b/nimterop/getters.nim index 7c42583..63836e3 100644 --- a/nimterop/getters.nim +++ b/nimterop/getters.nim @@ -2,7 +2,7 @@ import dynlib, macros, os, sequtils, sets, strformat, strutils, tables, times import regex -import "."/[git, globals, plugin, treesitter/runtime] +import "."/[git, globals, plugin, treesitter/api] const gReserved = """ addr and as asm diff --git a/nimterop/globals.nim b/nimterop/globals.nim index b959958..bdb29dc 100644 --- a/nimterop/globals.nim +++ b/nimterop/globals.nim @@ -5,7 +5,7 @@ import regex import "."/plugin when not declared(CIMPORT): - import "."/treesitter/runtime + import "."/treesitter/api const gAtoms {.used.} = @[ diff --git a/nimterop/grammar.nim b/nimterop/grammar.nim index 510cc7c..3895aa1 100644 --- a/nimterop/grammar.nim +++ b/nimterop/grammar.nim @@ -2,7 +2,7 @@ import macros, sets, strformat, strutils, tables import regex -import "."/[getters, globals, lisp, treesitter/runtime] +import "."/[getters, globals, lisp, treesitter/api] type Grammar = seq[tuple[grammar: string, call: proc(ast: ref Ast, node: TSNode, nimState: NimState) {.nimcall.}]] diff --git a/nimterop/toast.nim b/nimterop/toast.nim index 9221802..e3651a0 100644 --- a/nimterop/toast.nim +++ b/nimterop/toast.nim @@ -1,6 +1,6 @@ import os, strformat, strutils -import "."/treesitter/[runtime, c, cpp] +import "."/treesitter/[api, c, cpp] import "."/[ast, globals, getters, grammar] diff --git a/nimterop/treesitter/api.nim b/nimterop/treesitter/api.nim new file mode 100644 index 0000000..62ebe3b --- /dev/null +++ b/nimterop/treesitter/api.nim @@ -0,0 +1,174 @@ +{.experimental: "codeReordering".} + +import strutils, os + +import ".."/[setup, paths, types] + +static: + treesitterSetup() + +const sourcePath = incDir() / "treesitter/lib" + +when defined(Linux): + {.passC: "-std=c11".} + +{.passC: "-DUTF8PROC_STATIC".} +{.passC: "-I$1/include" % sourcePath.} +{.passC: "-I$1/src" % sourcePath.} +{.passC: "-I$1/../../utf8proc" % sourcePath.} + +{.compile: sourcePath / "src/lib.c".} + +### Generated below + +{.hint[ConvFromXtoItselfNotNeeded]: off.} + +defineEnum(TSInputEncoding) +defineEnum(TSSymbolType) +defineEnum(TSLogType) +const + headerapi {.used.} = sourcePath / "include/tree_sitter/api.h" + TREE_SITTER_LANGUAGE_VERSION* = 9 + TSInputEncodingUTF8* = 0.TSInputEncoding + TSInputEncodingUTF16* = 1.TSInputEncoding + TSSymbolTypeRegular* = 0.TSSymbolType + TSSymbolTypeAnonymous* = 1.TSSymbolType + TSSymbolTypeAuxiliary* = 2.TSSymbolType + TSLogTypeParse* = 0.TSLogType + TSLogTypeLex* = 1.TSLogType +type + TSSymbol* = uint16 + TSLanguage* = object + TSParser* = object + TSTree* = object + TSPoint* {.importc, header: headerapi, bycopy.} = object + row*: uint32 + column*: uint32 + + TSRange* {.importc, header: headerapi, bycopy.} = object + start_point*: TSPoint + end_point*: TSPoint + start_byte*: uint32 + end_byte*: uint32 + + TSInput* {.importc, header: headerapi, bycopy.} = object + payload*: pointer + read*: proc (payload: pointer; byte_index: uint32; position: TSPoint; + bytes_read: ptr uint32): cstring {.nimcall.} + encoding*: TSInputEncoding + + TSLogger* {.importc, header: headerapi, bycopy.} = object + payload*: pointer + log*: proc (payload: pointer; a1: TSLogType; a2: cstring) {.nimcall.} + + TSInputEdit* {.importc, header: headerapi, bycopy.} = object + start_byte*: uint32 + old_end_byte*: uint32 + new_end_byte*: uint32 + start_point*: TSPoint + old_end_point*: TSPoint + new_end_point*: TSPoint + + TSNode* {.importc, header: headerapi, bycopy.} = object + context*: array[4, uint32] + id*: pointer + tree*: ptr TSTree + + TSTreeCursor* {.importc, header: headerapi, bycopy.} = object + tree*: pointer + id*: pointer + context*: array[2, uint32] + +proc ts_parser_new*(): ptr TSParser {.importc, header: headerapi.} +proc ts_parser_delete*(a1: ptr TSParser) {.importc, header: headerapi.} +proc ts_parser_language*(a1: ptr TSParser): ptr TSLanguage {.importc, header: headerapi.} +proc ts_parser_set_language*(a1: ptr TSParser; a2: ptr TSLanguage): bool {.importc, + header: headerapi.} +proc ts_parser_logger*(a1: ptr TSParser): TSLogger {.importc, header: headerapi.} +proc ts_parser_set_logger*(a1: ptr TSParser; a2: TSLogger) {.importc, header: headerapi.} +proc ts_parser_print_dot_graphs*(a1: ptr TSParser; a2: cint) {.importc, + header: headerapi.} +proc ts_parser_halt_on_error*(a1: ptr TSParser; a2: bool) {.importc, header: headerapi.} +proc ts_parser_parse*(a1: ptr TSParser; a2: ptr TSTree; a3: TSInput): ptr TSTree {.importc, + header: headerapi.} +proc ts_parser_parse_string*(a1: ptr TSParser; a2: ptr TSTree; a3: cstring; a4: uint32): ptr TSTree {. + importc, header: headerapi.} +proc ts_parser_parse_string_encoding*(a1: ptr TSParser; a2: ptr TSTree; a3: cstring; + a4: uint32; a5: TSInputEncoding): ptr TSTree {. + importc, header: headerapi.} +proc ts_parser_enabled*(a1: ptr TSParser): bool {.importc, header: headerapi.} +proc ts_parser_set_enabled*(a1: ptr TSParser; a2: bool) {.importc, header: headerapi.} +proc ts_parser_operation_limit*(a1: ptr TSParser): cuint {.importc, header: headerapi.} +proc ts_parser_set_operation_limit*(a1: ptr TSParser; a2: cuint) {.importc, + header: headerapi.} +proc ts_parser_reset*(a1: ptr TSParser) {.importc, header: headerapi.} +proc ts_parser_set_included_ranges*(a1: ptr TSParser; a2: ptr TSRange; a3: uint32) {. + importc, header: headerapi.} +proc ts_parser_included_ranges*(a1: ptr TSParser; a2: ptr uint32): ptr TSRange {.importc, + header: headerapi.} +proc ts_tree_copy*(a1: ptr TSTree): ptr TSTree {.importc, header: headerapi.} +proc ts_tree_delete*(a1: ptr TSTree) {.importc, header: headerapi.} +proc ts_tree_root_node*(a1: ptr TSTree): TSNode {.importc, header: headerapi.} +proc ts_tree_edit*(a1: ptr TSTree; a2: ptr TSInputEdit) {.importc, header: headerapi.} +proc ts_tree_get_changed_ranges*(a1: ptr TSTree; a2: ptr TSTree; a3: ptr uint32): ptr TSRange {. + importc, header: headerapi.} +proc ts_tree_print_dot_graph*(a1: ptr TSTree; a2: ptr FILE) {.importc, header: headerapi.} +proc ts_tree_language*(a1: ptr TSTree): ptr TSLanguage {.importc, header: headerapi.} +proc ts_node_start_byte*(a1: TSNode): uint32 {.importc, header: headerapi.} +proc ts_node_start_point*(a1: TSNode): TSPoint {.importc, header: headerapi.} +proc ts_node_end_byte*(a1: TSNode): uint32 {.importc, header: headerapi.} +proc ts_node_end_point*(a1: TSNode): TSPoint {.importc, header: headerapi.} +proc ts_node_symbol*(a1: TSNode): TSSymbol {.importc, header: headerapi.} +proc ts_node_type*(a1: TSNode): cstring {.importc, header: headerapi.} +proc ts_node_string*(a1: TSNode): cstring {.importc, header: headerapi.} +proc ts_node_eq*(a1: TSNode; a2: TSNode): bool {.importc, header: headerapi.} +proc ts_node_is_null*(a1: TSNode): bool {.importc, header: headerapi.} +proc ts_node_is_named*(a1: TSNode): bool {.importc, header: headerapi.} +proc ts_node_is_missing*(a1: TSNode): bool {.importc, header: headerapi.} +proc ts_node_has_changes*(a1: TSNode): bool {.importc, header: headerapi.} +proc ts_node_has_error*(a1: TSNode): bool {.importc, header: headerapi.} +proc ts_node_parent*(a1: TSNode): TSNode {.importc, header: headerapi.} +proc ts_node_child*(a1: TSNode; a2: uint32): TSNode {.importc, header: headerapi.} +proc ts_node_named_child*(a1: TSNode; a2: uint32): TSNode {.importc, header: headerapi.} +proc ts_node_child_count*(a1: TSNode): uint32 {.importc, header: headerapi.} +proc ts_node_named_child_count*(a1: TSNode): uint32 {.importc, header: headerapi.} +proc ts_node_next_sibling*(a1: TSNode): TSNode {.importc, header: headerapi.} +proc ts_node_next_named_sibling*(a1: TSNode): TSNode {.importc, header: headerapi.} +proc ts_node_prev_sibling*(a1: TSNode): TSNode {.importc, header: headerapi.} +proc ts_node_prev_named_sibling*(a1: TSNode): TSNode {.importc, header: headerapi.} +proc ts_node_first_child_for_byte*(a1: TSNode; a2: uint32): TSNode {.importc, + header: headerapi.} +proc ts_node_first_named_child_for_byte*(a1: TSNode; a2: uint32): TSNode {.importc, + header: headerapi.} +proc ts_node_descendant_for_byte_range*(a1: TSNode; a2: uint32; a3: uint32): TSNode {. + importc, header: headerapi.} +proc ts_node_named_descendant_for_byte_range*(a1: TSNode; a2: uint32; a3: uint32): TSNode {. + importc, header: headerapi.} +proc ts_node_descendant_for_point_range*(a1: TSNode; a2: TSPoint; a3: TSPoint): TSNode {. + importc, header: headerapi.} +proc ts_node_named_descendant_for_point_range*(a1: TSNode; a2: TSPoint; a3: TSPoint): TSNode {. + importc, header: headerapi.} +proc ts_node_edit*(a1: ptr TSNode; a2: ptr TSInputEdit) {.importc, header: headerapi.} +proc ts_tree_cursor_new*(a1: TSNode): TSTreeCursor {.importc, header: headerapi.} +proc ts_tree_cursor_delete*(a1: ptr TSTreeCursor) {.importc, header: headerapi.} +proc ts_tree_cursor_reset*(a1: ptr TSTreeCursor; a2: TSNode) {.importc, + header: headerapi.} +proc ts_tree_cursor_current_node*(a1: ptr TSTreeCursor): TSNode {.importc, + header: headerapi.} +proc ts_tree_cursor_goto_parent*(a1: ptr TSTreeCursor): bool {.importc, + header: headerapi.} +proc ts_tree_cursor_goto_next_sibling*(a1: ptr TSTreeCursor): bool {.importc, + header: headerapi.} +proc ts_tree_cursor_goto_first_child*(a1: ptr TSTreeCursor): bool {.importc, + header: headerapi.} +proc ts_tree_cursor_goto_first_child_for_byte*(a1: ptr TSTreeCursor; a2: uint32): int64 {. + importc, header: headerapi.} +proc ts_language_symbol_count*(a1: ptr TSLanguage): uint32 {.importc, + header: headerapi.} +proc ts_language_symbol_name*(a1: ptr TSLanguage; a2: TSSymbol): cstring {.importc, + header: headerapi.} +proc ts_language_symbol_for_name*(a1: ptr TSLanguage; a2: cstring): TSSymbol {.importc, + header: headerapi.} +proc ts_language_symbol_type*(a1: ptr TSLanguage; a2: TSSymbol): TSSymbolType {. + importc, header: headerapi.} +proc ts_language_version*(a1: ptr TSLanguage): uint32 {.importc, header: headerapi.} diff --git a/nimterop/treesitter/c.nim b/nimterop/treesitter/c.nim index f34eaf9..0170a5d 100644 --- a/nimterop/treesitter/c.nim +++ b/nimterop/treesitter/c.nim @@ -5,7 +5,7 @@ import ".."/[setup, paths] static: treesitterCSetup() -import "."/runtime +import "."/api {.compile: incDir() / "treesitter_c/src/parser.c".} diff --git a/nimterop/treesitter/cpp.nim b/nimterop/treesitter/cpp.nim index 7fc0b13..296929f 100644 --- a/nimterop/treesitter/cpp.nim +++ b/nimterop/treesitter/cpp.nim @@ -5,7 +5,7 @@ import ".."/[setup, paths] static: treesitterCppSetup() -import "."/runtime +import "."/api const srcDir = incDir() / "treesitter_cpp/src" diff --git a/nimterop/treesitter/runtime.nim b/nimterop/treesitter/runtime.nim deleted file mode 100644 index 62ebe3b..0000000 --- a/nimterop/treesitter/runtime.nim +++ /dev/null @@ -1,174 +0,0 @@ -{.experimental: "codeReordering".} - -import strutils, os - -import ".."/[setup, paths, types] - -static: - treesitterSetup() - -const sourcePath = incDir() / "treesitter/lib" - -when defined(Linux): - {.passC: "-std=c11".} - -{.passC: "-DUTF8PROC_STATIC".} -{.passC: "-I$1/include" % sourcePath.} -{.passC: "-I$1/src" % sourcePath.} -{.passC: "-I$1/../../utf8proc" % sourcePath.} - -{.compile: sourcePath / "src/lib.c".} - -### Generated below - -{.hint[ConvFromXtoItselfNotNeeded]: off.} - -defineEnum(TSInputEncoding) -defineEnum(TSSymbolType) -defineEnum(TSLogType) -const - headerapi {.used.} = sourcePath / "include/tree_sitter/api.h" - TREE_SITTER_LANGUAGE_VERSION* = 9 - TSInputEncodingUTF8* = 0.TSInputEncoding - TSInputEncodingUTF16* = 1.TSInputEncoding - TSSymbolTypeRegular* = 0.TSSymbolType - TSSymbolTypeAnonymous* = 1.TSSymbolType - TSSymbolTypeAuxiliary* = 2.TSSymbolType - TSLogTypeParse* = 0.TSLogType - TSLogTypeLex* = 1.TSLogType -type - TSSymbol* = uint16 - TSLanguage* = object - TSParser* = object - TSTree* = object - TSPoint* {.importc, header: headerapi, bycopy.} = object - row*: uint32 - column*: uint32 - - TSRange* {.importc, header: headerapi, bycopy.} = object - start_point*: TSPoint - end_point*: TSPoint - start_byte*: uint32 - end_byte*: uint32 - - TSInput* {.importc, header: headerapi, bycopy.} = object - payload*: pointer - read*: proc (payload: pointer; byte_index: uint32; position: TSPoint; - bytes_read: ptr uint32): cstring {.nimcall.} - encoding*: TSInputEncoding - - TSLogger* {.importc, header: headerapi, bycopy.} = object - payload*: pointer - log*: proc (payload: pointer; a1: TSLogType; a2: cstring) {.nimcall.} - - TSInputEdit* {.importc, header: headerapi, bycopy.} = object - start_byte*: uint32 - old_end_byte*: uint32 - new_end_byte*: uint32 - start_point*: TSPoint - old_end_point*: TSPoint - new_end_point*: TSPoint - - TSNode* {.importc, header: headerapi, bycopy.} = object - context*: array[4, uint32] - id*: pointer - tree*: ptr TSTree - - TSTreeCursor* {.importc, header: headerapi, bycopy.} = object - tree*: pointer - id*: pointer - context*: array[2, uint32] - -proc ts_parser_new*(): ptr TSParser {.importc, header: headerapi.} -proc ts_parser_delete*(a1: ptr TSParser) {.importc, header: headerapi.} -proc ts_parser_language*(a1: ptr TSParser): ptr TSLanguage {.importc, header: headerapi.} -proc ts_parser_set_language*(a1: ptr TSParser; a2: ptr TSLanguage): bool {.importc, - header: headerapi.} -proc ts_parser_logger*(a1: ptr TSParser): TSLogger {.importc, header: headerapi.} -proc ts_parser_set_logger*(a1: ptr TSParser; a2: TSLogger) {.importc, header: headerapi.} -proc ts_parser_print_dot_graphs*(a1: ptr TSParser; a2: cint) {.importc, - header: headerapi.} -proc ts_parser_halt_on_error*(a1: ptr TSParser; a2: bool) {.importc, header: headerapi.} -proc ts_parser_parse*(a1: ptr TSParser; a2: ptr TSTree; a3: TSInput): ptr TSTree {.importc, - header: headerapi.} -proc ts_parser_parse_string*(a1: ptr TSParser; a2: ptr TSTree; a3: cstring; a4: uint32): ptr TSTree {. - importc, header: headerapi.} -proc ts_parser_parse_string_encoding*(a1: ptr TSParser; a2: ptr TSTree; a3: cstring; - a4: uint32; a5: TSInputEncoding): ptr TSTree {. - importc, header: headerapi.} -proc ts_parser_enabled*(a1: ptr TSParser): bool {.importc, header: headerapi.} -proc ts_parser_set_enabled*(a1: ptr TSParser; a2: bool) {.importc, header: headerapi.} -proc ts_parser_operation_limit*(a1: ptr TSParser): cuint {.importc, header: headerapi.} -proc ts_parser_set_operation_limit*(a1: ptr TSParser; a2: cuint) {.importc, - header: headerapi.} -proc ts_parser_reset*(a1: ptr TSParser) {.importc, header: headerapi.} -proc ts_parser_set_included_ranges*(a1: ptr TSParser; a2: ptr TSRange; a3: uint32) {. - importc, header: headerapi.} -proc ts_parser_included_ranges*(a1: ptr TSParser; a2: ptr uint32): ptr TSRange {.importc, - header: headerapi.} -proc ts_tree_copy*(a1: ptr TSTree): ptr TSTree {.importc, header: headerapi.} -proc ts_tree_delete*(a1: ptr TSTree) {.importc, header: headerapi.} -proc ts_tree_root_node*(a1: ptr TSTree): TSNode {.importc, header: headerapi.} -proc ts_tree_edit*(a1: ptr TSTree; a2: ptr TSInputEdit) {.importc, header: headerapi.} -proc ts_tree_get_changed_ranges*(a1: ptr TSTree; a2: ptr TSTree; a3: ptr uint32): ptr TSRange {. - importc, header: headerapi.} -proc ts_tree_print_dot_graph*(a1: ptr TSTree; a2: ptr FILE) {.importc, header: headerapi.} -proc ts_tree_language*(a1: ptr TSTree): ptr TSLanguage {.importc, header: headerapi.} -proc ts_node_start_byte*(a1: TSNode): uint32 {.importc, header: headerapi.} -proc ts_node_start_point*(a1: TSNode): TSPoint {.importc, header: headerapi.} -proc ts_node_end_byte*(a1: TSNode): uint32 {.importc, header: headerapi.} -proc ts_node_end_point*(a1: TSNode): TSPoint {.importc, header: headerapi.} -proc ts_node_symbol*(a1: TSNode): TSSymbol {.importc, header: headerapi.} -proc ts_node_type*(a1: TSNode): cstring {.importc, header: headerapi.} -proc ts_node_string*(a1: TSNode): cstring {.importc, header: headerapi.} -proc ts_node_eq*(a1: TSNode; a2: TSNode): bool {.importc, header: headerapi.} -proc ts_node_is_null*(a1: TSNode): bool {.importc, header: headerapi.} -proc ts_node_is_named*(a1: TSNode): bool {.importc, header: headerapi.} -proc ts_node_is_missing*(a1: TSNode): bool {.importc, header: headerapi.} -proc ts_node_has_changes*(a1: TSNode): bool {.importc, header: headerapi.} -proc ts_node_has_error*(a1: TSNode): bool {.importc, header: headerapi.} -proc ts_node_parent*(a1: TSNode): TSNode {.importc, header: headerapi.} -proc ts_node_child*(a1: TSNode; a2: uint32): TSNode {.importc, header: headerapi.} -proc ts_node_named_child*(a1: TSNode; a2: uint32): TSNode {.importc, header: headerapi.} -proc ts_node_child_count*(a1: TSNode): uint32 {.importc, header: headerapi.} -proc ts_node_named_child_count*(a1: TSNode): uint32 {.importc, header: headerapi.} -proc ts_node_next_sibling*(a1: TSNode): TSNode {.importc, header: headerapi.} -proc ts_node_next_named_sibling*(a1: TSNode): TSNode {.importc, header: headerapi.} -proc ts_node_prev_sibling*(a1: TSNode): TSNode {.importc, header: headerapi.} -proc ts_node_prev_named_sibling*(a1: TSNode): TSNode {.importc, header: headerapi.} -proc ts_node_first_child_for_byte*(a1: TSNode; a2: uint32): TSNode {.importc, - header: headerapi.} -proc ts_node_first_named_child_for_byte*(a1: TSNode; a2: uint32): TSNode {.importc, - header: headerapi.} -proc ts_node_descendant_for_byte_range*(a1: TSNode; a2: uint32; a3: uint32): TSNode {. - importc, header: headerapi.} -proc ts_node_named_descendant_for_byte_range*(a1: TSNode; a2: uint32; a3: uint32): TSNode {. - importc, header: headerapi.} -proc ts_node_descendant_for_point_range*(a1: TSNode; a2: TSPoint; a3: TSPoint): TSNode {. - importc, header: headerapi.} -proc ts_node_named_descendant_for_point_range*(a1: TSNode; a2: TSPoint; a3: TSPoint): TSNode {. - importc, header: headerapi.} -proc ts_node_edit*(a1: ptr TSNode; a2: ptr TSInputEdit) {.importc, header: headerapi.} -proc ts_tree_cursor_new*(a1: TSNode): TSTreeCursor {.importc, header: headerapi.} -proc ts_tree_cursor_delete*(a1: ptr TSTreeCursor) {.importc, header: headerapi.} -proc ts_tree_cursor_reset*(a1: ptr TSTreeCursor; a2: TSNode) {.importc, - header: headerapi.} -proc ts_tree_cursor_current_node*(a1: ptr TSTreeCursor): TSNode {.importc, - header: headerapi.} -proc ts_tree_cursor_goto_parent*(a1: ptr TSTreeCursor): bool {.importc, - header: headerapi.} -proc ts_tree_cursor_goto_next_sibling*(a1: ptr TSTreeCursor): bool {.importc, - header: headerapi.} -proc ts_tree_cursor_goto_first_child*(a1: ptr TSTreeCursor): bool {.importc, - header: headerapi.} -proc ts_tree_cursor_goto_first_child_for_byte*(a1: ptr TSTreeCursor; a2: uint32): int64 {. - importc, header: headerapi.} -proc ts_language_symbol_count*(a1: ptr TSLanguage): uint32 {.importc, - header: headerapi.} -proc ts_language_symbol_name*(a1: ptr TSLanguage; a2: TSSymbol): cstring {.importc, - header: headerapi.} -proc ts_language_symbol_for_name*(a1: ptr TSLanguage; a2: cstring): TSSymbol {.importc, - header: headerapi.} -proc ts_language_symbol_type*(a1: ptr TSLanguage; a2: TSSymbol): TSSymbolType {. - importc, header: headerapi.} -proc ts_language_version*(a1: ptr TSLanguage): uint32 {.importc, header: headerapi.} diff --git a/nimterop/treesitter/tsgen.nim b/nimterop/treesitter/tsgen.nim new file mode 100644 index 0000000..335f28f --- /dev/null +++ b/nimterop/treesitter/tsgen.nim @@ -0,0 +1,18 @@ +# nim c tsgen.nim > temp.nim +# Move temp.nim contents to api.nim below generated line + minor adjustments + +import os + +import nimterop/[cimport, paths] + +cPlugin: + import strutils + + proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} = + if "_CRT" in sym.name: + sym.name = sym.name.strip(chars={'_'}) + +static: + cDebug() + +cImport(incDir()/"treesitter/lib/include/tree_sitter/api.h") \ No newline at end of file -- cgit v1.2.3