(extension with aggregates): allow a single positional item

This commit is contained in:
Emmanuel Briot 2022-12-14 11:19:43 +01:00
parent c61d74d03a
commit a63a4f53d3
4 changed files with 11259 additions and 11174 deletions

View File

@ -690,7 +690,7 @@ module.exports = grammar({
'(', '(',
$.expression, $.expression,
reservedWord('with'), reservedWord('with'),
$.record_component_association_list, $._record_component_association_list_or_expression,
')', ')',
), ),
record_delta_aggregate: $ => seq( record_delta_aggregate: $ => seq(
@ -698,7 +698,7 @@ module.exports = grammar({
$.expression, $.expression,
reservedWord('with'), reservedWord('with'),
reservedWord('delta'), reservedWord('delta'),
$.record_component_association_list, $._record_component_association_list_or_expression,
')', ')',
), ),
array_delta_aggregate: $ => choice( array_delta_aggregate: $ => choice(
@ -730,7 +730,7 @@ module.exports = grammar({
// * expression, {expression_or_named} // * expression, {expression_or_named}
// expression_or_named:: expression | choice => expression // expression_or_named:: expression | choice => expression
// * named {, named} // * named {, named}
record_component_association_list: $ => choice( record_component_association_list: $ => choice( // RM 4.3.1
seq( seq(
reservedWord('null'), reservedWord('null'),
reservedWord('record'), reservedWord('record'),
@ -745,6 +745,15 @@ module.exports = grammar({
), ),
comma_separated_list_of($._named_record_component_association), comma_separated_list_of($._named_record_component_association),
), ),
// We have modified record_component_association_list to accept a
// minimum of two positional expressions. However, in extension
// aggregates it is valid to have just "(parent with value)"
_record_component_association_list_or_expression: $ => choice(
$.record_component_association_list,
$.expression,
),
_named_record_component_association: $ => seq( // adapted from ARM 4.3.1 _named_record_component_association: $ => seq( // adapted from ARM 4.3.1
$.component_choice_list, $.component_choice_list,
'=>', '=>',

View File

@ -3531,7 +3531,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "record_component_association_list" "name": "_record_component_association_list_or_expression"
}, },
{ {
"type": "STRING", "type": "STRING",
@ -3584,7 +3584,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "record_component_association_list" "name": "_record_component_association_list_or_expression"
}, },
{ {
"type": "STRING", "type": "STRING",
@ -3843,6 +3843,19 @@
} }
] ]
}, },
"_record_component_association_list_or_expression": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "record_component_association_list"
},
{
"type": "SYMBOL",
"name": "expression"
}
]
},
"_named_record_component_association": { "_named_record_component_association": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [

22352
src/parser.c

File diff suppressed because it is too large Load Diff

View File

@ -458,3 +458,52 @@ variants 2
(identifier) (identifier)
(component_definition (component_definition
(identifier))))))))))))) (identifier)))))))))))))
================================================================================
Extension with aggregate
================================================================================
procedure Proc is
Null : constant Rec := (Parent with A => null);
Null2 : constant Rec := (Parent with null);
begin
null;
end;
--------------------------------------------------------------------------------
(compilation
(compilation_unit
(subprogram_body
(procedure_specification
(identifier))
(non_empty_declarative_part
(object_declaration
(identifier)
(identifier)
(expression
(term
(extension_aggregate
(expression
(term
(identifier)))
(record_component_association_list
(component_choice_list
(identifier))
(expression
(term
(primary_null))))))))
(object_declaration
(identifier)
(identifier)
(expression
(term
(extension_aggregate
(expression
(term
(identifier)))
(expression
(term
(primary_null))))))))
(handled_sequence_of_statements
(null_statement)))))