Support for arrays and object declarations
This commit is contained in:
parent
1f837154de
commit
160d197c59
314
corpus/arrays.txt
Normal file
314
corpus/arrays.txt
Normal file
|
|
@ -0,0 +1,314 @@
|
||||||
|
================================================================================
|
||||||
|
Definite
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
package P is
|
||||||
|
type A is array (1 .. 2) of Boolean;
|
||||||
|
V : constant A := (1 => True, 2 => False);
|
||||||
|
V2 : constant A := (1 => True, others => False);
|
||||||
|
end P;
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(compilation
|
||||||
|
(compilation_unit
|
||||||
|
(package_specification
|
||||||
|
(name
|
||||||
|
(identifier))
|
||||||
|
(type_declaration
|
||||||
|
(full_type_declaration
|
||||||
|
(identifier)
|
||||||
|
(type_definition
|
||||||
|
(array_type_definition
|
||||||
|
(constrained_array_definition
|
||||||
|
(discrete_subtype_definition
|
||||||
|
(range_g
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal)))))
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal)))))))
|
||||||
|
(component_definition
|
||||||
|
(subtype_indication
|
||||||
|
(name
|
||||||
|
(identifier)))))))))
|
||||||
|
(object_declaration
|
||||||
|
(defining_identifier_list
|
||||||
|
(identifier))
|
||||||
|
(subtype_indication
|
||||||
|
(name
|
||||||
|
(identifier)))
|
||||||
|
(assign_value
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(aggregate
|
||||||
|
(array_aggregate
|
||||||
|
(named_array_aggregate
|
||||||
|
(array_component_association
|
||||||
|
(discrete_choice_list
|
||||||
|
(discrete_choice
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal)))))))))
|
||||||
|
(assoc_expression
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(name
|
||||||
|
(identifier))))))))))
|
||||||
|
(array_component_association
|
||||||
|
(discrete_choice_list
|
||||||
|
(discrete_choice
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal)))))))))
|
||||||
|
(assoc_expression
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(name
|
||||||
|
(identifier)))))))))))))))))))))
|
||||||
|
(object_declaration
|
||||||
|
(defining_identifier_list
|
||||||
|
(identifier))
|
||||||
|
(subtype_indication
|
||||||
|
(name
|
||||||
|
(identifier)))
|
||||||
|
(assign_value
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(aggregate
|
||||||
|
(array_aggregate
|
||||||
|
(named_array_aggregate
|
||||||
|
(array_component_association
|
||||||
|
(discrete_choice_list
|
||||||
|
(discrete_choice
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal)))))))))
|
||||||
|
(assoc_expression
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(name
|
||||||
|
(identifier))))))))))
|
||||||
|
(array_component_association
|
||||||
|
(discrete_choice_list
|
||||||
|
(discrete_choice
|
||||||
|
(subtype_indication
|
||||||
|
(name
|
||||||
|
(identifier)))))
|
||||||
|
(assoc_expression
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(name
|
||||||
|
(identifier)))))))))))))))))))))
|
||||||
|
(name
|
||||||
|
(identifier)))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Indefinite
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
package P is
|
||||||
|
type B is array (Natural range <>) of Boolean;
|
||||||
|
V : constant B := (1 .. 2 => False);
|
||||||
|
end P;
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(compilation
|
||||||
|
(compilation_unit
|
||||||
|
(package_specification
|
||||||
|
(name
|
||||||
|
(identifier))
|
||||||
|
(type_declaration
|
||||||
|
(full_type_declaration
|
||||||
|
(identifier)
|
||||||
|
(type_definition
|
||||||
|
(array_type_definition
|
||||||
|
(unconstrained_array_definition
|
||||||
|
(index_subtype_definition
|
||||||
|
(name
|
||||||
|
(identifier)))
|
||||||
|
(component_definition
|
||||||
|
(subtype_indication
|
||||||
|
(name
|
||||||
|
(identifier)))))))))
|
||||||
|
(object_declaration
|
||||||
|
(defining_identifier_list
|
||||||
|
(identifier))
|
||||||
|
(subtype_indication
|
||||||
|
(name
|
||||||
|
(identifier)))
|
||||||
|
(assign_value
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(aggregate
|
||||||
|
(array_aggregate
|
||||||
|
(named_array_aggregate
|
||||||
|
(array_component_association
|
||||||
|
(discrete_choice_list
|
||||||
|
(discrete_choice
|
||||||
|
(range_g
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal)))))
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal))))))))
|
||||||
|
(assoc_expression
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(name
|
||||||
|
(identifier)))))))))))))))))))))
|
||||||
|
(name
|
||||||
|
(identifier)))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
2D
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
package P is
|
||||||
|
type C is array (Natural range <>, Integer range <>) of Boolean;
|
||||||
|
V : constant C := (1 .. 2 => (1 .. 2 => False));
|
||||||
|
end P;
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(compilation
|
||||||
|
(compilation_unit
|
||||||
|
(package_specification
|
||||||
|
(name
|
||||||
|
(identifier))
|
||||||
|
(type_declaration
|
||||||
|
(full_type_declaration
|
||||||
|
(identifier)
|
||||||
|
(type_definition
|
||||||
|
(array_type_definition
|
||||||
|
(unconstrained_array_definition
|
||||||
|
(index_subtype_definition
|
||||||
|
(name
|
||||||
|
(identifier)))
|
||||||
|
(index_subtype_definition
|
||||||
|
(name
|
||||||
|
(identifier)))
|
||||||
|
(component_definition
|
||||||
|
(subtype_indication
|
||||||
|
(name
|
||||||
|
(identifier)))))))))
|
||||||
|
(object_declaration
|
||||||
|
(defining_identifier_list
|
||||||
|
(identifier))
|
||||||
|
(subtype_indication
|
||||||
|
(name
|
||||||
|
(identifier)))
|
||||||
|
(assign_value
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(aggregate
|
||||||
|
(array_aggregate
|
||||||
|
(named_array_aggregate
|
||||||
|
(array_component_association
|
||||||
|
(discrete_choice_list
|
||||||
|
(discrete_choice
|
||||||
|
(range_g
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal)))))
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal))))))))
|
||||||
|
(assoc_expression
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(aggregate
|
||||||
|
(array_aggregate
|
||||||
|
(named_array_aggregate
|
||||||
|
(array_component_association
|
||||||
|
(discrete_choice_list
|
||||||
|
(discrete_choice
|
||||||
|
(range_g
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal)))))
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal))))))))
|
||||||
|
(assoc_expression
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(name
|
||||||
|
(identifier))))))))))))))))))))))))))))))))
|
||||||
|
(name
|
||||||
|
(identifier)))))
|
||||||
53
grammar.js
53
grammar.js
|
|
@ -588,12 +588,45 @@ module.exports = grammar({
|
||||||
$.enumeration_type_definition,
|
$.enumeration_type_definition,
|
||||||
$.integer_type_definition,
|
$.integer_type_definition,
|
||||||
$.real_type_definition,
|
$.real_type_definition,
|
||||||
// $.array_type_definition,
|
$.array_type_definition,
|
||||||
// $.record_type_definition,
|
// $.record_type_definition,
|
||||||
// $.access_type_definition,
|
// $.access_type_definition,
|
||||||
$.derived_type_definition,
|
$.derived_type_definition,
|
||||||
// $.interface_type_definition,
|
// $.interface_type_definition,
|
||||||
),
|
),
|
||||||
|
array_type_definition: $ => choice(
|
||||||
|
$.unconstrained_array_definition,
|
||||||
|
$.constrained_array_definition,
|
||||||
|
),
|
||||||
|
unconstrained_array_definition: $ => seq(
|
||||||
|
reservedWord('array'),
|
||||||
|
'(',
|
||||||
|
$._index_subtype_definition_list,
|
||||||
|
')',
|
||||||
|
reservedWord('of'),
|
||||||
|
$.component_definition,
|
||||||
|
),
|
||||||
|
constrained_array_definition: $ => seq(
|
||||||
|
reservedWord('array'),
|
||||||
|
'(',
|
||||||
|
$._discrete_subtype_definition_list,
|
||||||
|
')',
|
||||||
|
reservedWord('of'),
|
||||||
|
$.component_definition,
|
||||||
|
),
|
||||||
|
_discrete_subtype_definition_list: $ =>
|
||||||
|
comma_separated_list_of($.discrete_subtype_definition),
|
||||||
|
discrete_subtype_definition: $ => choice(
|
||||||
|
$.subtype_indication,
|
||||||
|
$.range_g,
|
||||||
|
),
|
||||||
|
_index_subtype_definition_list: $ =>
|
||||||
|
comma_separated_list_of($.index_subtype_definition),
|
||||||
|
index_subtype_definition: $ => seq(
|
||||||
|
$.name,
|
||||||
|
reservedWord('range'),
|
||||||
|
'<>',
|
||||||
|
),
|
||||||
enumeration_type_definition: $ => seq(
|
enumeration_type_definition: $ => seq(
|
||||||
'(',
|
'(',
|
||||||
$._enumeration_literal_list,
|
$._enumeration_literal_list,
|
||||||
|
|
@ -696,7 +729,7 @@ module.exports = grammar({
|
||||||
$.defining_identifier_list,
|
$.defining_identifier_list,
|
||||||
':',
|
':',
|
||||||
$.component_definition,
|
$.component_definition,
|
||||||
// optional($.assign_value),
|
optional($.assign_value),
|
||||||
optional($.aspect_specification),
|
optional($.aspect_specification),
|
||||||
';'
|
';'
|
||||||
),
|
),
|
||||||
|
|
@ -804,6 +837,10 @@ module.exports = grammar({
|
||||||
reservedWord('with'),
|
reservedWord('with'),
|
||||||
$.aspect_mark_list,
|
$.aspect_mark_list,
|
||||||
),
|
),
|
||||||
|
assign_value: $ => seq(
|
||||||
|
':=',
|
||||||
|
$.expression,
|
||||||
|
),
|
||||||
at_clause: $ => seq(
|
at_clause: $ => seq(
|
||||||
reservedWord('for'),
|
reservedWord('for'),
|
||||||
$.identifier,
|
$.identifier,
|
||||||
|
|
@ -1025,21 +1062,21 @@ module.exports = grammar({
|
||||||
$.defining_identifier_list,
|
$.defining_identifier_list,
|
||||||
';',
|
';',
|
||||||
reservedWord('constant'),
|
reservedWord('constant'),
|
||||||
// $.assign_value,
|
$.assign_value,
|
||||||
';',
|
';',
|
||||||
),
|
),
|
||||||
object_declaration: $ => choice(
|
object_declaration: $ => choice(
|
||||||
seq(
|
seq(
|
||||||
$.defining_identifier_list,
|
$.defining_identifier_list,
|
||||||
':',
|
':',
|
||||||
reservedWord('aliased'),
|
optional(reservedWord('aliased')),
|
||||||
reservedWord('constant'),
|
optional(reservedWord('constant')),
|
||||||
choice(
|
choice(
|
||||||
$.subtype_indication,
|
$.subtype_indication,
|
||||||
$.access_definition,
|
$.access_definition,
|
||||||
// $.array_type_definition,
|
$.array_type_definition,
|
||||||
),
|
),
|
||||||
// optional($.assign_value),
|
optional($.assign_value),
|
||||||
optional($.aspect_specification),
|
optional($.aspect_specification),
|
||||||
';',
|
';',
|
||||||
),
|
),
|
||||||
|
|
@ -1063,7 +1100,7 @@ module.exports = grammar({
|
||||||
optional($.non_empty_mode),
|
optional($.non_empty_mode),
|
||||||
optional($.null_exclusion),
|
optional($.null_exclusion),
|
||||||
$.name,
|
$.name,
|
||||||
// optional($.assign_value),
|
optional($.assign_value),
|
||||||
),
|
),
|
||||||
parameter_specification_list: $ => list_of(
|
parameter_specification_list: $ => list_of(
|
||||||
';',
|
';',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user