mirror of
https://github.com/github/codeql.git
synced 2026-05-22 15:17:09 +02:00
Python: Also use tree-sitter 0.22.6
This commit is contained in:
20
python/extractor/tsg-python/bindings/node/binding.cc
Normal file
20
python/extractor/tsg-python/bindings/node/binding.cc
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <napi.h>
|
||||
|
||||
typedef struct TSLanguage TSLanguage;
|
||||
|
||||
extern "C" TSLanguage *tree_sitter_tsg_python();
|
||||
|
||||
// "tree-sitter", "language" hashed with BLAKE2
|
||||
const napi_type_tag LANGUAGE_TYPE_TAG = {
|
||||
0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
|
||||
};
|
||||
|
||||
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
||||
exports["name"] = Napi::String::New(env, "tsg_python");
|
||||
auto language = Napi::External<TSLanguage>::New(env, tree_sitter_tsg_python());
|
||||
language.TypeTag(&LANGUAGE_TYPE_TAG);
|
||||
exports["language"] = language;
|
||||
return exports;
|
||||
}
|
||||
|
||||
NODE_API_MODULE(tree_sitter_tsg_python_binding, Init)
|
||||
28
python/extractor/tsg-python/bindings/node/index.d.ts
vendored
Normal file
28
python/extractor/tsg-python/bindings/node/index.d.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
type BaseNode = {
|
||||
type: string;
|
||||
named: boolean;
|
||||
};
|
||||
|
||||
type ChildNode = {
|
||||
multiple: boolean;
|
||||
required: boolean;
|
||||
types: BaseNode[];
|
||||
};
|
||||
|
||||
type NodeInfo =
|
||||
| (BaseNode & {
|
||||
subtypes: BaseNode[];
|
||||
})
|
||||
| (BaseNode & {
|
||||
fields: { [name: string]: ChildNode };
|
||||
children: ChildNode[];
|
||||
});
|
||||
|
||||
type Language = {
|
||||
name: string;
|
||||
language: unknown;
|
||||
nodeTypeInfo: NodeInfo[];
|
||||
};
|
||||
|
||||
declare const language: Language;
|
||||
export = language;
|
||||
7
python/extractor/tsg-python/bindings/node/index.js
Normal file
7
python/extractor/tsg-python/bindings/node/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
const root = require("path").join(__dirname, "..", "..");
|
||||
|
||||
module.exports = require("node-gyp-build")(root);
|
||||
|
||||
try {
|
||||
module.exports.nodeTypeInfo = require("../../src/node-types.json");
|
||||
} catch (_) {}
|
||||
Reference in New Issue
Block a user