M2-Operators.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Free Software" and "Free Software Needs
  8. Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
  9. and with the Back-Cover Texts as in (a) below.
  10. (a) The FSF's Back-Cover Text is: "You are free to copy and modify
  11. this GNU Manual. Buying copies from GNU Press supports the FSF in
  12. developing GNU and promoting software freedom." -->
  13. <!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <title>Debugging with GDB: M2 Operators</title>
  16. <meta name="description" content="Debugging with GDB: M2 Operators">
  17. <meta name="keywords" content="Debugging with GDB: M2 Operators">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Modula_002d2.html#Modula_002d2" rel="up" title="Modula-2">
  26. <link href="Built_002dIn-Func_002fProc.html#Built_002dIn-Func_002fProc" rel="next" title="Built-In Func/Proc">
  27. <link href="Modula_002d2.html#Modula_002d2" rel="previous" title="Modula-2">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.indentedblock {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style:oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nocodebreak {white-space:nowrap}
  50. span.nolinebreak {white-space:nowrap}
  51. span.roman {font-family:serif; font-weight:normal}
  52. span.sansserif {font-family:sans-serif; font-weight:normal}
  53. ul.no-bullet {list-style: none}
  54. -->
  55. </style>
  56. </head>
  57. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  58. <a name="M2-Operators"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="Built_002dIn-Func_002fProc.html#Built_002dIn-Func_002fProc" accesskey="n" rel="next">Built-In Func/Proc</a>, Up: <a href="Modula_002d2.html#Modula_002d2" accesskey="u" rel="up">Modula-2</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  62. </div>
  63. <hr>
  64. <a name="Operators"></a>
  65. <h4 class="subsubsection">15.4.9.1 Operators</h4>
  66. <a name="index-Modula_002d2-operators"></a>
  67. <p>Operators must be defined on values of specific types. For instance,
  68. <code>+</code> is defined on numbers, but not on structures. Operators are
  69. often defined on groups of types. For the purposes of Modula-2, the
  70. following definitions hold:
  71. </p>
  72. <ul>
  73. <li> <em>Integral types</em> consist of <code>INTEGER</code>, <code>CARDINAL</code>, and
  74. their subranges.
  75. </li><li> <em>Character types</em> consist of <code>CHAR</code> and its subranges.
  76. </li><li> <em>Floating-point types</em> consist of <code>REAL</code>.
  77. </li><li> <em>Pointer types</em> consist of anything declared as <code>POINTER TO
  78. <var>type</var></code>.
  79. </li><li> <em>Scalar types</em> consist of all of the above.
  80. </li><li> <em>Set types</em> consist of <code>SET</code> and <code>BITSET</code> types.
  81. </li><li> <em>Boolean types</em> consist of <code>BOOLEAN</code>.
  82. </li></ul>
  83. <p>The following operators are supported, and appear in order of
  84. increasing precedence:
  85. </p>
  86. <dl compact="compact">
  87. <dt><code>,</code></dt>
  88. <dd><p>Function argument or array index separator.
  89. </p>
  90. </dd>
  91. <dt><code>:=</code></dt>
  92. <dd><p>Assignment. The value of <var>var</var> <code>:=</code> <var>value</var> is
  93. <var>value</var>.
  94. </p>
  95. </dd>
  96. <dt><code>&lt;<span class="roman">, </span>&gt;</code></dt>
  97. <dd><p>Less than, greater than on integral, floating-point, or enumerated
  98. types.
  99. </p>
  100. </dd>
  101. <dt><code>&lt;=<span class="roman">, </span>&gt;=</code></dt>
  102. <dd><p>Less than or equal to, greater than or equal to
  103. on integral, floating-point and enumerated types, or set inclusion on
  104. set types. Same precedence as <code>&lt;</code>.
  105. </p>
  106. </dd>
  107. <dt><code>=<span class="roman">, </span>&lt;&gt;<span class="roman">, </span>#</code></dt>
  108. <dd><p>Equality and two ways of expressing inequality, valid on scalar types.
  109. Same precedence as <code>&lt;</code>. In <small>GDB</small> scripts, only <code>&lt;&gt;</code> is
  110. available for inequality, since <code>#</code> conflicts with the script
  111. comment character.
  112. </p>
  113. </dd>
  114. <dt><code>IN</code></dt>
  115. <dd><p>Set membership. Defined on set types and the types of their members.
  116. Same precedence as <code>&lt;</code>.
  117. </p>
  118. </dd>
  119. <dt><code>OR</code></dt>
  120. <dd><p>Boolean disjunction. Defined on boolean types.
  121. </p>
  122. </dd>
  123. <dt><code>AND<span class="roman">, </span>&amp;</code></dt>
  124. <dd><p>Boolean conjunction. Defined on boolean types.
  125. </p>
  126. </dd>
  127. <dt><code>@</code></dt>
  128. <dd><p>The <small>GDB</small> &ldquo;artificial array&rdquo; operator (see <a href="Expressions.html#Expressions">Expressions</a>).
  129. </p>
  130. </dd>
  131. <dt><code>+<span class="roman">, </span>-</code></dt>
  132. <dd><p>Addition and subtraction on integral and floating-point types, or union
  133. and difference on set types.
  134. </p>
  135. </dd>
  136. <dt><code>*</code></dt>
  137. <dd><p>Multiplication on integral and floating-point types, or set intersection
  138. on set types.
  139. </p>
  140. </dd>
  141. <dt><code>/</code></dt>
  142. <dd><p>Division on floating-point types, or symmetric set difference on set
  143. types. Same precedence as <code>*</code>.
  144. </p>
  145. </dd>
  146. <dt><code>DIV<span class="roman">, </span>MOD</code></dt>
  147. <dd><p>Integer division and remainder. Defined on integral types. Same
  148. precedence as <code>*</code>.
  149. </p>
  150. </dd>
  151. <dt><code>-</code></dt>
  152. <dd><p>Negative. Defined on <code>INTEGER</code> and <code>REAL</code> data.
  153. </p>
  154. </dd>
  155. <dt><code>^</code></dt>
  156. <dd><p>Pointer dereferencing. Defined on pointer types.
  157. </p>
  158. </dd>
  159. <dt><code>NOT</code></dt>
  160. <dd><p>Boolean negation. Defined on boolean types. Same precedence as
  161. <code>^</code>.
  162. </p>
  163. </dd>
  164. <dt><code>.</code></dt>
  165. <dd><p><code>RECORD</code> field selector. Defined on <code>RECORD</code> data. Same
  166. precedence as <code>^</code>.
  167. </p>
  168. </dd>
  169. <dt><code>[]</code></dt>
  170. <dd><p>Array indexing. Defined on <code>ARRAY</code> data. Same precedence as <code>^</code>.
  171. </p>
  172. </dd>
  173. <dt><code>()</code></dt>
  174. <dd><p>Procedure argument list. Defined on <code>PROCEDURE</code> objects. Same precedence
  175. as <code>^</code>.
  176. </p>
  177. </dd>
  178. <dt><code>::<span class="roman">, </span>.</code></dt>
  179. <dd><p><small>GDB</small> and Modula-2 scope operators.
  180. </p></dd>
  181. </dl>
  182. <blockquote>
  183. <p><em>Warning:</em> Set expressions and their operations are not yet supported, so <small>GDB</small>
  184. treats the use of the operator <code>IN</code>, or the use of operators
  185. <code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>, <code>=</code>, , <code>&lt;&gt;</code>, <code>#</code>,
  186. <code>&lt;=</code>, and <code>&gt;=</code> on sets as an error.
  187. </p></blockquote>
  188. <hr>
  189. <div class="header">
  190. <p>
  191. Next: <a href="Built_002dIn-Func_002fProc.html#Built_002dIn-Func_002fProc" accesskey="n" rel="next">Built-In Func/Proc</a>, Up: <a href="Modula_002d2.html#Modula_002d2" accesskey="u" rel="up">Modula-2</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  192. </div>
  193. </body>
  194. </html>