Fix handling of operator names in parameter_association

This commit is contained in:
Emmanuel Briot 2022-12-14 10:06:22 +01:00
parent 15b9745fff
commit 725a32a592
6 changed files with 30528 additions and 30400 deletions

View File

@ -105,6 +105,8 @@ module.exports = grammar({
[$._name, $._subtype_indication],
[$._name, $._subtype_indication, $.component_choice_list],
[$.attribute_definition_clause, $._attribute_reference],
[$.component_choice_list, $.discrete_choice],
[$.component_choice_list, $.positional_array_aggregate],
],
inline: $ => [
$._name_not_function_call,
@ -666,8 +668,14 @@ module.exports = grammar({
'=>',
$.expression,
),
component_choice_list: $ =>
list_of('|', $.identifier),
component_choice_list: $ => choice( // RM 4.3.1
reservedWord('others'),
list_of('|', choice( // Do not allow slice, function_call,...
$.identifier, // as opposed to what the ARM allows
$.selected_component,
$.string_literal,
)),
),
_aggregate: $ => choice( // RM 4.3
$.record_aggregate,
$.extension_aggregate,

View File

@ -3397,12 +3397,44 @@
]
},
"component_choice_list": {
"type": "CHOICE",
"members": [
{
"type": "ALIAS",
"content": {
"type": "TOKEN",
"content": {
"type": "PREC",
"value": 2,
"content": {
"type": "PATTERN",
"value": "[oO][tT][hH][eE][rR][sS]"
}
}
},
"named": false,
"value": "others"
},
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "selected_component"
},
{
"type": "SYMBOL",
"name": "string_literal"
}
]
},
{
"type": "REPEAT",
"content": {
@ -3412,12 +3444,27 @@
"type": "STRING",
"value": "|"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "selected_component"
},
{
"type": "SYMBOL",
"name": "string_literal"
}
]
}
]
}
}
]
}
]
},
@ -14749,11 +14796,21 @@
[
"attribute_definition_clause",
"_attribute_reference"
],
[
"component_choice_list",
"discrete_choice"
],
[
"component_choice_list",
"positional_array_aggregate"
]
],
"precedences": [],
"externals": [],
"inline": [],
"inline": [
"_name_not_function_call"
],
"supertypes": []
}

View File

@ -1599,11 +1599,19 @@
"fields": {},
"children": {
"multiple": true,
"required": true,
"required": false,
"types": [
{
"type": "identifier",
"named": true
},
{
"type": "selected_component",
"named": true
},
{
"type": "string_literal",
"named": true
}
]
}

60770
src/parser.c

File diff suppressed because it is too large Load Diff

View File

@ -44,8 +44,7 @@ end;
(term
(numeric_literal))))
(parameter_association
(component_choice_list
(identifier))))))
(component_choice_list)))))
(formal_subprogram_declaration
(formal_concrete_subprogram_declaration
(procedure_specification

View File

@ -522,26 +522,26 @@ Subprogram and field access
(numeric_literal))))))
(identifier)))))))
===============================
================================================================================
Parameterless Procedure call
===============================
================================================================================
Proc;
------
--------------------------------------------------------------------------------
(compilation
(compilation_unit
(procedure_call_statement
(identifier))))
===============================
================================================================================
Parameterless Function call
===============================
================================================================================
A := Func;
------
--------------------------------------------------------------------------------
(compilation
(compilation_unit
@ -550,3 +550,33 @@ A := Func;
(expression
(term
(identifier))))))
================================================================================
Parameter association for operators
================================================================================
package P is new Pack ("+" => "+", "-" => Imported."+");
--------------------------------------------------------------------------------
(compilation
(compilation_unit
(generic_instantiation
(identifier)
(function_call
(identifier)
(actual_parameter_part
(parameter_association
(component_choice_list
(string_literal))
(expression
(term
(string_literal))))
(parameter_association
(component_choice_list
(string_literal))
(expression
(term
(selected_component
(identifier)
(string_literal))))))))))