Add support for separates

This commit is contained in:
Emmanuel Briot 2022-10-24 14:57:08 +02:00
parent 184f9ca9b8
commit 779bebba99
2 changed files with 158 additions and 8 deletions

118
corpus/separates.txt Normal file
View File

@ -0,0 +1,118 @@
================================================================================
Separate subprograms
================================================================================
package body P is
overriding procedure Proc is separate with Inline;
overriding function Func return Boolean is separate with Inline;
end;
--------------------------------------------------------------------------------
(compilation
(compilation_unit
(proper_body
(package_body
(name
(identifier))
(non_empty_declarative_part
(declarative_item_pragma
(body_stub
(subprogram_body_stub
(overriding_indicator)
(subprogram_specification
(procedure_specification
(name
(identifier))))
(aspect_specification
(aspect_mark_list
(aspect_association
(aspect_mark
(identifier))))))))
(declarative_item_pragma
(body_stub
(subprogram_body_stub
(overriding_indicator)
(subprogram_specification
(function_specification
(name
(identifier))
(parameter_and_result_profile
(result_profile
(name
(identifier))))))
(aspect_specification
(aspect_mark_list
(aspect_association
(aspect_mark
(identifier)))))))))))))
================================================================================
Separate packages
================================================================================
package body P is
package body Child is separate;
end;
--------------------------------------------------------------------------------
(compilation
(compilation_unit
(proper_body
(package_body
(name
(identifier))
(non_empty_declarative_part
(declarative_item_pragma
(body_stub
(package_body_stub
(identifier)))))))))
================================================================================
Separate protected
================================================================================
package body P is
protected body Prot is separate;
end P;
--------------------------------------------------------------------------------
(compilation
(compilation_unit
(proper_body
(package_body
(name
(identifier))
(non_empty_declarative_part
(declarative_item_pragma
(body_stub
(protected_body_stub
(identifier)))))
(name
(identifier))))))
================================================================================
Separate task
================================================================================
package body P is
task body T is separate;
end P;
--------------------------------------------------------------------------------
(compilation
(compilation_unit
(proper_body
(package_body
(name
(identifier))
(non_empty_declarative_part
(declarative_item_pragma
(body_stub
(task_body_stub
(identifier)))))
(name
(identifier))))))

View File

@ -111,13 +111,10 @@ module.exports = grammar({
[$.formal_derived_type_definition], [$.formal_derived_type_definition],
[$._direct_name, $.aspect_mark], [$._direct_name, $.aspect_mark],
[$.name, $.attribute_reference, $.qualified_expression], [$.name, $.attribute_reference, $.qualified_expression],
[$._direct_name, $.package_body_stub],
], ],
// inline: $ => [
// $._direct_name,
// ],
rules: { rules: {
compilation: $ => repeat( compilation: $ => repeat(
$.compilation_unit, $.compilation_unit,
@ -1135,10 +1132,45 @@ module.exports = grammar({
';', ';',
), ),
body_stub: $ => choice( body_stub: $ => choice(
// $.subprogram_body_stub, $.subprogram_body_stub,
// $.package_body_stub, $.package_body_stub,
// $.task_body_stub, $.task_body_stub,
// $.protected_body_stub, $.protected_body_stub,
),
subprogram_body_stub: $ => seq(
optional($.overriding_indicator),
$.subprogram_specification,
reservedWord('is'),
reservedWord('separate'),
optional($.aspect_specification),
';',
),
package_body_stub: $ => seq(
reservedWord('package'),
reservedWord('body'),
$.identifier,
reservedWord('is'),
reservedWord('separate'),
optional($.aspect_specification),
';',
),
task_body_stub: $ => seq(
reservedWord('task'),
reservedWord('body'),
$.identifier,
reservedWord('is'),
reservedWord('separate'),
optional($.aspect_specification),
';',
),
protected_body_stub: $ => seq(
reservedWord('protected'),
reservedWord('body'),
$.identifier,
reservedWord('is'),
reservedWord('separate'),
optional($.aspect_specification),
';',
), ),
choice_parameter_specification: $ => $.identifier, // ??? inline choice_parameter_specification: $ => $.identifier, // ??? inline
component_clause: $ => seq( component_clause: $ => seq(