-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: global declarations were error nodes
- Loading branch information
Showing
8 changed files
with
9,036 additions
and
8,657 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,20 @@ | ||
#include "nan.h" | ||
#include "tree_sitter/parser.h" | ||
#include <node.h> | ||
#include <napi.h> | ||
|
||
using namespace v8; | ||
typedef struct TSLanguage TSLanguage; | ||
|
||
extern "C" TSLanguage *tree_sitter_hare(); | ||
|
||
namespace { | ||
|
||
NAN_METHOD(New) {} | ||
|
||
void Init(Local<Object> exports, Local<Object> module) { | ||
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New); | ||
tpl->SetClassName(Nan::New("Language").ToLocalChecked()); | ||
tpl->InstanceTemplate()->SetInternalFieldCount(1); | ||
|
||
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked(); | ||
Local<Object> instance = | ||
constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked(); | ||
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_hare()); | ||
|
||
Nan::Set(instance, Nan::New("name").ToLocalChecked(), | ||
Nan::New("hare").ToLocalChecked()); | ||
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance); | ||
// "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, "hare"); | ||
auto language = Napi::External<TSLanguage>::New(env, tree_sitter_hare()); | ||
language.TypeTag(&LANGUAGE_TYPE_TAG); | ||
exports["language"] = language; | ||
return exports; | ||
} | ||
|
||
NODE_MODULE(tree_sitter_hare_binding, Init) | ||
|
||
} // namespace | ||
NODE_API_MODULE(tree_sitter_hare_binding, Init) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,7 @@ | ||
try { | ||
module.exports = require('../../build/Release/tree_sitter_hare_binding'); | ||
} catch (error1) { | ||
if (error1.code !== 'MODULE_NOT_FOUND') { | ||
throw error1; | ||
} | ||
try { | ||
module.exports = require('../../build/Debug/tree_sitter_hare_binding'); | ||
} catch (error2) { | ||
if (error2.code !== 'MODULE_NOT_FOUND') { | ||
throw error2; | ||
} | ||
throw error1; | ||
} | ||
} | ||
const root = require("path").join(__dirname, "..", ".."); | ||
|
||
module.exports = require("node-gyp-build")(root); | ||
|
||
try { | ||
module.exports.nodeTypeInfo = require('../../src/node-types.json'); | ||
module.exports.nodeTypeInfo = require("../../src/node-types.json"); | ||
} catch (_) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,32 +3,53 @@ | |
"version": "1.0.0", | ||
"description": "Hare grammar for tree-sitter", | ||
"main": "bindings/node", | ||
"types": "bindings/node", | ||
"keywords": [ | ||
"parser", | ||
"lexer", | ||
"hare" | ||
], | ||
"files": [ | ||
"grammar.js", | ||
"binding.gyp", | ||
"prebuilds/**", | ||
"bindings/node/*", | ||
"queries/*", | ||
"src/**" | ||
], | ||
"author": "Amaan Qureshi <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/amaanq/tree-sitter-hare/issues" | ||
}, | ||
"homepage": "https://github.com/amaanq/tree-sitter-hare#readme", | ||
"dependencies": { | ||
"nan": "^2.17.0" | ||
"node-addon-api": "^7.1.0", | ||
"node-gyp-build": "^4.8.0" | ||
}, | ||
"peerDependencies": { | ||
"tree-sitter": "^0.21.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"tree_sitter": { | ||
"optional": true | ||
} | ||
}, | ||
"devDependencies": { | ||
"eslint": "^8.40.0", | ||
"eslint-config-google": "^0.14.0", | ||
"tree-sitter-cli": "^0.20.8" | ||
"tree-sitter-cli": "^0.20.8", | ||
"prebuildify": "^6.0.0" | ||
}, | ||
"repository": "https://github.com/amaanq/tree-sitter-hare", | ||
"scripts": { | ||
"build": "tree-sitter generate && node-gyp build", | ||
"lint": "eslint grammar.js", | ||
"parse": "tree-sitter parse", | ||
"test": "tree-sitter test && script/parse-examples", | ||
"test-windows": "tree-sitter test" | ||
"test-windows": "tree-sitter test", | ||
"install": "node-gyp-build", | ||
"prebuildify": "prebuildify --napi --strip" | ||
}, | ||
"tree-sitter": [ | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.