From 779bebba99943917b90618cc0cd069c6f62eb397 Mon Sep 17 00:00:00 2001 From: Emmanuel Briot Date: Mon, 24 Oct 2022 14:57:08 +0200 Subject: [PATCH] Add support for separates --- corpus/separates.txt | 118 +++++++++++++++++++++++++++++++++++++++++++ grammar.js | 48 +++++++++++++++--- 2 files changed, 158 insertions(+), 8 deletions(-) create mode 100644 corpus/separates.txt diff --git a/corpus/separates.txt b/corpus/separates.txt new file mode 100644 index 0000000..2426fbe --- /dev/null +++ b/corpus/separates.txt @@ -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)))))) diff --git a/grammar.js b/grammar.js index 7970f32..9372b7b 100644 --- a/grammar.js +++ b/grammar.js @@ -111,13 +111,10 @@ module.exports = grammar({ [$.formal_derived_type_definition], [$._direct_name, $.aspect_mark], [$.name, $.attribute_reference, $.qualified_expression], + [$._direct_name, $.package_body_stub], ], -// inline: $ => [ -// $._direct_name, -// ], - rules: { compilation: $ => repeat( $.compilation_unit, @@ -1135,10 +1132,45 @@ module.exports = grammar({ ';', ), body_stub: $ => choice( -// $.subprogram_body_stub, -// $.package_body_stub, -// $.task_body_stub, -// $.protected_body_stub, + $.subprogram_body_stub, + $.package_body_stub, + $.task_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 component_clause: $ => seq(