You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

214 lines
8.0KB

  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 6.5, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>M2 Operators (Debugging with GDB)</title>
  17. <meta name="description" content="M2 Operators (Debugging with GDB)">
  18. <meta name="keywords" content="M2 Operators (Debugging with GDB)">
  19. <meta name="resource-type" content="document">
  20. <meta name="distribution" content="global">
  21. <meta name="Generator" content="makeinfo">
  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="prev" title="Modula-2">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.indentedblock {margin-right: 0em}
  32. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  33. blockquote.smallquotation {font-size: smaller}
  34. div.display {margin-left: 3.2em}
  35. div.example {margin-left: 3.2em}
  36. div.lisp {margin-left: 3.2em}
  37. div.smalldisplay {margin-left: 3.2em}
  38. div.smallexample {margin-left: 3.2em}
  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.nolinebreak {white-space: nowrap}
  50. span.roman {font-family: initial; font-weight: normal}
  51. span.sansserif {font-family: sans-serif; font-weight: normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en">
  57. <a name="M2-Operators"></a>
  58. <div class="header">
  59. <p>
  60. 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>
  61. </div>
  62. <hr>
  63. <a name="Operators"></a>
  64. <h4 class="subsubsection">15.4.9.1 Operators</h4>
  65. <a name="index-Modula_002d2-operators"></a>
  66. <p>Operators must be defined on values of specific types. For instance,
  67. <code>+</code> is defined on numbers, but not on structures. Operators are
  68. often defined on groups of types. For the purposes of Modula-2, the
  69. following definitions hold:
  70. </p>
  71. <ul>
  72. <li> <em>Integral types</em> consist of <code>INTEGER</code>, <code>CARDINAL</code>, and
  73. their subranges.
  74. </li><li> <em>Character types</em> consist of <code>CHAR</code> and its subranges.
  75. </li><li> <em>Floating-point types</em> consist of <code>REAL</code>.
  76. </li><li> <em>Pointer types</em> consist of anything declared as <code>POINTER TO
  77. <var>type</var></code>.
  78. </li><li> <em>Scalar types</em> consist of all of the above.
  79. </li><li> <em>Set types</em> consist of <code>SET</code> and <code>BITSET</code> types.
  80. </li><li> <em>Boolean types</em> consist of <code>BOOLEAN</code>.
  81. </li></ul>
  82. <p>The following operators are supported, and appear in order of
  83. increasing precedence:
  84. </p>
  85. <dl compact="compact">
  86. <dt><code>,</code></dt>
  87. <dd><p>Function argument or array index separator.
  88. </p>
  89. </dd>
  90. <dt><code>:=</code></dt>
  91. <dd><p>Assignment. The value of <var>var</var> <code>:=</code> <var>value</var> is
  92. <var>value</var>.
  93. </p>
  94. </dd>
  95. <dt><code>&lt;<span class="roman">, </span>&gt;</code></dt>
  96. <dd><p>Less than, greater than on integral, floating-point, or enumerated
  97. types.
  98. </p>
  99. </dd>
  100. <dt><code>&lt;=<span class="roman">, </span>&gt;=</code></dt>
  101. <dd><p>Less than or equal to, greater than or equal to
  102. on integral, floating-point and enumerated types, or set inclusion on
  103. set types. Same precedence as <code>&lt;</code>.
  104. </p>
  105. </dd>
  106. <dt><code>=<span class="roman">, </span>&lt;&gt;<span class="roman">, </span>#</code></dt>
  107. <dd><p>Equality and two ways of expressing inequality, valid on scalar types.
  108. Same precedence as <code>&lt;</code>. In <small>GDB</small> scripts, only <code>&lt;&gt;</code> is
  109. available for inequality, since <code>#</code> conflicts with the script
  110. comment character.
  111. </p>
  112. </dd>
  113. <dt><code>IN</code></dt>
  114. <dd><p>Set membership. Defined on set types and the types of their members.
  115. Same precedence as <code>&lt;</code>.
  116. </p>
  117. </dd>
  118. <dt><code>OR</code></dt>
  119. <dd><p>Boolean disjunction. Defined on boolean types.
  120. </p>
  121. </dd>
  122. <dt><code>AND<span class="roman">, </span>&amp;</code></dt>
  123. <dd><p>Boolean conjunction. Defined on boolean types.
  124. </p>
  125. </dd>
  126. <dt><code>@</code></dt>
  127. <dd><p>The <small>GDB</small> &ldquo;artificial array&rdquo; operator (see <a href="Expressions.html#Expressions">Expressions</a>).
  128. </p>
  129. </dd>
  130. <dt><code>+<span class="roman">, </span>-</code></dt>
  131. <dd><p>Addition and subtraction on integral and floating-point types, or union
  132. and difference on set types.
  133. </p>
  134. </dd>
  135. <dt><code>*</code></dt>
  136. <dd><p>Multiplication on integral and floating-point types, or set intersection
  137. on set types.
  138. </p>
  139. </dd>
  140. <dt><code>/</code></dt>
  141. <dd><p>Division on floating-point types, or symmetric set difference on set
  142. types. Same precedence as <code>*</code>.
  143. </p>
  144. </dd>
  145. <dt><code>DIV<span class="roman">, </span>MOD</code></dt>
  146. <dd><p>Integer division and remainder. Defined on integral types. Same
  147. precedence as <code>*</code>.
  148. </p>
  149. </dd>
  150. <dt><code>-</code></dt>
  151. <dd><p>Negative. Defined on <code>INTEGER</code> and <code>REAL</code> data.
  152. </p>
  153. </dd>
  154. <dt><code>^</code></dt>
  155. <dd><p>Pointer dereferencing. Defined on pointer types.
  156. </p>
  157. </dd>
  158. <dt><code>NOT</code></dt>
  159. <dd><p>Boolean negation. Defined on boolean types. Same precedence as
  160. <code>^</code>.
  161. </p>
  162. </dd>
  163. <dt><code>.</code></dt>
  164. <dd><p><code>RECORD</code> field selector. Defined on <code>RECORD</code> data. Same
  165. precedence as <code>^</code>.
  166. </p>
  167. </dd>
  168. <dt><code>[]</code></dt>
  169. <dd><p>Array indexing. Defined on <code>ARRAY</code> data. Same precedence as <code>^</code>.
  170. </p>
  171. </dd>
  172. <dt><code>()</code></dt>
  173. <dd><p>Procedure argument list. Defined on <code>PROCEDURE</code> objects. Same precedence
  174. as <code>^</code>.
  175. </p>
  176. </dd>
  177. <dt><code>::<span class="roman">, </span>.</code></dt>
  178. <dd><p><small>GDB</small> and Modula-2 scope operators.
  179. </p></dd>
  180. </dl>
  181. <blockquote>
  182. <p><em>Warning:</em> Set expressions and their operations are not yet supported, so <small>GDB</small>
  183. treats the use of the operator <code>IN</code>, or the use of operators
  184. <code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>, <code>=</code>, , <code>&lt;&gt;</code>, <code>#</code>,
  185. <code>&lt;=</code>, and <code>&gt;=</code> on sets as an error.
  186. </p></blockquote>
  187. <hr>
  188. <div class="header">
  189. <p>
  190. 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>
  191. </div>
  192. </body>
  193. </html>