⬆️ tree-sitter-cli

This commit is contained in:
Max Brunsfeld 2019-12-02 17:10:24 -08:00
parent 47841b3f8e
commit 2af852d7b8
5 changed files with 746 additions and 710 deletions

View File

@ -16,7 +16,7 @@
"nan": "^2.10.0"
},
"devDependencies": {
"tree-sitter-cli": "^0.15.6"
"tree-sitter-cli": "^0.15.14"
},
"scripts": {
"build": "tree-sitter generate && node-gyp build",

View File

@ -10,17 +10,17 @@ namespace {
NAN_METHOD(New) {}
void Init(Handle<Object> exports, Handle<Object> module) {
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 = tpl->GetFunction();
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_html());
instance->Set(Nan::New("name").ToLocalChecked(), Nan::New("html").ToLocalChecked());
module->Set(Nan::New("exports").ToLocalChecked(), instance);
Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("html").ToLocalChecked());
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
}
NODE_MODULE(tree_sitter_html_binding, Init)

View File

@ -5,7 +5,7 @@
"fields": {},
"children": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "attribute_name",
@ -33,7 +33,7 @@
"fields": {},
"children": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "doctype",
@ -77,15 +77,25 @@
{
"type": "end_tag",
"named": true,
"fields": {}
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "tag_name",
"named": true
}
]
}
},
{
"type": "erroneous_end_tag",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": false,
"multiple": false,
"required": true,
"types": [
{
"type": "erroneous_end_tag_name",
@ -132,7 +142,17 @@
{
"type": "quoted_attribute_value",
"named": true,
"fields": {}
"fields": {},
"children": {
"multiple": false,
"required": false,
"types": [
{
"type": "attribute_value",
"named": true
}
]
}
},
{
"type": "script_element",
@ -140,7 +160,7 @@
"fields": {},
"children": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "end_tag",
@ -163,11 +183,15 @@
"fields": {},
"children": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "attribute",
"named": true
},
{
"type": "tag_name",
"named": true
}
]
}
@ -178,11 +202,15 @@
"fields": {},
"children": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "attribute",
"named": true
},
{
"type": "tag_name",
"named": true
}
]
}
@ -193,7 +221,7 @@
"fields": {},
"children": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "end_tag",
@ -211,11 +239,15 @@
}
},
{
"type": "<!",
"type": "\"",
"named": false
},
{
"type": ">",
"type": "'",
"named": false
},
{
"type": "/>",
"named": false
},
{
@ -223,7 +255,7 @@
"named": false
},
{
"type": "/>",
"type": "<!",
"named": false
},
{
@ -234,6 +266,10 @@
"type": "=",
"named": false
},
{
"type": ">",
"named": false
},
{
"type": "attribute_name",
"named": true
@ -242,14 +278,6 @@
"type": "attribute_value",
"named": true
},
{
"type": "'",
"named": false
},
{
"type": "\"",
"named": false
},
{
"type": "text",
"named": true

1372
src/parser.c vendored

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,8 @@ struct TSLexer {
void (*advance)(TSLexer *, bool);
void (*mark_end)(TSLexer *);
uint32_t (*get_column)(TSLexer *);
bool (*is_at_included_range_start)(TSLexer *);
bool (*is_at_included_range_start)(const TSLexer *);
bool (*eof)(const TSLexer *);
};
typedef enum {
@ -123,6 +124,7 @@ struct TSLanguage {
#define START_LEXER() \
bool result = false; \
bool skip = false; \
bool eof = false; \
int32_t lookahead; \
goto start; \
next_state: \