1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
  
     | 
    
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
    <TITLE>Ada95 - Expressions</TITLE>
    <META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
    <META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
    <STYLE type="text/css">
    DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
    TT {font-family: "Courier New", monospace}
    DT {display: compact}
    DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
    DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
    DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
    DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
    DIV.Index {font-family: "Times New Roman", Times, serif}
    DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
    DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
    DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
    DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
    DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
    DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
    DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left:  10.0em; margin-bottom: 0.6em}
    DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
    DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
    DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
    DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
    DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left:  15.0em; margin-bottom: 0.6em}
    UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
    DD.Hanging {margin-left: 6.0em}
    DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
    DD.IndentedHanging {margin-left: 2.0em}
    DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.HangingInBulleted {margin-left: 4.0em}
    DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
    DD.SmallHanging {margin-left: 7.5em}
    DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
    DD.SmallIndentedHanging {margin-left: 2.0em}
    DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.SmallHangingInBulleted {margin-left: 5.0em}
    DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.Enumerated {margin-left: 2.0em}
    DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.SmallEnumerated {margin-left: 2.5em}
    DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
    DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    </STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="RM-TOC.html">Contents</A>   <A HREF="RM-0-29.html">Index</A>   <A HREF="RM-4-3-3.html">Previous</A>   <A HREF="RM-4-5.html">Next</A></P>
<HR>
<H1> 4.4 Expressions</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal">   <A NAME="I2331"></A>An <I>expression</I> is a
formula that defines the computation or retrieval of a value. In this
International Standard, the term ``expression'' refers to a construct
of the syntactic category <FONT FACE="Arial, Helvetica">expression</FONT>
or of any of the other five syntactic categories defined below. <A NAME="I2332"></A><A NAME="I2333"></A><A NAME="I2334"></A><A NAME="I2335"></A><A NAME="I2336"></A><A NAME="I2337"></A><A NAME="I2338"></A><A NAME="I2339"></A><A NAME="I2340"></A><A NAME="I2341"></A><A NAME="I2342"></A><A NAME="I2343"></A><A NAME="I2344"></A><A NAME="I2345"></A><A NAME="I2346"></A><A NAME="I2347"></A><A NAME="I2348"></A><A NAME="I2349"></A><A NAME="I2350"></A><A NAME="I2351"></A><A NAME="I2352"></A><A NAME="I2353"></A><A NAME="I2354"></A><A NAME="I2355"></A><A NAME="I2356"></A><A NAME="I2357"></A><A NAME="I2358"></A><A NAME="I2359"></A><A NAME="I2360"></A><A NAME="I2361"></A><A NAME="I2362"></A><A NAME="I2363"></A><A NAME="I2364"></A><A NAME="I2365"></A><A NAME="I2366"></A><A NAME="I2367"></A><A NAME="I2368"></A><A NAME="I2369"></A><A NAME="I2370"></A><A NAME="I2371"></A><A NAME="I2372"></A><A NAME="I2373"></A><A NAME="I2374"></A><A NAME="I2375"></A><A NAME="I2376"></A><A NAME="I2377"></A><A NAME="I2378"></A><A NAME="I2379"></A><A NAME="I2380"></A><A NAME="I2381"></A><A NAME="I2382"></A><A NAME="I2383"></A><A NAME="I2384"></A><A NAME="I2385"></A><A NAME="I2386"></A><A NAME="I2387"></A><A NAME="I2388"></A><A NAME="I2389"></A><A NAME="I2390"></A><A NAME="I2391"></A><A NAME="I2392"></A><A NAME="I2393"></A><A NAME="I2394"></A><A NAME="I2395"></A><A NAME="I2396"></A><A NAME="I2397"></A><A NAME="I2398"></A><A NAME="I2399"></A><A NAME="I2400"></A><A NAME="I2401"></A><A NAME="I2402"></A><A NAME="I2403"></A></DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">expression<A NAME="I2404"></A>
::= </FONT><BR>
     <A NAME="I2405"></A><FONT FACE="Arial, Helvetica">relation</FONT> {<B>and</B> <A NAME="I2406"></A><FONT FACE="Arial, Helvetica">relation</FONT>}  | <A NAME="I2407"></A><FONT FACE="Arial, Helvetica">relation</FONT> {<B>and</B> <B>then</B> <A NAME="I2408"></A><FONT FACE="Arial, Helvetica">relation</FONT>}<BR>
   | <A NAME="I2409"></A><FONT FACE="Arial, Helvetica">relation</FONT> {<B>or</B> <A NAME="I2410"></A><FONT FACE="Arial, Helvetica">relation</FONT>}  | <A NAME="I2411"></A><FONT FACE="Arial, Helvetica">relation</FONT> {<B>or</B> <B>else</B> <A NAME="I2412"></A><FONT FACE="Arial, Helvetica">relation</FONT>}<BR>
   | <A NAME="I2413"></A><FONT FACE="Arial, Helvetica">relation</FONT> {<B>xor</B> <A NAME="I2414"></A><FONT FACE="Arial, Helvetica">relation</FONT>}</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">relation<A NAME="I2415"></A>
::= </FONT><BR>
     <A NAME="I2416"></A><FONT FACE="Arial, Helvetica">simple_expression</FONT> [<A NAME="I2417"></A><FONT FACE="Arial, Helvetica">relational_operator</FONT> <A NAME="I2418"></A><FONT FACE="Arial, Helvetica">simple_expression</FONT>]<BR>
   | <A NAME="I2419"></A><FONT FACE="Arial, Helvetica">simple_expression</FONT> [<B>not</B>] <B>in</B> <A NAME="I2420"></A><FONT FACE="Arial, Helvetica">range</FONT><BR>
   | <A NAME="I2421"></A><FONT FACE="Arial, Helvetica">simple_expression</FONT> [<B>not</B>] <B>in</B> <A NAME="I2422"></A><FONT FACE="Arial, Helvetica">subtype_mark</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">simple_expression<A NAME="I2423"></A>
