support for discrete_range constraints

This commit is contained in:
Emmanuel Briot 2022-10-24 14:48:54 +02:00
parent 6f6cac7c84
commit 184f9ca9b8
2 changed files with 74 additions and 1 deletions

View File

@ -256,3 +256,72 @@ end P;
(numeric_literal)))))))))))))) (numeric_literal))))))))))))))
(name (name
(identifier))))) (identifier)))))
================================================================================
Subtypes
================================================================================
package P is
subtype T is Integer range 1 .. 2;
subtype Arr is MyArray (1 .. 2, 3 .. 4);
end P;
--------------------------------------------------------------------------------
(compilation
(compilation_unit
(package_specification
(name
(identifier))
(subtype_declaration
(identifier)
(subtype_indication
(name
(identifier))
(constraint
(scalar_constraint
(range_constraint
(range_g
(simple_expression
(term
(factor
(primary
(numeric_literal)))))
(simple_expression
(term
(factor
(primary
(numeric_literal)))))))))))
(subtype_declaration
(identifier)
(subtype_indication
(name
(identifier))
(constraint
(index_constraint
(discrete_range
(range_g
(simple_expression
(term
(factor
(primary
(numeric_literal)))))
(simple_expression
(term
(factor
(primary
(numeric_literal)))))))
(discrete_range
(range_g
(simple_expression
(term
(factor
(primary
(numeric_literal)))))
(simple_expression
(term
(factor
(primary
(numeric_literal)))))))))))
(name
(identifier)))))

View File

@ -730,7 +730,7 @@ module.exports = grammar({
), ),
index_constraint: $ => seq( index_constraint: $ => seq(
'(', '(',
// comma_separated_list_of($.discrete_range), comma_separated_list_of($.discrete_range),
')', ')',
), ),
digits_constraint: $ => seq( digits_constraint: $ => seq(
@ -875,6 +875,10 @@ module.exports = grammar({
$.subtype_indication, $.subtype_indication,
$.range_g, $.range_g,
), ),
discrete_range: $ => choice( // same as discrete_subtype_definition
$.subtype_indication,
$.range_g,
),
_index_subtype_definition_list: $ => _index_subtype_definition_list: $ =>
comma_separated_list_of($.index_subtype_definition), comma_separated_list_of($.index_subtype_definition),
index_subtype_definition: $ => seq( index_subtype_definition: $ => seq(