Support for record aggregates
This commit is contained in:
parent
c0b04e4be1
commit
bf801ce20e
|
|
@ -155,3 +155,89 @@ end;
|
|||
(package_body
|
||||
(name
|
||||
(identifier)))))))
|
||||
|
||||
==========================
|
||||
private types
|
||||
=========================
|
||||
|
||||
package P is
|
||||
type A is private;
|
||||
type B is abstract synchronized new C with private;
|
||||
type C is abstract tagged limited private with Size => 8;
|
||||
end;
|
||||
|
||||
-----------
|
||||
|
||||
(compilation
|
||||
(compilation_unit
|
||||
(package_specification
|
||||
(name
|
||||
(identifier))
|
||||
(type_declaration
|
||||
(private_type_declaration
|
||||
(identifier)))
|
||||
(type_declaration
|
||||
(private_extension_declaration
|
||||
(identifier)
|
||||
(subtype_indication
|
||||
(name
|
||||
(identifier)))))
|
||||
(type_declaration
|
||||
(private_type_declaration
|
||||
(identifier)
|
||||
(aspect_specification
|
||||
(aspect_mark_list
|
||||
(aspect_association
|
||||
(aspect_mark
|
||||
(identifier))
|
||||
(aspect_definition
|
||||
(expression
|
||||
(relation
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(numeric_literal))))))))))))))))
|
||||
|
||||
==========
|
||||
incomplete types
|
||||
==========
|
||||
|
||||
package P is
|
||||
private
|
||||
type I;
|
||||
type R (A : Integer);
|
||||
type R2 (<>);
|
||||
type T is tagged;
|
||||
end;
|
||||
|
||||
--------------
|
||||
|
||||
(compilation
|
||||
(compilation_unit
|
||||
(package_specification
|
||||
(name
|
||||
(identifier))
|
||||
(type_declaration
|
||||
(incomplete_type_declaration
|
||||
(identifier)))
|
||||
(type_declaration
|
||||
(incomplete_type_declaration
|
||||
(identifier)
|
||||
(discriminant_part
|
||||
(known_discriminant_part
|
||||
(discriminant_specification_list
|
||||
(discriminant_specification
|
||||
(defining_identifier_list
|
||||
(identifier))
|
||||
(name
|
||||
(identifier))))))))
|
||||
(type_declaration
|
||||
(incomplete_type_declaration
|
||||
(identifier)
|
||||
(discriminant_part
|
||||
(unknown_discriminant_part))))
|
||||
(type_declaration
|
||||
(incomplete_type_declaration
|
||||
(identifier))))))
|
||||
|
||||
|
|
|
|||
|
|
@ -356,3 +356,179 @@ end;
|
|||
(identifier)))
|
||||
(record_extension_part
|
||||
(record_definition)))))))))
|
||||
|
||||
========
|
||||
record aggregates
|
||||
========
|
||||
|
||||
procedure P is
|
||||
begin
|
||||
A := (F1 => 1, F2 => 2);
|
||||
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
|
||||
(aggregate
|
||||
(record_aggregate
|
||||
(record_component_association_list
|
||||
(record_component_association
|
||||
(component_choice_list
|
||||
(selector_name
|
||||
(identifier)))
|
||||
(assoc_expression
|
||||
(expression
|
||||
(relation
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(numeric_literal)))))))))
|
||||
(record_component_association
|
||||
(component_choice_list
|
||||
(selector_name
|
||||
(identifier)))
|
||||
(assoc_expression
|
||||
(expression
|
||||
(relation
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(numeric_literal))))))))))))))))))))))))))))
|
||||
|
||||
======
|
||||
record aggregate extension
|
||||
======
|
||||
|
||||
procedure P is
|
||||
begin
|
||||
A := (B with F3 => 2);
|
||||
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
|
||||
(aggregate
|
||||
(extension_aggregate
|
||||
(expression
|
||||
(relation
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(name
|
||||
(identifier))))))))
|
||||
(record_component_association_list
|
||||
(record_component_association
|
||||
(component_choice_list
|
||||
(selector_name
|
||||
(identifier)))
|
||||
(assoc_expression
|
||||
(expression
|
||||
(relation
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(numeric_literal))))))))))))))))))))))))))))
|
||||
|
||||
======
|
||||
record delta aggregate
|
||||
======
|
||||
|
||||
procedure P is
|
||||
begin
|
||||
A := (B with delta F3 => 2);
|
||||
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
|
||||
(aggregate
|
||||
(delta_aggregate
|
||||
(record_delta_aggregate
|
||||
(expression
|
||||
(relation
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(name
|
||||
(identifier))))))))
|
||||
(record_component_association_list
|
||||
(record_component_association
|
||||
(component_choice_list
|
||||
(selector_name
|
||||
(identifier)))
|
||||
(assoc_expression
|
||||
(expression
|
||||
(relation
|
||||
(simple_expression
|
||||
(term
|
||||
(factor
|
||||
(primary
|
||||
(numeric_literal)))))))))))))))))))))))))))))
|
||||
|
|
|
|||
|
|
@ -241,9 +241,9 @@ function F2 (A : Integer) return Boolean
|
|||
(name
|
||||
(identifier)))))
|
||||
(aggregate
|
||||
(array_aggregate
|
||||
(positional_array_aggregate
|
||||
(expression_list
|
||||
(record_aggregate
|
||||
(record_component_association_list
|
||||
(record_component_association
|
||||
(expression
|
||||
(relation
|
||||
(simple_expression
|
||||
|
|
@ -281,9 +281,9 @@ function F3 return Boolean
|
|||
(name
|
||||
(identifier)))))
|
||||
(aggregate
|
||||
(array_aggregate
|
||||
(positional_array_aggregate
|
||||
(expression_list
|
||||
(record_aggregate
|
||||
(record_component_association_list
|
||||
(record_component_association
|
||||
(expression
|
||||
(relation
|
||||
(raise_expression
|
||||
|
|
@ -309,9 +309,9 @@ function F4 return Boolean is (True);
|
|||
(name
|
||||
(identifier)))))
|
||||
(aggregate
|
||||
(array_aggregate
|
||||
(positional_array_aggregate
|
||||
(expression_list
|
||||
(record_aggregate
|
||||
(record_component_association_list
|
||||
(record_component_association
|
||||
(expression
|
||||
(relation
|
||||
(simple_expression
|
||||
|
|
@ -421,9 +421,9 @@ function F5 (A : Integer) return Boolean
|
|||
(name
|
||||
(identifier)))))
|
||||
(aggregate
|
||||
(array_aggregate
|
||||
(positional_array_aggregate
|
||||
(expression_list
|
||||
(record_aggregate
|
||||
(record_component_association_list
|
||||
(record_component_association
|
||||
(expression
|
||||
(relation
|
||||
(simple_expression
|
||||
|
|
|
|||
186
grammar.js
186
grammar.js
|
|
@ -50,6 +50,13 @@ module.exports = grammar({
|
|||
// specified in at_clause.
|
||||
[$.at_clause, $.name],
|
||||
|
||||
// name ':=' '(' _direct_name . '=>'
|
||||
// Where the direct_name could be a name or selector_name
|
||||
[$.name, $.selector_name],
|
||||
|
||||
// name ':=' '(' expression . ',' ...
|
||||
[$.expression_list, $.record_component_association],
|
||||
|
||||
// "procedure name is" could be either a procedure specification, or
|
||||
// a generic_instantiation.
|
||||
[$.generic_instantiation, $.procedure_specification],
|
||||
|
|
@ -76,8 +83,18 @@ module.exports = grammar({
|
|||
// ??? This results in a large slowdown of the parser
|
||||
[$.raise_expression],
|
||||
|
||||
// 'type' identifier known_discriminant_part . 'is' ...
|
||||
[$.full_type_declaration, $.discriminant_part],
|
||||
|
||||
// 'type' identifier 'is' 'new' subtype_indication . 'with' .
|
||||
[$.private_extension_declaration, $.derived_type_definition],
|
||||
|
||||
],
|
||||
|
||||
// inline: $ => [
|
||||
// $._direct_name,
|
||||
// ],
|
||||
|
||||
rules: {
|
||||
compilation: $ => repeat(
|
||||
$.compilation_unit,
|
||||
|
|
@ -120,7 +137,7 @@ module.exports = grammar({
|
|||
|
||||
_direct_name: $ => $.identifier,
|
||||
name: $ => seq(
|
||||
$.identifier,
|
||||
$._direct_name,
|
||||
repeat(seq(
|
||||
'.',
|
||||
$.identifier,
|
||||
|
|
@ -134,6 +151,8 @@ module.exports = grammar({
|
|||
'.',
|
||||
reservedWord('all'),
|
||||
),
|
||||
|
||||
// ??? Seems to allow 'name.others' as a component
|
||||
selected_component: $ => seq(
|
||||
$.name,
|
||||
'.',
|
||||
|
|
@ -142,7 +161,7 @@ module.exports = grammar({
|
|||
selector_name: $ => choice(
|
||||
$._direct_name,
|
||||
$.character_literal,
|
||||
reservedWord('others'),
|
||||
// reservedWord('others'),
|
||||
),
|
||||
attribute_reference: $ => choice(
|
||||
seq(
|
||||
|
|
@ -475,6 +494,36 @@ module.exports = grammar({
|
|||
$.name,
|
||||
// $.allocator,
|
||||
),
|
||||
access_type_definition: $ => seq(
|
||||
optional($.null_exclusion),
|
||||
choice(
|
||||
$.access_to_object_definition,
|
||||
seq(
|
||||
reservedWord('access'),
|
||||
optional(reservedWord('protected')),
|
||||
$.access_to_subprogram_definition,
|
||||
),
|
||||
),
|
||||
),
|
||||
access_to_object_definition: $ => seq(
|
||||
reservedWord('access'),
|
||||
optional($.general_access_modifier),
|
||||
$.subtype_indication,
|
||||
),
|
||||
general_access_modifier: $ => choice(
|
||||
reservedWord('all'),
|
||||
reservedWord('constant'),
|
||||
),
|
||||
access_to_subprogram_definition: $ => choice(
|
||||
seq(
|
||||
reservedWord('procedure'),
|
||||
optional($.formal_part),
|
||||
),
|
||||
seq(
|
||||
reservedWord('function'),
|
||||
$.parameter_and_result_profile,
|
||||
),
|
||||
),
|
||||
access_definition: $ => seq(
|
||||
optional($.null_exclusion),
|
||||
reservedWord('access'),
|
||||
|
|
@ -500,7 +549,7 @@ module.exports = grammar({
|
|||
choice(
|
||||
comma_separated_list_of($.parameter_association),
|
||||
$.conditional_expression,
|
||||
// $.quantified_expression,
|
||||
$.quantified_expression,
|
||||
// $.declare_expression,
|
||||
),
|
||||
')',
|
||||
|
|
@ -545,16 +594,14 @@ module.exports = grammar({
|
|||
reservedWord('when'),
|
||||
$.discrete_choice_list,
|
||||
$._non_default_assoc_expression,
|
||||
// '=>',
|
||||
// $.expression,
|
||||
),
|
||||
component_choice_list: $ =>
|
||||
list_of('|', $.selector_name),
|
||||
aggregate: $ => choice(
|
||||
$.record_aggregate,
|
||||
// $.extension_aggregate,
|
||||
$.extension_aggregate,
|
||||
$.array_aggregate,
|
||||
// $.delta_aggregate,
|
||||
$.delta_aggregate,
|
||||
seq(
|
||||
'(',
|
||||
choice(
|
||||
|
|
@ -565,13 +612,63 @@ module.exports = grammar({
|
|||
')',
|
||||
),
|
||||
),
|
||||
delta_aggregate: $ => choice(
|
||||
$.record_delta_aggregate,
|
||||
$.array_delta_aggregate,
|
||||
),
|
||||
extension_aggregate: $ => seq(
|
||||
'(',
|
||||
$.expression,
|
||||
reservedWord('with'),
|
||||
$.record_component_association_list,
|
||||
')',
|
||||
),
|
||||
record_delta_aggregate: $ => seq(
|
||||
'(',
|
||||
$.expression,
|
||||
reservedWord('with'),
|
||||
reservedWord('delta'),
|
||||
$.record_component_association_list,
|
||||
')',
|
||||
),
|
||||
array_delta_aggregate: $ => choice(
|
||||
seq(
|
||||
'(',
|
||||
$.expression,
|
||||
reservedWord('with'),
|
||||
reservedWord('delta'),
|
||||
$.array_component_association_list,
|
||||
')',
|
||||
),
|
||||
seq(
|
||||
'[',
|
||||
$.expression,
|
||||
reservedWord('with'),
|
||||
reservedWord('delta'),
|
||||
$.array_component_association_list,
|
||||
']',
|
||||
),
|
||||
),
|
||||
record_aggregate: $ => seq(
|
||||
'(',
|
||||
$.record_component_association_list,
|
||||
')',
|
||||
),
|
||||
array_component_association: $ => seq(
|
||||
$.discrete_choice_list,
|
||||
$.assoc_expression,
|
||||
),
|
||||
array_component_association_list: $ =>
|
||||
comma_separated_list_of($.array_component_association),
|
||||
record_component_association: $ => choice(
|
||||
seq(
|
||||
$.component_choice_list,
|
||||
$.assoc_expression,
|
||||
),
|
||||
$.expression,
|
||||
),
|
||||
record_component_association_list: $ => choice(
|
||||
// comma_separated_list_of($.record_component_association),
|
||||
comma_separated_list_of($.record_component_association),
|
||||
seq(
|
||||
reservedWord('null'),
|
||||
reservedWord('record'),
|
||||
|
|
@ -605,9 +702,9 @@ module.exports = grammar({
|
|||
),
|
||||
type_declaration: $ => choice(
|
||||
$.full_type_declaration,
|
||||
// $.incomplete_type_declaration,
|
||||
// $.private_type_declaration,
|
||||
// $.private_extension_declaration,
|
||||
$.incomplete_type_declaration,
|
||||
$.private_type_declaration,
|
||||
$.private_extension_declaration,
|
||||
),
|
||||
full_type_declaration: $ => choice(
|
||||
seq(
|
||||
|
|
@ -622,13 +719,67 @@ module.exports = grammar({
|
|||
// $.task_type_declaration,
|
||||
// $.protected_type_declaration,
|
||||
),
|
||||
private_type_declaration: $ => seq(
|
||||
reservedWord('type'),
|
||||
$.identifier,
|
||||
optional($.discriminant_part),
|
||||
reservedWord('is'),
|
||||
optional(seq(
|
||||
optional(reservedWord('abstract')),
|
||||
reservedWord('tagged'),
|
||||
)),
|
||||
optional(reservedWord('limited')),
|
||||
reservedWord('private'),
|
||||
optional($.aspect_specification),
|
||||
';',
|
||||
),
|
||||
private_extension_declaration: $ => seq(
|
||||
reservedWord('type'),
|
||||
$.identifier,
|
||||
optional($.discriminant_part),
|
||||
reservedWord('is'),
|
||||
optional(reservedWord('abstract')),
|
||||
optional(choice(
|
||||
reservedWord('limited'),
|
||||
reservedWord('synchronized'),
|
||||
)),
|
||||
reservedWord('new'),
|
||||
$.subtype_indication,
|
||||
optional(seq(
|
||||
reservedWord('and'),
|
||||
$.interface_list,
|
||||
)),
|
||||
reservedWord('with'),
|
||||
reservedWord('private'),
|
||||
optional($.aspect_specification),
|
||||
';',
|
||||
),
|
||||
discriminant_part: $ => choice(
|
||||
$.known_discriminant_part,
|
||||
$.unknown_discriminant_part,
|
||||
),
|
||||
unknown_discriminant_part: $ => seq(
|
||||
'(',
|
||||
'<>',
|
||||
')',
|
||||
),
|
||||
known_discriminant_part: $ => seq(
|
||||
'(',
|
||||
$.discriminant_specification_list,
|
||||
')',
|
||||
),
|
||||
incomplete_type_declaration: $ => seq(
|
||||
reservedWord('type'),
|
||||
$.identifier,
|
||||
optional($.discriminant_part),
|
||||
optional(seq(
|
||||
reservedWord('is'),
|
||||
reservedWord('tagged'),
|
||||
)),
|
||||
';',
|
||||
),
|
||||
discriminant_specification_list: $ =>
|
||||
list_of(';', $.discriminant_specification),
|
||||
prec.right(list_of(';', $.discriminant_specification)),
|
||||
discriminant_specification: $ => seq(
|
||||
$.defining_identifier_list,
|
||||
':',
|
||||
|
|
@ -647,7 +798,7 @@ module.exports = grammar({
|
|||
$.real_type_definition,
|
||||
$.array_type_definition,
|
||||
$.record_type_definition,
|
||||
// $.access_type_definition,
|
||||
$.access_type_definition,
|
||||
$.derived_type_definition,
|
||||
$.interface_type_definition,
|
||||
),
|
||||
|
|
@ -917,7 +1068,7 @@ module.exports = grammar({
|
|||
),
|
||||
at_clause: $ => seq(
|
||||
reservedWord('for'),
|
||||
$.identifier,
|
||||
$._direct_name,
|
||||
reservedWord('use'),
|
||||
reservedWord('at'),
|
||||
$.expression,
|
||||
|
|
@ -1240,7 +1391,7 @@ module.exports = grammar({
|
|||
)),
|
||||
simple_statement: $ => choice(
|
||||
$.null_statement,
|
||||
// $.assignment_statement,
|
||||
$.assignment_statement,
|
||||
// $.exit_statement,
|
||||
// $.goto_statement,
|
||||
// $.procedure_call_statement,
|
||||
|
|
@ -1258,6 +1409,11 @@ module.exports = grammar({
|
|||
// $.compound_statement,
|
||||
),
|
||||
),
|
||||
assignment_statement: $ => seq(
|
||||
$.name,
|
||||
$.assign_value,
|
||||
';',
|
||||
),
|
||||
subprogram_declaration: $ => seq(
|
||||
optional($.overriding_indicator),
|
||||
$.subprogram_specification,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user