::= </FONT>[<A NAME="I2424"></A><FONT FACE="Arial, Helvetica">unary_adding_operator</FONT>] <A NAME="I2425"></A><FONT FACE="Arial, Helvetica">term</FONT> {<A NAME="I2426"></A><FONT FACE="Arial, Helvetica">binary_adding_operator</FONT> <A NAME="I2427"></A><FONT FACE="Arial, Helvetica">term</FONT>}</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">term<A NAME="I2428"></A>
::= </FONT><A NAME="I2429"></A><FONT FACE="Arial, Helvetica">factor</FONT> {<A NAME="I2430"></A><FONT FACE="Arial, Helvetica">multiplying_operator</FONT> <A NAME="I2431"></A><FONT FACE="Arial, Helvetica">factor</FONT>}</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">factor<A NAME="I2432"></A>
::= </FONT><A NAME="I2433"></A><FONT FACE="Arial, Helvetica">primary</FONT> [** <A NAME="I2434"></A><FONT FACE="Arial, Helvetica">primary</FONT>] | <B>abs</B> <A NAME="I2435"></A><FONT FACE="Arial, Helvetica">primary</FONT> | <B>not</B> <A NAME="I2436"></A><FONT FACE="Arial, Helvetica">primary</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="SyntaxIndented"><FONT FACE="Arial, Helvetica">primary<A NAME="I2437"></A>
::= </FONT><BR>
   <A NAME="I2438"></A><FONT FACE="Arial, Helvetica">numeric_literal</FONT> | <B>null</B> | <A NAME="I2439"></A><FONT FACE="Arial, Helvetica">string_literal</FONT> | <A NAME="I2440"></A><FONT FACE="Arial, Helvetica">aggregate</FONT><BR>
 | <A NAME="I2441"></A><FONT FACE="Arial, Helvetica">name</FONT> | <A NAME="I2442"></A><FONT FACE="Arial, Helvetica">qualified_expression</FONT> | <A NAME="I2443"></A><FONT FACE="Arial, Helvetica">allocator</FONT> | (<A NAME="I2444"></A><FONT FACE="Arial, Helvetica">expression</FONT>)</DIV>
<H4 ALIGN=CENTER>Name Resolution Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Normal">   A <FONT FACE="Arial, Helvetica">name</FONT> used
as a <FONT FACE="Arial, Helvetica">primary</FONT> shall resolve to denote
an object or a value. </DIV>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Normal">   Each expression has a type; it specifies the computation
or retrieval of a value of that type. </DIV>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Normal">    <A NAME="I2445"></A>The value of a <FONT FACE="Arial, Helvetica">primary</FONT>
that is a <FONT FACE="Arial, Helvetica">name</FONT> denoting an object
is the value of the object. </DIV>
<H4 ALIGN=CENTER>Implementation Permissions</H4>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Normal">    <A NAME="I2446"></A><A NAME="I2447"></A><A NAME="I2448"></A>For
the evaluation of a <FONT FACE="Arial, Helvetica">primary</FONT> that
is a <FONT FACE="Arial, Helvetica">name</FONT> denoting an object of
an unconstrained numeric subtype, if the value of the object is outside
the base range of its type, the implementation may either raise Constraint_Error
or return the value of the object. </DIV>
<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">    <I>Examples of
primaries:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Examples" Style="margin-bottom: 0.9em"><TT>4.0                <I>--  real literal</I><BR>
Pi                 <I>--  named number</I><BR>
(1 .. 10 => 0)     <I>--  array aggregate</I><BR>
Sum                <I>--  variable</I><BR>
Integer'Last       <I>--  attribute</I><BR>
Sine(X)            <I>--  function call</I><BR>
Color'(Blue)       <I>--  qualified expression</I><BR>
Real(M*N)          <I>--  conversion</I><BR>
(Line_Count + 10)  <I>--  parenthesized expression </I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">    <I>Examples of
expressions:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Examples"><TT>Volume                      <I>-- primary</I><BR>
<B>not</B> Destroyed               <I>-- factor</I><BR>
2*Line_Count                <I>-- term  </I><BR>
-4.0                        <I>-- simple expression</I><BR>
-4.0 + A                    <I>-- simple expression</I><BR>
B**2 - 4.0*A*C              <I>-- simple expression</I><BR>
Password(1 .. 3) = "Bwv"    <I>-- relation</I><BR>
Count <B>in</B> Small_Int          <I>-- relation</I><BR>
Count <B>not</B> <B>in</B> Small_Int      <I>-- relation</I><BR>
Index = 0 <B>or</B> Item_Hit       <I>-- expression</I><BR>
(Cold <B>and</B> Sunny) <B>or</B> Warm    <I>-- expression (parentheses are required)</I><BR>
A**(B**C)                   <I>-- expression (parentheses are required)</I></TT></DIV>
<HR>
<P><A HREF="RM-TOC.html">Contents</A>   <A HREF="RM-0-29.html">Index</A>   <A HREF="RM-4-3-3.html">Previous</A>   <A HREF="RM-4-5.html">Next</A>   <A HREF="RM-TTL.html">Legal</A></P>
</BODY>
</HTML>
 
     |