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:
parent
4312cfd8ba
commit
68040e7ae8
15
grammar.js
15
grammar.js
|
|
@ -1362,7 +1362,12 @@ module.exports = grammar({
|
|||
entry_body: $ => seq(
|
||||
reservedWord('entry'),
|
||||
$.identifier,
|
||||
optional($.non_empty_entry_body_formal_part),
|
||||
optional(seq(
|
||||
'(',
|
||||
$.entry_index_specification,
|
||||
')',
|
||||
)),
|
||||
field('parameter_profile', optional($.formal_part)),
|
||||
optional($.aspect_specification),
|
||||
$.entry_barrier,
|
||||
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(
|
||||
optional($.overriding_indicator),
|
||||
reservedWord('entry'),
|
||||
|
|
|
|||
|
|
@ -8042,14 +8042,43 @@
|
|||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "non_empty_entry_body_formal_part"
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "entry_index_specification"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ")"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "parameter_profile",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "formal_part"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"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": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
|
|
|
|||
|
|
@ -2883,7 +2883,18 @@
|
|||
{
|
||||
"type": "entry_body",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"fields": {
|
||||
"parameter_profile": {
|
||||
"multiple": false,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "formal_part",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
|
|
@ -2896,6 +2907,10 @@
|
|||
"type": "entry_barrier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "entry_index_specification",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "handled_sequence_of_statements",
|
||||
"named": true
|
||||
|
|
@ -2907,10 +2922,6 @@
|
|||
{
|
||||
"type": "non_empty_declarative_part",
|
||||
"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",
|
||||
"named": true,
|
||||
|
|
|
|||
82851
src/parser.c
82851
src/parser.c
File diff suppressed because it is too large
Load Diff
|
|
@ -8,6 +8,7 @@ package body P is
|
|||
function Func return Boolean;
|
||||
entry E;
|
||||
entry E2 (Color)(A : Integer);
|
||||
entry E3 (1 .. 1);
|
||||
private
|
||||
Field : Integer;
|
||||
end Obj;
|
||||
|
|
@ -23,6 +24,10 @@ package body P is
|
|||
begin
|
||||
null;
|
||||
end E2;
|
||||
entry E3 (for I in 1 .. 1) when True is
|
||||
begin
|
||||
null;
|
||||
end E3;
|
||||
end Obj;
|
||||
end;
|
||||
|
||||
|
|
@ -54,6 +59,13 @@ end;
|
|||
(parameter_specification
|
||||
(identifier)
|
||||
(identifier))))
|
||||
(entry_declaration
|
||||
(identifier)
|
||||
(range_g
|
||||
(term
|
||||
(numeric_literal))
|
||||
(term
|
||||
(numeric_literal))))
|
||||
(component_declaration
|
||||
(identifier)
|
||||
(component_definition
|
||||
|
|
@ -92,14 +104,29 @@ end;
|
|||
(identifier))
|
||||
(entry_body
|
||||
(identifier)
|
||||
(non_empty_entry_body_formal_part
|
||||
(entry_index_specification
|
||||
(entry_index_specification
|
||||
(identifier)
|
||||
(identifier))
|
||||
(formal_part
|
||||
(parameter_specification
|
||||
(identifier)
|
||||
(identifier))
|
||||
(formal_part
|
||||
(parameter_specification
|
||||
(identifier)
|
||||
(identifier)))
|
||||
(entry_barrier
|
||||
(expression
|
||||
(term
|
||||
(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
|
||||
(expression
|
||||
(term
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user