Accept declare expression in pragma

(_conditional_quantified_expression): accept declare expression; rename

Fixes parsing error that occurred in GNATprove source code.

add test.
This commit is contained in:
Piotr Trojanek 2024-01-03 15:39:15 +01:00 committed by Emmanuel Briot
parent 73d90b439d
commit 07019a9929
5 changed files with 4171 additions and 4124 deletions

View File

@ -661,10 +661,11 @@ module.exports = grammar({
$.if_expression,
$.case_expression,
),
_conditional_quantified_expression: $ => choice(
_conditional_quantified_declare_expression: $ => choice(
$.if_expression,
$.case_expression,
$.quantified_expression,
$.declare_expression,
),
quantified_expression: $ => seq( // ARM 4.5.8
reservedWord('for'),
@ -1862,7 +1863,7 @@ module.exports = grammar({
'(',
choice(
comma_separated_list_of($.pragma_argument_association),
$._conditional_quantified_expression,
$._conditional_quantified_declare_expression,
),
')',
)),

View File

@ -3331,7 +3331,7 @@
}
]
},
"_conditional_quantified_expression": {
"_conditional_quantified_declare_expression": {
"type": "CHOICE",
"members": [
{
@ -3345,6 +3345,10 @@
{
"type": "SYMBOL",
"name": "quantified_expression"
},
{
"type": "SYMBOL",
"name": "declare_expression"
}
]
},
@ -11287,7 +11291,7 @@
},
{
"type": "SYMBOL",
"name": "_conditional_quantified_expression"
"name": "_conditional_quantified_declare_expression"
}
]
},

View File

@ -8865,6 +8865,10 @@
"type": "case_expression",
"named": true
},
{
"type": "declare_expression",
"named": true
},
{
"type": "identifier",
"named": true

File diff suppressed because it is too large Load Diff

View File

@ -129,3 +129,38 @@ end;
(expression
(term
(identifier))))))))))
================================================================================
declare expression in pragma
================================================================================
package P is
pragma Assert
(declare
E : constant Integer := 123;
begin
E = 123);
end P;
--------------------------------------------------------------------------------
(compilation
(compilation_unit
(package_declaration
(identifier)
(pragma_g
(identifier)
(declare_expression
(object_declaration
(identifier)
(identifier)
(expression
(term
(numeric_literal))))
(expression
(term
(identifier))
(relational_operator)
(term
(numeric_literal)))))
(identifier))))