Accept entry families with no parameters

(entry_body): directly parse entry_body_formal_part

In Ada grammar the entry_body_formal_part both the
entry_index_specification and the parameter_profile are optional
(because they describe both simple entries and entry families,
both with and without parameters). However, tree-sitter does not
allow rules that match empty strings.

The simplest solution is to directly encode entry_body_formal_part
within the entry_body.

add test.
This commit is contained in:
Piotr Trojanek 2024-01-03 17:58:44 +01:00 committed by Emmanuel Briot
parent 4312cfd8ba
commit 68040e7ae8
5 changed files with 42250 additions and 40773 deletions

View File

@ -1362,7 +1362,12 @@ module.exports = grammar({
entry_body: $ => seq( entry_body: $ => seq(
reservedWord('entry'), reservedWord('entry'),
$.identifier, $.identifier,
optional($.non_empty_entry_body_formal_part), optional(seq(
'(',
$.entry_index_specification,
')',
)),
field('parameter_profile', optional($.formal_part)),
optional($.aspect_specification), optional($.aspect_specification),
$.entry_barrier, $.entry_barrier,
reservedWord('is'), reservedWord('is'),
@ -1793,14 +1798,6 @@ module.exports = grammar({
)), )),
';', ';',
), ),
non_empty_entry_body_formal_part: $ => seq(
optional(seq(
'(',
$.entry_index_specification,
')',
)),
field('parameter_profile', $.formal_part),
),
entry_declaration: $ => seq( entry_declaration: $ => seq(
optional($.overriding_indicator), optional($.overriding_indicator),
reservedWord('entry'), reservedWord('entry'),

View File

@ -8041,15 +8041,44 @@
{ {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "non_empty_entry_body_formal_part" "name": "entry_index_specification"
},
{
"type": "STRING",
"value": ")"
}
]
}, },
{ {
"type": "BLANK" "type": "BLANK"
} }
] ]
}, },
{
"type": "FIELD",
"name": "parameter_profile",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "formal_part"
},
{
"type": "BLANK"
}
]
}
},
{ {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
@ -10891,44 +10920,6 @@
} }
] ]
}, },
"non_empty_entry_body_formal_part": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
"name": "entry_index_specification"
},
{
"type": "STRING",
"value": ")"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "parameter_profile",
"content": {
"type": "SYMBOL",
"name": "formal_part"
}
}
]
},
"_task_item": { "_task_item": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [

View File

@ -2883,7 +2883,18 @@
{ {
"type": "entry_body", "type": "entry_body",
"named": true, "named": true,
"fields": {}, "fields": {
"parameter_profile": {
"multiple": false,
"required": false,
"types": [
{
"type": "formal_part",
"named": true
}
]
}
},
"children": { "children": {
"multiple": true, "multiple": true,
"required": true, "required": true,
@ -2896,6 +2907,10 @@
"type": "entry_barrier", "type": "entry_barrier",
"named": true "named": true
}, },
{
"type": "entry_index_specification",
"named": true
},
{ {
"type": "handled_sequence_of_statements", "type": "handled_sequence_of_statements",
"named": true "named": true
@ -2907,10 +2922,6 @@
{ {
"type": "non_empty_declarative_part", "type": "non_empty_declarative_part",
"named": true "named": true
},
{
"type": "non_empty_entry_body_formal_part",
"named": true
} }
] ]
} }
@ -7791,32 +7802,6 @@
] ]
} }
}, },
{
"type": "non_empty_entry_body_formal_part",
"named": true,
"fields": {
"parameter_profile": {
"multiple": false,
"required": true,
"types": [
{
"type": "formal_part",
"named": true
}
]
}
},
"children": {
"multiple": false,
"required": false,
"types": [
{
"type": "entry_index_specification",
"named": true
}
]
}
},
{ {
"type": "non_empty_mode", "type": "non_empty_mode",
"named": true, "named": true,

82851
src/parser.c

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@ package body P is
function Func return Boolean; function Func return Boolean;
entry E; entry E;
entry E2 (Color)(A : Integer); entry E2 (Color)(A : Integer);
entry E3 (1 .. 1);
private private
Field : Integer; Field : Integer;
end Obj; end Obj;
@ -23,6 +24,10 @@ package body P is
begin begin
null; null;
end E2; end E2;
entry E3 (for I in 1 .. 1) when True is
begin
null;
end E3;
end Obj; end Obj;
end; end;
@ -54,6 +59,13 @@ end;
(parameter_specification (parameter_specification
(identifier) (identifier)
(identifier)))) (identifier))))
(entry_declaration
(identifier)
(range_g
(term
(numeric_literal))
(term
(numeric_literal))))
(component_declaration (component_declaration
(identifier) (identifier)
(component_definition (component_definition
@ -92,14 +104,29 @@ end;
(identifier)) (identifier))
(entry_body (entry_body
(identifier) (identifier)
(non_empty_entry_body_formal_part
(entry_index_specification (entry_index_specification
(identifier) (identifier)
(identifier)) (identifier))
(formal_part (formal_part
(parameter_specification (parameter_specification
(identifier) (identifier)
(identifier)))
(entry_barrier
(expression
(term
(identifier)))) (identifier))))
(handled_sequence_of_statements
(null_statement))
(identifier))
(entry_body
(identifier)
(entry_index_specification
(identifier)
(range_g
(term
(numeric_literal))
(term
(numeric_literal))))
(entry_barrier (entry_barrier
(expression (expression
(term (term