Skip to content

Commit

Permalink
fix: ms call modifier missing in some spots
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Feb 16, 2024
1 parent 579f349 commit e3f4c95
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
9 changes: 8 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ module.exports = grammar({
function_definition: $ => seq(
optional($.ms_call_modifier),
$._declaration_specifiers,
optional($.ms_call_modifier),
field('declarator', $._declarator),
field('body', $.compound_statement),
),
Expand All @@ -247,6 +248,7 @@ module.exports = grammar({
$._declaration_specifiers,
commaSep1(field('declarator', choice(
seq(
optional($.ms_call_modifier),
$._declaration_declarator,
optional($.gnu_asm_expression),
),
Expand Down Expand Up @@ -398,21 +400,25 @@ module.exports = grammar({

parenthesized_declarator: $ => prec.dynamic(PREC.PAREN_DECLARATOR, seq(
'(',
optional($.ms_call_modifier),
$._declarator,
')',
)),
parenthesized_field_declarator: $ => prec.dynamic(PREC.PAREN_DECLARATOR, seq(
'(',
optional($.ms_call_modifier),
$._field_declarator,
')',
)),
parenthesized_type_declarator: $ => prec.dynamic(PREC.PAREN_DECLARATOR, seq(
'(',
optional($.ms_call_modifier),
$._type_declarator,
')',
)),
abstract_parenthesized_declarator: $ => prec(1, seq(
'(',
optional($.ms_call_modifier),
$._abstract_declarator,
')',
)),
Expand Down Expand Up @@ -468,7 +474,8 @@ module.exports = grammar({
$.identifier,
alias($.preproc_call_expression, $.call_expression),
)),
)),
),
),

_function_declaration_declarator: $ => prec.right(1,
seq(
Expand Down
49 changes: 47 additions & 2 deletions test/corpus/microsoft.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ __fastcall void mymethod(){
return;
}

void __stdcall f() { }

void (__stdcall g)() { }

void __stdcall h();

void (__stdcall j());

typedef void(__stdcall *fp)();

---

(translation_unit
Expand All @@ -184,8 +194,43 @@ __fastcall void mymethod(){
declarator: (identifier)
parameters: (parameter_list))
body: (compound_statement
(return_statement))))

(return_statement)))
(function_definition
type: (primitive_type)
(ms_call_modifier)
declarator: (function_declarator
declarator: (identifier)
parameters: (parameter_list))
body: (compound_statement))
(function_definition
type: (primitive_type)
declarator: (function_declarator
declarator: (parenthesized_declarator
(ms_call_modifier)
(identifier))
parameters: (parameter_list))
body: (compound_statement))
(declaration
type: (primitive_type)
declarator: (ms_call_modifier)
declarator: (function_declarator
declarator: (identifier)
parameters: (parameter_list)))
(declaration
type: (primitive_type)
declarator: (parenthesized_declarator
(ms_call_modifier)
(function_declarator
declarator: (identifier)
parameters: (parameter_list))))
(type_definition
type: (primitive_type)
declarator: (function_declarator
declarator: (parenthesized_declarator
(ms_call_modifier)
(pointer_declarator
declarator: (type_identifier)))
parameters: (parameter_list))))

================================
SEH exception handling
Expand Down

0 comments on commit e3f4c95

Please sign in to comment.