Minor cleanups

This commit is contained in:
Emmanuel Briot 2022-10-25 09:53:24 +02:00
parent 464ba8c3da
commit e06723eee2
2 changed files with 129 additions and 93 deletions

View File

@ -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))))))))))))))))))))

View File

@ -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(