tree-sitter-c
Advanced tools
Comparing version 0.4.4 to 0.4.5
@@ -160,10 +160,18 @@ ============================================ | ||
typedef void my_callback(void *, size_t); | ||
--- | ||
(translation_unit | ||
(declaration (storage_class_specifier) (primitive_type) (identifier)) | ||
(declaration | ||
(storage_class_specifier) | ||
(type_definition (primitive_type) (type_identifier)) | ||
(type_definition | ||
(struct_specifier (field_declaration_list (field_declaration (primitive_type) (field_identifier)))) | ||
(pointer_declarator (identifier)))) | ||
(pointer_declarator (type_identifier))) | ||
(type_definition | ||
(primitive_type) | ||
(function_declarator | ||
(type_identifier) | ||
(parameter_list | ||
(parameter_declaration (primitive_type) (abstract_pointer_declarator)) | ||
(parameter_declaration (primitive_type)))))) | ||
@@ -170,0 +178,0 @@ ============================================ |
@@ -56,2 +56,3 @@ const PREC = { | ||
$.declaration, | ||
$.type_definition, | ||
$._empty_declaration, | ||
@@ -69,2 +70,3 @@ $.preproc_if, | ||
$.declaration, | ||
$.type_definition, | ||
$._empty_declaration, | ||
@@ -172,2 +174,10 @@ alias($.preproc_if_in_compound_statement, $.preproc_if), | ||
type_definition: $ => seq( | ||
'typedef', | ||
repeat($.type_qualifier), | ||
$._type_specifier, | ||
$._type_declarator, | ||
';' | ||
), | ||
_declaration_specifiers: $ => seq( | ||
@@ -217,2 +227,10 @@ repeat(choice( | ||
_type_declarator: $ => choice( | ||
alias($.pointer_type_declarator, $.pointer_declarator), | ||
alias($.function_type_declarator, $.function_declarator), | ||
alias($.array_type_declarator, $.array_declarator), | ||
seq('(', $._type_declarator, ')'), | ||
$._type_identifier | ||
), | ||
_abstract_declarator: $ => choice( | ||
@@ -226,5 +244,4 @@ $.abstract_pointer_declarator, | ||
pointer_declarator: $ => prec.right(seq('*', $._declarator)), | ||
pointer_field_declarator: $ => prec.right(seq('*', $._field_declarator)), | ||
pointer_type_declarator: $ => prec.right(seq('*', $._type_declarator)), | ||
abstract_pointer_declarator: $ => prec.right(seq('*', optional($._abstract_declarator))), | ||
@@ -234,2 +251,3 @@ | ||
function_field_declarator: $ => prec(1, seq($._field_declarator, $.parameter_list)), | ||
function_type_declarator: $ => prec(1, seq($._type_declarator, $.parameter_list)), | ||
abstract_function_declarator: $ => prec(1, seq(optional($._abstract_declarator), $.parameter_list)), | ||
@@ -244,3 +262,2 @@ | ||
)), | ||
array_field_declarator: $ => prec(1, seq( | ||
@@ -253,3 +270,9 @@ $._field_declarator, | ||
)), | ||
array_type_declarator: $ => prec(1, seq( | ||
$._type_declarator, | ||
'[', | ||
optional($._declaration_specifiers), | ||
optional($._expression), | ||
']' | ||
)), | ||
abstract_array_declarator: $ => prec(1, seq( | ||
@@ -276,3 +299,2 @@ optional($._abstract_declarator), | ||
storage_class_specifier: $ => choice( | ||
'typedef', | ||
'extern', | ||
@@ -449,3 +471,4 @@ 'static' , | ||
$._statement, | ||
$.declaration | ||
$.declaration, | ||
$.type_definition | ||
) | ||
@@ -452,0 +475,0 @@ ), |
{ | ||
"name": "tree-sitter-c", | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"description": "C grammar for node-tree-sitter", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
2976440
4624