Some more cases of expression functions
This commit is contained in:
parent
8e44c8bc3b
commit
c0b04e4be1
|
|
@ -128,10 +128,7 @@ end P;
|
||||||
(identifier))))))))))
|
(identifier))))))))))
|
||||||
(array_component_association
|
(array_component_association
|
||||||
(discrete_choice_list
|
(discrete_choice_list
|
||||||
(discrete_choice
|
(discrete_choice))
|
||||||
(subtype_indication
|
|
||||||
(name
|
|
||||||
(identifier)))))
|
|
||||||
(assoc_expression
|
(assoc_expression
|
||||||
(expression
|
(expression
|
||||||
(relation
|
(relation
|
||||||
|
|
|
||||||
|
|
@ -310,10 +310,7 @@ end;
|
||||||
(identifier))))))))
|
(identifier))))))))
|
||||||
(variant
|
(variant
|
||||||
(discrete_choice_list
|
(discrete_choice_list
|
||||||
(discrete_choice
|
(discrete_choice))
|
||||||
(subtype_indication
|
|
||||||
(name
|
|
||||||
(identifier)))))
|
|
||||||
(component_list)))))))))))))
|
(component_list)))))))))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,6 @@ procedures
|
||||||
package P is
|
package P is
|
||||||
procedure A (P1, P2 : Integer; P3 : Float)
|
procedure A (P1, P2 : Integer; P3 : Float)
|
||||||
with Inline;
|
with Inline;
|
||||||
procedure B is abstract;
|
|
||||||
procedure C is abstract with Inline;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
@ -75,13 +73,31 @@ end;
|
||||||
(aspect_mark_list
|
(aspect_mark_list
|
||||||
(aspect_association
|
(aspect_association
|
||||||
(aspect_mark
|
(aspect_mark
|
||||||
(identifier))))))
|
(identifier)))))))))
|
||||||
(abstract_subprogram_declaration
|
|
||||||
|
================================================================================
|
||||||
|
abstract procedures
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
package P is
|
||||||
|
procedure B is abstract;
|
||||||
|
overriding procedure C is abstract with Inline;
|
||||||
|
end;
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(compilation
|
||||||
|
(compilation_unit
|
||||||
|
(package_specification
|
||||||
|
(name
|
||||||
|
(identifier))
|
||||||
|
(subprogram_declaration
|
||||||
(subprogram_specification
|
(subprogram_specification
|
||||||
(procedure_specification
|
(procedure_specification
|
||||||
(name
|
(name
|
||||||
(identifier)))))
|
(identifier)))))
|
||||||
(abstract_subprogram_declaration
|
(subprogram_declaration
|
||||||
|
(overriding_indicator)
|
||||||
(subprogram_specification
|
(subprogram_specification
|
||||||
(procedure_specification
|
(procedure_specification
|
||||||
(name
|
(name
|
||||||
|
|
@ -92,6 +108,7 @@ end;
|
||||||
(aspect_mark
|
(aspect_mark
|
||||||
(identifier)))))))))
|
(identifier)))))))))
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
functions
|
functions
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
@ -198,7 +215,7 @@ end;
|
||||||
(identifier))))))))))
|
(identifier))))))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
expression function membership
|
Expression function membership
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
function F2 (A : Integer) return Boolean
|
function F2 (A : Integer) return Boolean
|
||||||
|
|
@ -446,3 +463,143 @@ function F5 (A : Integer) return Boolean
|
||||||
(primary
|
(primary
|
||||||
(name
|
(name
|
||||||
(identifier))))))))))))))))))))))))
|
(identifier))))))))))))))))))))))))
|
||||||
|
|
||||||
|
======
|
||||||
|
Expression function case
|
||||||
|
======
|
||||||
|
|
||||||
|
function F (A : Integer) return Boolean
|
||||||
|
is (case A + 1 is
|
||||||
|
when 0 .. 1 | 3 .. 4 => True,
|
||||||
|
when others => False);
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
(compilation
|
||||||
|
(compilation_unit
|
||||||
|
(expression_function_declaration
|
||||||
|
(function_specification
|
||||||
|
(name
|
||||||
|
(identifier))
|
||||||
|
(parameter_and_result_profile
|
||||||
|
(formal_part
|
||||||
|
(parameter_specification_list
|
||||||
|
(parameter_specification
|
||||||
|
(defining_identifier_list
|
||||||
|
(identifier))
|
||||||
|
(name
|
||||||
|
(identifier)))))
|
||||||
|
(result_profile
|
||||||
|
(name
|
||||||
|
(identifier)))))
|
||||||
|
(aggregate
|
||||||
|
(conditional_expression
|
||||||
|
(case_expression
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(name
|
||||||
|
(identifier)))))
|
||||||
|
(binary_adding_operator)
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal)))))))
|
||||||
|
(case_expression_alternative
|
||||||
|
(discrete_choice_list
|
||||||
|
(discrete_choice
|
||||||
|
(range_g
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal)))))
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal)))))))
|
||||||
|
(discrete_choice
|
||||||
|
(range_g
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal)))))
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal))))))))
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(name
|
||||||
|
(identifier)))))))))
|
||||||
|
(case_expression_alternative
|
||||||
|
(discrete_choice_list
|
||||||
|
(discrete_choice))
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(name
|
||||||
|
(identifier)))))))))))))))
|
||||||
|
|
||||||
|
=====
|
||||||
|
Expression function quantified
|
||||||
|
=====
|
||||||
|
|
||||||
|
function F (A : My_Array) return Boolean
|
||||||
|
is (for some E of A => E = 1);
|
||||||
|
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
(compilation
|
||||||
|
(compilation_unit
|
||||||
|
(expression_function_declaration
|
||||||
|
(function_specification
|
||||||
|
(name
|
||||||
|
(identifier))
|
||||||
|
(parameter_and_result_profile
|
||||||
|
(formal_part
|
||||||
|
(parameter_specification_list
|
||||||
|
(parameter_specification
|
||||||
|
(defining_identifier_list
|
||||||
|
(identifier))
|
||||||
|
(name
|
||||||
|
(identifier)))))
|
||||||
|
(result_profile
|
||||||
|
(name
|
||||||
|
(identifier)))))
|
||||||
|
(aggregate
|
||||||
|
(quantified_expression
|
||||||
|
(quantifier)
|
||||||
|
(iterator_specification
|
||||||
|
(identifier)
|
||||||
|
(name
|
||||||
|
(identifier)))
|
||||||
|
(assoc_expression
|
||||||
|
(expression
|
||||||
|
(relation
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(name
|
||||||
|
(identifier))))))
|
||||||
|
(relational_operator)
|
||||||
|
(simple_expression
|
||||||
|
(term
|
||||||
|
(factor
|
||||||
|
(primary
|
||||||
|
(numeric_literal)))))))))))))
|
||||||
|
|
|
||||||
90
grammar.js
90
grammar.js
|
|
@ -42,13 +42,9 @@ module.exports = grammar({
|
||||||
word: $ => $.identifier,
|
word: $ => $.identifier,
|
||||||
|
|
||||||
conflicts: $ => [
|
conflicts: $ => [
|
||||||
// "function_specification is" could be either an expression function
|
|
||||||
// specification, or a function specification
|
|
||||||
// ??? Maybe we can merge both in the grammar
|
|
||||||
[$.expression_function_declaration, $.subprogram_specification],
|
|
||||||
|
|
||||||
// ??? Maybe we can merge these
|
// ??? Maybe we can merge these
|
||||||
[$.null_procedure_declaration, $.subprogram_specification],
|
[$.null_procedure_declaration, $.subprogram_specification],
|
||||||
|
[$.expression_function_declaration, $.subprogram_specification],
|
||||||
|
|
||||||
// "'for' _direct_name * 'use'" could also be "'for' name * 'use'" as
|
// "'for' _direct_name * 'use'" could also be "'for' name * 'use'" as
|
||||||
// specified in at_clause.
|
// specified in at_clause.
|
||||||
|
|
@ -280,9 +276,8 @@ module.exports = grammar({
|
||||||
$.object_declaration,
|
$.object_declaration,
|
||||||
$.number_declaration,
|
$.number_declaration,
|
||||||
$.subprogram_declaration,
|
$.subprogram_declaration,
|
||||||
$.abstract_subprogram_declaration,
|
|
||||||
$.null_procedure_declaration,
|
|
||||||
$.expression_function_declaration,
|
$.expression_function_declaration,
|
||||||
|
$.null_procedure_declaration,
|
||||||
$._package_declaration,
|
$._package_declaration,
|
||||||
$.renaming_declaration,
|
$.renaming_declaration,
|
||||||
$.exception_declaration,
|
$.exception_declaration,
|
||||||
|
|
@ -402,12 +397,13 @@ module.exports = grammar({
|
||||||
list_of(seq(reservedWord('or'), reservedWord('else')), $.relation),
|
list_of(seq(reservedWord('or'), reservedWord('else')), $.relation),
|
||||||
list_of(reservedWord('xor'), $.relation),
|
list_of(reservedWord('xor'), $.relation),
|
||||||
),
|
),
|
||||||
assoc_expression: $ => seq(
|
assoc_expression: $ => choice(
|
||||||
'=>',
|
seq('=>', '<>'),
|
||||||
choice(
|
$._non_default_assoc_expression,
|
||||||
$.expression,
|
|
||||||
'<>',
|
|
||||||
),
|
),
|
||||||
|
_non_default_assoc_expression: $ => seq(
|
||||||
|
'=>',
|
||||||
|
$.expression,
|
||||||
),
|
),
|
||||||
relation: $ => choice(
|
relation: $ => choice(
|
||||||
seq(
|
seq(
|
||||||
|
|
@ -519,7 +515,38 @@ module.exports = grammar({
|
||||||
),
|
),
|
||||||
conditional_expression: $ => choice(
|
conditional_expression: $ => choice(
|
||||||
$.if_expression,
|
$.if_expression,
|
||||||
// $.case_expression,
|
$.case_expression,
|
||||||
|
),
|
||||||
|
conditional_quantified_expression: $ => choice(
|
||||||
|
$.if_expression,
|
||||||
|
$.case_expression,
|
||||||
|
$.quantified_expression,
|
||||||
|
),
|
||||||
|
quantified_expression: $ => seq(
|
||||||
|
reservedWord('for'),
|
||||||
|
$.quantifier,
|
||||||
|
choice(
|
||||||
|
$.loop_parameter_specification,
|
||||||
|
$.iterator_specification,
|
||||||
|
),
|
||||||
|
$.assoc_expression,
|
||||||
|
),
|
||||||
|
quantifier: $ => choice(
|
||||||
|
reservedWord('all'),
|
||||||
|
reservedWord('some'),
|
||||||
|
),
|
||||||
|
case_expression: $ => seq(
|
||||||
|
reservedWord('case'),
|
||||||
|
$.expression,
|
||||||
|
reservedWord('is'),
|
||||||
|
comma_separated_list_of($.case_expression_alternative),
|
||||||
|
),
|
||||||
|
case_expression_alternative: $ => seq(
|
||||||
|
reservedWord('when'),
|
||||||
|
$.discrete_choice_list,
|
||||||
|
$._non_default_assoc_expression,
|
||||||
|
// '=>',
|
||||||
|
// $.expression,
|
||||||
),
|
),
|
||||||
component_choice_list: $ =>
|
component_choice_list: $ =>
|
||||||
list_of('|', $.selector_name),
|
list_of('|', $.selector_name),
|
||||||
|
|
@ -532,7 +559,7 @@ module.exports = grammar({
|
||||||
'(',
|
'(',
|
||||||
choice(
|
choice(
|
||||||
$.conditional_expression,
|
$.conditional_expression,
|
||||||
// $.quantified_expression,
|
$.quantified_expression,
|
||||||
// $.declare_expression,
|
// $.declare_expression,
|
||||||
),
|
),
|
||||||
')',
|
')',
|
||||||
|
|
@ -796,14 +823,6 @@ module.exports = grammar({
|
||||||
$.access_definition,
|
$.access_definition,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
abstract_subprogram_declaration: $ => seq(
|
|
||||||
optional($.overriding_indicator),
|
|
||||||
$.subprogram_specification,
|
|
||||||
reservedWord('is'),
|
|
||||||
reservedWord('abstract'),
|
|
||||||
optional($.aspect_specification),
|
|
||||||
';',
|
|
||||||
),
|
|
||||||
array_aggregate: $ => choice(
|
array_aggregate: $ => choice(
|
||||||
$.positional_array_aggregate,
|
$.positional_array_aggregate,
|
||||||
$.null_array_aggregate,
|
$.null_array_aggregate,
|
||||||
|
|
@ -861,6 +880,7 @@ module.exports = grammar({
|
||||||
$.expression,
|
$.expression,
|
||||||
$.subtype_indication,
|
$.subtype_indication,
|
||||||
$.range_g,
|
$.range_g,
|
||||||
|
reservedWord('others'),
|
||||||
),
|
),
|
||||||
aspect_association: $ => seq(
|
aspect_association: $ => seq(
|
||||||
$.aspect_mark,
|
$.aspect_mark,
|
||||||
|
|
@ -898,7 +918,6 @@ module.exports = grammar({
|
||||||
at_clause: $ => seq(
|
at_clause: $ => seq(
|
||||||
reservedWord('for'),
|
reservedWord('for'),
|
||||||
$.identifier,
|
$.identifier,
|
||||||
// $._direct_name,
|
|
||||||
reservedWord('use'),
|
reservedWord('use'),
|
||||||
reservedWord('at'),
|
reservedWord('at'),
|
||||||
$.expression,
|
$.expression,
|
||||||
|
|
@ -984,14 +1003,6 @@ module.exports = grammar({
|
||||||
$.exception_handler,
|
$.exception_handler,
|
||||||
$.pragma_g,
|
$.pragma_g,
|
||||||
)),
|
)),
|
||||||
expression_function_declaration: $ => seq(
|
|
||||||
optional($.overriding_indicator),
|
|
||||||
$.function_specification,
|
|
||||||
reservedWord('is'),
|
|
||||||
$.aggregate,
|
|
||||||
optional($.aspect_specification),
|
|
||||||
';',
|
|
||||||
),
|
|
||||||
formal_part: $ => seq(
|
formal_part: $ => seq(
|
||||||
'(',
|
'(',
|
||||||
$.parameter_specification_list,
|
$.parameter_specification_list,
|
||||||
|
|
@ -1172,11 +1183,6 @@ module.exports = grammar({
|
||||||
)),
|
)),
|
||||||
';'
|
';'
|
||||||
),
|
),
|
||||||
conditional_quantified_expression: $ => choice(
|
|
||||||
$.if_expression,
|
|
||||||
// $.case_expression,
|
|
||||||
// $.quantified_expression,
|
|
||||||
),
|
|
||||||
if_expression: $ => seq(
|
if_expression: $ => seq(
|
||||||
reservedWord('if'),
|
reservedWord('if'),
|
||||||
field('condition', $.expression),
|
field('condition', $.expression),
|
||||||
|
|
@ -1255,6 +1261,18 @@ module.exports = grammar({
|
||||||
subprogram_declaration: $ => seq(
|
subprogram_declaration: $ => seq(
|
||||||
optional($.overriding_indicator),
|
optional($.overriding_indicator),
|
||||||
$.subprogram_specification,
|
$.subprogram_specification,
|
||||||
|
field('is_abstract', optional(seq(
|
||||||
|
reservedWord('is'),
|
||||||
|
reservedWord('abstract'),
|
||||||
|
))),
|
||||||
|
optional($.aspect_specification),
|
||||||
|
';',
|
||||||
|
),
|
||||||
|
expression_function_declaration: $ => seq(
|
||||||
|
optional($.overriding_indicator),
|
||||||
|
$.function_specification,
|
||||||
|
reservedWord('is'),
|
||||||
|
$.aggregate,
|
||||||
optional($.aspect_specification),
|
optional($.aspect_specification),
|
||||||
';',
|
';',
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"generate": "tree-sitter generate",
|
"generate": "tree-sitter generate",
|
||||||
"test": "tree-sitter generate && tree-sitter test",
|
"test": "tree-sitter generate && time tree-sitter test",
|
||||||
"update-test": "tree-sitter test --update"
|
"update-test": "tree-sitter test --update"
|
||||||
},
|
},
|
||||||
"main": "bindings/node"
|
"main": "bindings/node"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user