From e06723eee2cf3452af465fb8f78cb6464e1f94fb Mon Sep 17 00:00:00 2001 From: Emmanuel Briot Date: Tue, 25 Oct 2022 09:53:24 +0200 Subject: [PATCH] Minor cleanups --- corpus/access.txt | 187 ++++++++++++++++++++++++++++++---------------- grammar.js | 35 ++------- 2 files changed, 129 insertions(+), 93 deletions(-) diff --git a/corpus/access.txt b/corpus/access.txt index 8cfbe25..5c2c047 100644 --- a/corpus/access.txt +++ b/corpus/access.txt @@ -1,6 +1,6 @@ -======== +================================================================================ access types -======== +================================================================================ package P is type A is access Integer; @@ -11,69 +11,126 @@ package P is type F is access protected function return Boolean; end; -------- +-------------------------------------------------------------------------------- - (compilation - (compilation_unit - (package_specification - (name - (identifier)) - (type_declaration - (full_type_declaration - (identifier) - (type_definition - (access_type_definition - (access_to_object_definition - (subtype_indication +(compilation + (compilation_unit + (package_specification + (name + (identifier)) + (type_declaration + (full_type_declaration + (identifier) + (type_definition + (access_type_definition + (access_to_object_definition + (subtype_indication + (name + (identifier)))))))) + (type_declaration + (full_type_declaration + (identifier) + (type_definition + (access_type_definition + (access_to_object_definition + (subtype_indication + (null_exclusion) + (name + (identifier)))))))) + (type_declaration + (full_type_declaration + (identifier) + (type_definition + (access_type_definition + (access_to_object_definition + (general_access_modifier) + (subtype_indication + (name + (identifier)))))))) + (type_declaration + (full_type_declaration + (identifier) + (type_definition + (access_type_definition + (access_to_object_definition + (general_access_modifier) + (subtype_indication + (name + (identifier)))))))) + (type_declaration + (full_type_declaration + (identifier) + (type_definition + (access_type_definition + (access_to_subprogram_definition + (parameter_and_result_profile + (result_profile + (name + (identifier))))))))) + (type_declaration + (full_type_declaration + (identifier) + (type_definition + (access_type_definition + (access_to_subprogram_definition + (parameter_and_result_profile + (result_profile + (name + (identifier)))))))))))) + +================================================================================ +Dereference +================================================================================ + +procedure P is +begin + A := Acc.all; + Proc.all (1); +end; + +-------------------------------------------------------------------------------- + +(compilation + (compilation_unit + (proper_body + (subprogram_body + (subprogram_specification + (procedure_specification + (name + (identifier)))) + (handled_sequence_of_statements + (sequence_of_statements + (statement + (simple_statement + (assignment_statement + (name + (identifier)) + (assign_value + (expression + (relation + (simple_expression + (term + (factor + (primary + (name + (identifier) + (name + (identifier))))))))))))) + (statement + (simple_statement + (procedure_call_statement + (name + (function_call (name - (identifier)))))))) - (type_declaration - (full_type_declaration - (identifier) - (type_definition - (access_type_definition - (access_to_object_definition - (subtype_indication - (null_exclusion) - (name - (identifier)))))))) - (type_declaration - (full_type_declaration - (identifier) - (type_definition - (access_type_definition - (access_to_object_definition - (general_access_modifier) - (subtype_indication - (name - (identifier)))))))) - (type_declaration - (full_type_declaration - (identifier) - (type_definition - (access_type_definition - (access_to_object_definition - (general_access_modifier) - (subtype_indication - (name - (identifier)))))))) - (type_declaration - (full_type_declaration - (identifier) - (type_definition - (access_type_definition - (access_to_subprogram_definition - (parameter_and_result_profile - (result_profile + (identifier) (name - (identifier))))))))) - (type_declaration - (full_type_declaration - (identifier) - (type_definition - (access_type_definition - (access_to_subprogram_definition - (parameter_and_result_profile - (result_profile - (name - (identifier)))))))))))) + (identifier))) + (actual_parameter_part + (parameter_association + (expression + (relation + (simple_expression + (term + (factor + (primary + (numeric_literal)))))))))))))))))))) diff --git a/grammar.js b/grammar.js index 04f7183..bf13c7d 100644 --- a/grammar.js +++ b/grammar.js @@ -143,19 +143,9 @@ module.exports = grammar({ '\'', // But is not the start of a character_literal ), - // Simpler definition for games than the standard grammer -// name: $ => choice( -// $.explicit_dereference, -// $.selected_component, -// ), -// _direct_name: $ => choice( -// $.identifier, -// $.string_literal, -// ), - _direct_name: $ => $.identifier, name: $ => choice( - seq( + seq( // inline selected_component from ada-mode $._direct_name, optional(seq( '.', @@ -166,30 +156,19 @@ module.exports = grammar({ $.function_call, $.qualified_expression, '@', - //$.character_literal, // from adamode, seems wrong. - //$.string_literal, // from ada-mode, but seems wrong. - // // Added to primary instead + //$.explicit_dereference, // covered by the first rule above + //$.character_literal, // from adamode, seems wrong. + //$.string_literal, // from ada-mode, but seems wrong. + // // Added to primary instead ), name_list: $ => comma_separated_list_of($.name), defining_identifier_list: $ => comma_separated_list_of($.identifier), - explicit_dereference: $ => seq( - $.name, - '.', - reservedWord('all'), - ), - - // ??? Seems to allow 'name.others' as a component - selected_component: $ => seq( - $.name, - '.', - $.selector_name, - ), selector_name: $ => choice( $._direct_name, -// $.character_literal, // was in ada-mode, moved to primary instead -// reservedWord('others'), + // $.character_literal, // was in ada-mode, moved to primary instead + // reservedWord('others'), ), attribute_reference: $ => choice( seq(