Allow pragmas inside records

This commit is contained in:
Emmanuel Briot 2022-12-14 12:08:24 +01:00
parent b9645c74b2
commit fb54a00c16
5 changed files with 12803 additions and 12719 deletions

View File

@ -1054,8 +1054,9 @@ module.exports = grammar({
_component_item: $ => choice( _component_item: $ => choice(
$.component_declaration, $.component_declaration,
$._aspect_clause, $._aspect_clause,
$.pragma_g, // not in RM
), ),
component_declaration: $ => seq( component_declaration: $ => seq( // RM 3.8
$._defining_identifier_list, $._defining_identifier_list,
':', ':',
$.component_definition, $.component_definition,
@ -1842,7 +1843,7 @@ module.exports = grammar({
';', ';',
$.parameter_specification, $.parameter_specification,
), ),
pragma_g: $ => seq( pragma_g: $ => seq( // RM 2.8
reservedWord('pragma'), reservedWord('pragma'),
$.identifier, $.identifier,
optional(seq( optional(seq(

View File

@ -5928,6 +5928,10 @@
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_aspect_clause" "name": "_aspect_clause"
},
{
"type": "SYMBOL",
"name": "pragma_g"
} }
] ]
}, },

View File

@ -1875,6 +1875,10 @@
"type": "enumeration_representation_clause", "type": "enumeration_representation_clause",
"named": true "named": true
}, },
{
"type": "pragma_g",
"named": true
},
{ {
"type": "record_representation_clause", "type": "record_representation_clause",
"named": true "named": true

25447
src/parser.c

File diff suppressed because it is too large Load Diff

62
test/corpus/pragmas.txt Normal file
View File

@ -0,0 +1,62 @@
================================================================================
pragma on record field
================================================================================
package P is
type R is record
Started : Boolean := False;
pragma Atomic (Started);
end record;
pragma Foo;
end;
--------------------------------------------------------------------------------
(compilation
(compilation_unit
(package_specification
(identifier)
(full_type_declaration
(identifier)
(record_type_definition
(record_definition
(component_list
(component_declaration
(identifier)
(component_definition
(identifier))
(expression
(term
(identifier))))
(pragma_g
(identifier)
(pragma_argument_association
(expression
(term
(identifier)))))))))
(pragma_g
(identifier)))))
================================================================================
pragma in statement
================================================================================
procedure P is
begin
null;
pragma Foo;
null;
end;
--------------------------------------------------------------------------------
(compilation
(compilation_unit
(subprogram_body
(procedure_specification
(identifier))
(handled_sequence_of_statements
(null_statement)
(pragma_g
(identifier))
(null_statement)))))