Choice_simple_expression and tested_simple_expression

The RM defines:

relation ::= 
     simple_expression [relational_operator simple_expression]
   | tested_simple_expression [not] in membership_choice_list
   | raise_expression

membership_choice_list ::= membership_choice {'|' membership_choice}

membership_choice ::= choice_simple_expression | range | subtype_mark

but I haven’t found anywhere in the RM that defines what specifically tested_simple_expression and choice_simple_expression are vs just a regular simple_expression. The annotated RM wasn’t much more clear on it (unless I just missed something in the text):

RM: www.ada-auth.org/standards/22aarm/html/AA-4-4.html

If there is an italicized prefix (such as tested_ simple_expression), the prefix is indicating some semantic distinction rather than a syntactic distinction. Syntactically, a prefixed non-terminal is equivalent to the un-prefixed non-terminal (such as “simple_expression”), but semantically there is a difference. In this case, the distinction is given in RM 4.5.2(3.1/5):

If the tested type is tagged, then the tested_ simple_expression shall resolve to be of a type that is convertible (see 4.6) to the tested type; if untagged, the expected type of the tested_ simple_expression is the tested type. The expected type of a choice_ simple_expression in a membership_choice, and of a simple_expression of a range in a membership_choice, is the tested type of the membership operation.

5 Likes

You can read about this convention in RM 1.1.4(14), which is the “Method of Description” section of the manual:

If the name of any syntactic category starts with an italicized part, it is equivalent to the category name without the italicized part. The italicized part is intended to convey some semantic information. For example subtype_ name and task_ name are both equivalent to name alone.

4 Likes

@sttaft Thanks, that helps a lot.

I couldn’t find the terms listed in the index, so I didn’t realize they were more explained in a separate section. So I really do appreciate it! Thank you!

1 Like