Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tree-sitter-c

Package Overview
Dependencies
Maintainers
9
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tree-sitter-c - npm Package Compare versions

Comparing version 0.21.3 to 0.21.4

184

grammar.js

@@ -38,2 +38,21 @@ /**

conflicts: $ => [
[$.type_specifier, $._declarator],
[$.type_specifier, $._declarator, $.macro_type_specifier],
[$.type_specifier, $.expression],
[$.type_specifier, $.expression, $.macro_type_specifier],
[$.type_specifier, $.macro_type_specifier],
[$.type_specifier, $.sized_type_specifier],
[$.sized_type_specifier],
[$.attributed_statement],
[$._declaration_modifiers, $.attributed_statement],
[$.enum_specifier],
[$.type_specifier, $._old_style_parameter_list],
[$.parameter_list, $._old_style_parameter_list],
[$.function_declarator, $._function_declaration_declarator],
[$._block_item, $.statement],
[$._top_level_item, $._top_level_statement],
[$.type_specifier, $._top_level_expression_statement],
],
extras: $ => [

@@ -45,6 +64,2 @@ /\s|\\\r?\n/,

inline: $ => [
$._statement,
$._block_item,
$._top_level_item,
$._top_level_statement,
$._type_identifier,

@@ -55,18 +70,13 @@ $._field_identifier,

$._assignment_left_expression,
$._expression_not_binary,
],
conflicts: $ => [
[$._type_specifier, $._declarator],
[$._type_specifier, $._declarator, $.macro_type_specifier],
[$._type_specifier, $._expression_not_binary],
[$._type_specifier, $._expression_not_binary, $.macro_type_specifier],
[$._type_specifier, $.macro_type_specifier],
[$._type_specifier, $.sized_type_specifier],
[$.sized_type_specifier],
[$.attributed_statement],
[$._declaration_modifiers, $.attributed_statement],
[$.enum_specifier],
[$._type_specifier, $._old_style_parameter_list],
[$.parameter_list, $._old_style_parameter_list],
[$.function_declarator, $._function_declaration_declarator],
supertypes: $ => [
$.expression,
$.statement,
$.type_specifier,
$._declarator,
$._field_declarator,
$._type_declarator,
$._abstract_declarator,
],

@@ -102,3 +112,3 @@

$.declaration,
$._statement,
$.statement,
$.attributed_statement,

@@ -270,3 +280,3 @@ $.type_definition,

),
_type_definition_type: $ => seq(repeat($.type_qualifier), field('type', $._type_specifier), repeat($.type_qualifier)),
_type_definition_type: $ => seq(repeat($.type_qualifier), field('type', $.type_specifier), repeat($.type_qualifier)),
_type_definition_declarators: $ => commaSep1(field('declarator', $._type_declarator)),

@@ -284,3 +294,3 @@

repeat($._declaration_modifiers),
field('type', $._type_specifier),
field('type', $.type_specifier),
repeat($._declaration_modifiers),

@@ -513,4 +523,4 @@ )),

'[',
repeat($.type_qualifier),
field('size', optional(choice($._expression, '*'))),
repeat(choice($.type_qualifier, 'static')),
field('size', optional(choice($.expression, '*'))),
']',

@@ -521,4 +531,4 @@ )),

'[',
repeat($.type_qualifier),
field('size', optional(choice($._expression, '*'))),
repeat(choice($.type_qualifier, 'static')),
field('size', optional(choice($.expression, '*'))),
']',

@@ -529,4 +539,4 @@ )),

'[',
repeat($.type_qualifier),
field('size', optional(choice($._expression, '*'))),
repeat(choice($.type_qualifier, 'static')),
field('size', optional(choice($.expression, '*'))),
']',

@@ -537,4 +547,4 @@ )),

'[',
repeat($.type_qualifier),
field('size', optional(choice($._expression, '*'))),
repeat(choice($.type_qualifier, 'static')),
field('size', optional(choice($.expression, '*'))),
']',

@@ -546,3 +556,3 @@ )),

'=',
field('value', choice($.initializer_list, $._expression)),
field('value', choice($.initializer_list, $.expression)),
),

@@ -569,3 +579,3 @@

type_qualifier: _ => choice(
type_qualifier: $ => choice(
'const',

@@ -580,5 +590,13 @@ 'constexpr',

'noreturn',
$.alignas_qualifier,
),
_type_specifier: $ => choice(
alignas_qualifier: $ => seq(
choice('alignas', '_Alignas'),
'(',
choice($.expression, $.type_descriptor),
')',
),
type_specifier: $ => choice(
$.struct_specifier,

@@ -737,7 +755,7 @@ $.union_specifier,

bitfield_clause: $ => seq(':', $._expression),
bitfield_clause: $ => seq(':', $.expression),
enumerator: $ => seq(
field('name', $.identifier),
optional(seq('=', field('value', $._expression))),
optional(seq('=', field('value', $.expression))),
),

@@ -770,6 +788,6 @@

repeat1($.attribute_declaration),
$._statement,
$.statement,
),
_statement: $ => choice(
statement: $ => choice(
$.case_statement,

@@ -817,3 +835,3 @@ $._non_case_statement,

':',
$._statement,
$.statement,
),

@@ -829,3 +847,3 @@

optional(choice(
$._expression,
$.expression,
$.comma_expression,

@@ -839,7 +857,7 @@ )),

field('condition', $.parenthesized_expression),
field('consequence', $._statement),
field('consequence', $.statement),
optional(field('alternative', $.else_clause)),
)),
else_clause: $ => seq('else', $._statement),
else_clause: $ => seq('else', $.statement),

@@ -854,3 +872,3 @@ switch_statement: $ => seq(

choice(
seq('case', field('value', $._expression)),
seq('case', field('value', $.expression)),
'default',

@@ -869,3 +887,3 @@ ),

field('condition', $.parenthesized_expression),
field('body', $._statement),
field('body', $.statement),
),

@@ -875,3 +893,3 @@

'do',
field('body', $._statement),
field('body', $.statement),
'while',

@@ -887,3 +905,3 @@ field('condition', $.parenthesized_expression),

')',
field('body', $._statement),
field('body', $.statement),
),

@@ -893,7 +911,7 @@ _for_statement_body: $ => seq(

field('initializer', $.declaration),
seq(field('initializer', optional(choice($._expression, $.comma_expression))), ';'),
seq(field('initializer', optional(choice($.expression, $.comma_expression))), ';'),
),
field('condition', optional(choice($._expression, $.comma_expression))),
field('condition', optional(choice($.expression, $.comma_expression))),
';',
field('update', optional(choice($._expression, $.comma_expression))),
field('update', optional(choice($.expression, $.comma_expression))),
),

@@ -903,3 +921,3 @@

'return',
optional(choice($._expression, $.comma_expression)),
optional(choice($.expression, $.comma_expression)),
';',

@@ -945,3 +963,3 @@ ),

_expression: $ => choice(
expression: $ => choice(
$._expression_not_binary,

@@ -983,13 +1001,13 @@ $.binary_expression,

comma_expression: $ => seq(
field('left', $._expression),
field('left', $.expression),
',',
field('right', choice($._expression, $.comma_expression)),
field('right', choice($.expression, $.comma_expression)),
),
conditional_expression: $ => prec.right(PREC.CONDITIONAL, seq(
field('condition', $._expression),
field('condition', $.expression),
'?',
optional(field('consequence', choice($._expression, $.comma_expression))),
optional(field('consequence', choice($.expression, $.comma_expression))),
':',
field('alternative', $._expression),
field('alternative', $.expression),
)),

@@ -1021,3 +1039,3 @@

)),
field('right', $._expression),
field('right', $.expression),
)),

@@ -1027,3 +1045,3 @@

field('operator', choice('*', '&')),
field('argument', $._expression),
field('argument', $.expression),
)),

@@ -1033,3 +1051,3 @@

field('operator', choice('!', '~', '-', '+')),
field('argument', $._expression),
field('argument', $.expression),
)),

@@ -1061,6 +1079,6 @@

return prec.left(precedence, seq(
field('left', $._expression),
field('left', $.expression),
// @ts-ignore
field('operator', operator),
field('right', $._expression),
field('right', $.expression),
));

@@ -1071,3 +1089,3 @@ }));

update_expression: $ => {
const argument = field('argument', $._expression);
const argument = field('argument', $.expression);
const operator = field('operator', choice('--', '++'));

@@ -1084,3 +1102,3 @@ return prec.right(PREC.UNARY, choice(

')',
field('value', $._expression),
field('value', $.expression),
)),

@@ -1090,3 +1108,3 @@

repeat($.type_qualifier),
field('type', $._type_specifier),
field('type', $.type_specifier),
repeat($.type_qualifier),

@@ -1099,3 +1117,3 @@ field('declarator', optional($._abstract_declarator)),

choice(
field('value', $._expression),
field('value', $.expression),
seq('(', field('type', $.type_descriptor), ')'),

@@ -1118,5 +1136,5 @@ ),

'(',
$._expression,
$.expression,
',',
commaSep1(seq($.type_descriptor, ':', $._expression)),
commaSep1(seq($.type_descriptor, ':', $.expression)),
')',

@@ -1126,5 +1144,5 @@ )),

subscript_expression: $ => prec(PREC.SUBSCRIPT, seq(
field('argument', $._expression),
field('argument', $.expression),
'[',
field('index', $._expression),
field('index', $.expression),
']',

@@ -1134,3 +1152,3 @@ )),

call_expression: $ => prec(PREC.CALL, seq(
field('function', $._expression),
field('function', $.expression),
field('arguments', $.argument_list),

@@ -1193,3 +1211,3 @@ )),

'(',
field('value', $._expression),
field('value', $.expression),
')',

@@ -1209,7 +1227,7 @@ ),

// The compound_statement is added to parse macros taking statements as arguments, e.g. MYFORLOOP(1, 10, i, { foo(i); bar(i); })
argument_list: $ => seq('(', commaSep(choice(seq(optional('__extension__'), $._expression), $.compound_statement)), ')'),
argument_list: $ => seq('(', commaSep(choice(seq(optional('__extension__'), $.expression), $.compound_statement)), ')'),
field_expression: $ => seq(
prec(PREC.FIELD, seq(
field('argument', $._expression),
field('argument', $.expression),
field('operator', choice('.', '->')),

@@ -1229,3 +1247,3 @@ )),

'(',
choice($._expression, $.comma_expression),
choice($.expression, $.comma_expression),
')',

@@ -1238,3 +1256,3 @@ ),

$.initializer_pair,
$._expression,
$.expression,
$.initializer_list,

@@ -1254,3 +1272,3 @@ )),

'=',
field('value', choice($._expression, $.initializer_list)),
field('value', choice($.expression, $.initializer_list)),
),

@@ -1260,9 +1278,9 @@ seq(

':',
field('value', choice($._expression, $.initializer_list)),
field('value', choice($.expression, $.initializer_list)),
),
),
subscript_designator: $ => seq('[', $._expression, ']'),
subscript_designator: $ => seq('[', $.expression, ']'),
subscript_range_designator: $ => seq('[', field('start', $._expression), '...', field('end', $._expression), ']'),
subscript_range_designator: $ => seq('[', field('start', $.expression), '...', field('end', $.expression), ']'),

@@ -1364,3 +1382,3 @@ field_designator: $ => seq('.', $._field_identifier),

_empty_declaration: $ => seq(
$._type_specifier,
$.type_specifier,
';',

@@ -1386,12 +1404,2 @@ ),

},
supertypes: $ => [
$._expression,
$._statement,
$._type_specifier,
$._declarator,
$._field_declarator,
$._type_declarator,
$._abstract_declarator,
],
});

@@ -1398,0 +1406,0 @@

{
"name": "tree-sitter-c",
"version": "0.21.3",
"version": "0.21.4",
"description": "C grammar for tree-sitter",

@@ -5,0 +5,0 @@ "repository": "github:tree-sitter/tree-sitter-c",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc