Rename tree-sitter runtime to api, add tsgen
This commit is contained in:
parent
b2d68ba84c
commit
7bc619e79d
11 changed files with 27 additions and 9 deletions
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import macros, os, strformat, strutils
|
||||
|
||||
import treesitter/runtime
|
||||
import treesitter/api
|
||||
|
||||
import getters, globals
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import regex
|
|||
import "."/plugin
|
||||
|
||||
when not declared(CIMPORT):
|
||||
import "."/treesitter/runtime
|
||||
import "."/treesitter/api
|
||||
|
||||
const
|
||||
gAtoms {.used.} = @[
|
||||
|
|
|
|||
|
|
@ -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.}]]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import os, strformat, strutils
|
||||
|
||||
import "."/treesitter/[runtime, c, cpp]
|
||||
import "."/treesitter/[api, c, cpp]
|
||||
|
||||
import "."/[ast, globals, getters, grammar]
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import ".."/[setup, paths]
|
|||
static:
|
||||
treesitterCSetup()
|
||||
|
||||
import "."/runtime
|
||||
import "."/api
|
||||
|
||||
{.compile: incDir() / "treesitter_c/src/parser.c".}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import ".."/[setup, paths]
|
|||
static:
|
||||
treesitterCppSetup()
|
||||
|
||||
import "."/runtime
|
||||
import "."/api
|
||||
|
||||
const srcDir = incDir() / "treesitter_cpp/src"
|
||||
|
||||
|
|
|
|||
18
nimterop/treesitter/tsgen.nim
Normal file
18
nimterop/treesitter/tsgen.nim
Normal file
|
|
@ -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")
|
||||
Loading…
Add table
Add a link
Reference in a new issue