Add discriminant_constraint
This commit is contained in:
parent
a63a4f53d3
commit
b9645c74b2
30
grammar.js
30
grammar.js
|
|
@ -110,6 +110,7 @@ module.exports = grammar({
|
|||
],
|
||||
inline: $ => [
|
||||
$._name_not_function_call,
|
||||
$._name_for_component_choice,
|
||||
],
|
||||
|
||||
rules: {
|
||||
|
|
@ -150,6 +151,12 @@ module.exports = grammar({
|
|||
$._name_not_function_call,
|
||||
$.function_call,
|
||||
),
|
||||
_name_for_component_choice: $ => choice(
|
||||
// Do not allow slice, function_call,... as opposed to what RM allows
|
||||
$.identifier,
|
||||
$.string_literal,
|
||||
),
|
||||
|
||||
selected_component: $ => prec.left(seq( // RM 4.1.3
|
||||
field('prefix', $._name),
|
||||
seq(
|
||||
|
|
@ -392,9 +399,22 @@ module.exports = grammar({
|
|||
field('subtype_mark', $._name_not_function_call),
|
||||
optional($._constraint),
|
||||
),
|
||||
_constraint: $ => choice(
|
||||
discriminant_constraint: $ => seq( // RM 3.7.1
|
||||
'(',
|
||||
comma_separated_list_of($.discriminant_association),
|
||||
')',
|
||||
),
|
||||
discriminant_association: $ => seq( // RM 3.7.1
|
||||
optional(seq(
|
||||
list_of('|', $._name_for_component_choice),
|
||||
'=>',
|
||||
)),
|
||||
$.expression,
|
||||
),
|
||||
_constraint: $ => choice( // RM 3.2.2
|
||||
$._scalar_constraint,
|
||||
$.index_constraint,
|
||||
$.discriminant_constraint,
|
||||
),
|
||||
_scalar_constraint: $ => choice(
|
||||
$.range_constraint,
|
||||
|
|
@ -670,11 +690,7 @@ module.exports = grammar({
|
|||
),
|
||||
component_choice_list: $ => choice( // RM 4.3.1
|
||||
reservedWord('others'),
|
||||
list_of('|', choice( // Do not allow slice, function_call,...
|
||||
$.identifier, // as opposed to what the ARM allows
|
||||
$.selected_component,
|
||||
$.string_literal,
|
||||
)),
|
||||
list_of('|', $._name_for_component_choice),
|
||||
),
|
||||
_aggregate: $ => choice( // RM 4.3
|
||||
$.record_aggregate,
|
||||
|
|
@ -766,7 +782,7 @@ module.exports = grammar({
|
|||
reservedWord('not'),
|
||||
reservedWord('null'),
|
||||
),
|
||||
index_constraint: $ => seq(
|
||||
index_constraint: $ => seq( // RM 3.6.1
|
||||
'(',
|
||||
comma_separated_list_of($._discrete_range),
|
||||
')',
|
||||
|
|
|
|||
143
src/grammar.json
143
src/grammar.json
|
|
@ -193,6 +193,19 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"_name_for_component_choice": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "string_literal"
|
||||
}
|
||||
]
|
||||
},
|
||||
"selected_component": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
|
|
@ -1770,6 +1783,95 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"discriminant_constraint": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "discriminant_association"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "discriminant_association"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ")"
|
||||
}
|
||||
]
|
||||
},
|
||||
"discriminant_association": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_name_for_component_choice"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "|"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_name_for_component_choice"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "=>"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_constraint": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
|
|
@ -1780,6 +1882,10 @@
|
|||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "index_constraint"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "discriminant_constraint"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -3419,21 +3525,8 @@
|
|||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "selected_component"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "string_literal"
|
||||
}
|
||||
]
|
||||
"type": "SYMBOL",
|
||||
"name": "_name_for_component_choice"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
|
|
@ -3445,21 +3538,8 @@
|
|||
"value": "|"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "selected_component"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "string_literal"
|
||||
}
|
||||
]
|
||||
"type": "SYMBOL",
|
||||
"name": "_name_for_component_choice"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -14817,7 +14897,8 @@
|
|||
"precedences": [],
|
||||
"externals": [],
|
||||
"inline": [
|
||||
"_name_not_function_call"
|
||||
"_name_not_function_call",
|
||||
"_name_for_component_choice"
|
||||
],
|
||||
"supertypes": []
|
||||
}
|
||||
|
|
|
|||
|
|
@ -366,6 +366,10 @@
|
|||
"type": "digits_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "general_access_modifier",
|
||||
"named": true
|
||||
|
|
@ -623,6 +627,10 @@
|
|||
"type": "digits_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "index_constraint",
|
||||
"named": true
|
||||
|
|
@ -1312,6 +1320,10 @@
|
|||
"type": "digits_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
|
|
@ -1605,10 +1617,6 @@
|
|||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "selected_component",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "string_literal",
|
||||
"named": true
|
||||
|
|
@ -1824,6 +1832,10 @@
|
|||
"type": "digits_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "index_constraint",
|
||||
"named": true
|
||||
|
|
@ -2262,6 +2274,10 @@
|
|||
"type": "digits_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "function_call",
|
||||
"named": true
|
||||
|
|
@ -2419,6 +2435,10 @@
|
|||
"type": "digits_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "expression",
|
||||
"named": true
|
||||
|
|
@ -2457,6 +2477,44 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "discriminant_association",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "expression",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "string_literal",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "discriminant_association",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "discriminant_specification",
|
||||
"named": true,
|
||||
|
|
@ -2933,6 +2991,10 @@
|
|||
"type": "digits_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
|
|
@ -3031,6 +3093,10 @@
|
|||
"type": "digits_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
|
|
@ -3696,6 +3762,10 @@
|
|||
"type": "digits_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "expression",
|
||||
"named": true
|
||||
|
|
@ -6323,6 +6393,10 @@
|
|||
"type": "digits_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "index_constraint",
|
||||
"named": true
|
||||
|
|
@ -6659,6 +6733,10 @@
|
|||
"type": "digits_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
|
|
@ -6800,6 +6878,10 @@
|
|||
"type": "digits_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
|
|
@ -7346,6 +7428,10 @@
|
|||
"type": "digits_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "expression",
|
||||
"named": true
|
||||
|
|
@ -8302,6 +8388,10 @@
|
|||
"type": "digits_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "function_call",
|
||||
"named": true
|
||||
|
|
@ -10526,6 +10616,10 @@
|
|||
"type": "digits_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "discriminant_constraint",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
|
|
|
|||
63068
src/parser.c
63068
src/parser.c
File diff suppressed because it is too large
Load Diff
|
|
@ -507,3 +507,42 @@ end;
|
|||
(primary_null))))))))
|
||||
(handled_sequence_of_statements
|
||||
(null_statement)))))
|
||||
|
||||
========================
|
||||
Record with discr
|
||||
========================
|
||||
|
||||
procedure Proc is
|
||||
type Rec (Len : Natural) is null record;
|
||||
R : Rec (0);
|
||||
begin
|
||||
null;
|
||||
end;
|
||||
|
||||
--------
|
||||
|
||||
(compilation
|
||||
(compilation_unit
|
||||
(subprogram_body
|
||||
(procedure_specification
|
||||
(identifier))
|
||||
(non_empty_declarative_part
|
||||
(full_type_declaration
|
||||
(identifier)
|
||||
(known_discriminant_part
|
||||
(discriminant_specification_list
|
||||
(discriminant_specification
|
||||
(identifier)
|
||||
(identifier))))
|
||||
(record_type_definition
|
||||
(record_definition)))
|
||||
(object_declaration
|
||||
(identifier)
|
||||
(identifier)
|
||||
(discriminant_constraint
|
||||
(discriminant_association
|
||||
(expression
|
||||
(term
|
||||
(numeric_literal)))))))
|
||||
(handled_sequence_of_statements
|
||||
(null_statement)))))
|
||||
|
|
|
|||
|
|
@ -580,3 +580,24 @@ package P is new Pack ("+" => "+", "-" => Imported."+");
|
|||
(selected_component
|
||||
(identifier)
|
||||
(string_literal))))))))))
|
||||
|
||||
================================================================================
|
||||
Function renaming
|
||||
================================================================================
|
||||
|
||||
function F (S : String) return Boolean renames F2;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(compilation
|
||||
(compilation_unit
|
||||
(subprogram_renaming_declaration
|
||||
(function_specification
|
||||
(identifier)
|
||||
(formal_part
|
||||
(parameter_specification
|
||||
(identifier)
|
||||
(identifier)))
|
||||
(result_profile
|
||||
(identifier)))
|
||||
(identifier))))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user