|
|
|
|
@ -46,6 +46,8 @@ module.exports = grammar({
|
|
|
|
|
[$._type_specifier, $._expression, $.macro_type_specifier],
|
|
|
|
|
[$._type_specifier, $.macro_type_specifier],
|
|
|
|
|
[$.sized_type_specifier],
|
|
|
|
|
[$._declaration_modifiers, $.attributed_statement],
|
|
|
|
|
[$._declaration_modifiers, $.attributed_non_case_statement],
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
word: $ => $.identifier,
|
|
|
|
|
@ -58,6 +60,7 @@ module.exports = grammar({
|
|
|
|
|
$.linkage_specification,
|
|
|
|
|
$.declaration,
|
|
|
|
|
$._statement,
|
|
|
|
|
$.attributed_statement,
|
|
|
|
|
$.type_definition,
|
|
|
|
|
$._empty_declaration,
|
|
|
|
|
$.preproc_if,
|
|
|
|
|
@ -207,20 +210,18 @@ module.exports = grammar({
|
|
|
|
|
';'
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_declaration_modifiers: $ => choice(
|
|
|
|
|
$.storage_class_specifier,
|
|
|
|
|
$.type_qualifier,
|
|
|
|
|
$.attribute_specifier,
|
|
|
|
|
$.attribute_declaration,
|
|
|
|
|
$.ms_declspec_modifier
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_declaration_specifiers: $ => seq(
|
|
|
|
|
repeat(choice(
|
|
|
|
|
$.storage_class_specifier,
|
|
|
|
|
$.type_qualifier,
|
|
|
|
|
$.attribute_specifier,
|
|
|
|
|
$.ms_declspec_modifier
|
|
|
|
|
)),
|
|
|
|
|
repeat($._declaration_modifiers),
|
|
|
|
|
field('type', $._type_specifier),
|
|
|
|
|
repeat(choice(
|
|
|
|
|
$.storage_class_specifier,
|
|
|
|
|
$.type_qualifier,
|
|
|
|
|
$.attribute_specifier,
|
|
|
|
|
$.ms_declspec_modifier
|
|
|
|
|
))
|
|
|
|
|
repeat($._declaration_modifiers),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
linkage_specification: $ => seq(
|
|
|
|
|
@ -240,6 +241,18 @@ module.exports = grammar({
|
|
|
|
|
')'
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
attribute: $ => seq(
|
|
|
|
|
optional(seq(field('prefix', $.identifier), '::')),
|
|
|
|
|
field('name', $.identifier),
|
|
|
|
|
optional($.argument_list)
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
attribute_declaration: $ => seq(
|
|
|
|
|
'[[',
|
|
|
|
|
commaSep1($.attribute),
|
|
|
|
|
']]'
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
ms_declspec_modifier: $ => seq(
|
|
|
|
|
'__declspec',
|
|
|
|
|
'(',
|
|
|
|
|
@ -283,6 +296,7 @@ module.exports = grammar({
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_declarator: $ => choice(
|
|
|
|
|
$.attributed_declarator,
|
|
|
|
|
$.pointer_declarator,
|
|
|
|
|
$.function_declarator,
|
|
|
|
|
$.array_declarator,
|
|
|
|
|
@ -291,6 +305,7 @@ module.exports = grammar({
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_field_declarator: $ => choice(
|
|
|
|
|
alias($.attributed_field_declarator, $.attributed_declarator),
|
|
|
|
|
alias($.pointer_field_declarator, $.pointer_declarator),
|
|
|
|
|
alias($.function_field_declarator, $.function_declarator),
|
|
|
|
|
alias($.array_field_declarator, $.array_declarator),
|
|
|
|
|
@ -299,6 +314,7 @@ module.exports = grammar({
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_type_declarator: $ => choice(
|
|
|
|
|
alias($.attributed_type_declarator, $.attributed_declarator),
|
|
|
|
|
alias($.pointer_type_declarator, $.pointer_declarator),
|
|
|
|
|
alias($.function_type_declarator, $.function_declarator),
|
|
|
|
|
alias($.array_type_declarator, $.array_declarator),
|
|
|
|
|
@ -335,6 +351,18 @@ module.exports = grammar({
|
|
|
|
|
)),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
attributed_declarator: $ => prec.right(seq(
|
|
|
|
|
$._declarator,
|
|
|
|
|
repeat1($.attribute_declaration),
|
|
|
|
|
)),
|
|
|
|
|
attributed_field_declarator: $ => prec.right(seq(
|
|
|
|
|
$._field_declarator,
|
|
|
|
|
repeat1($.attribute_declaration),
|
|
|
|
|
)),
|
|
|
|
|
attributed_type_declarator: $ => prec.right(seq(
|
|
|
|
|
$._type_declarator,
|
|
|
|
|
repeat1($.attribute_declaration),
|
|
|
|
|
)),
|
|
|
|
|
|
|
|
|
|
pointer_declarator: $ => prec.dynamic(1, prec.right(seq(
|
|
|
|
|
optional($.ms_based_modifier),
|
|
|
|
|
@ -548,9 +576,13 @@ module.exports = grammar({
|
|
|
|
|
optional(seq('=', field('value', $._expression)))
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
variadic_parameter: $ => seq(
|
|
|
|
|
'...',
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
parameter_list: $ => seq(
|
|
|
|
|
'(',
|
|
|
|
|
commaSep(choice($.parameter_declaration, '...')),
|
|
|
|
|
commaSep(choice($.parameter_declaration, $.variadic_parameter)),
|
|
|
|
|
')'
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
@ -564,6 +596,16 @@ module.exports = grammar({
|
|
|
|
|
|
|
|
|
|
// Statements
|
|
|
|
|
|
|
|
|
|
attributed_statement: $ => seq(
|
|
|
|
|
repeat1($.attribute_declaration),
|
|
|
|
|
$._statement
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
attributed_non_case_statement: $ => seq(
|
|
|
|
|
repeat1($.attribute_declaration),
|
|
|
|
|
$._non_case_statement
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
_statement: $ => choice(
|
|
|
|
|
$.case_statement,
|
|
|
|
|
$._non_case_statement
|
|
|
|
|
@ -621,6 +663,7 @@ module.exports = grammar({
|
|
|
|
|
),
|
|
|
|
|
':',
|
|
|
|
|
repeat(choice(
|
|
|
|
|
alias($.attributed_non_case_statement, $.attributed_statement),
|
|
|
|
|
$._non_case_statement,
|
|
|
|
|
$.declaration,
|
|
|
|
|
$.type_definition
|
|
|
|
|
|