1
|
1 // help.cc -*- C++ -*- |
|
2 /* |
|
3 |
|
4 Copyright (C) 1992, 1993 John W. Eaton |
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef __GNUG__ |
|
25 #pragma implementation |
|
26 #endif |
|
27 |
|
28 #include <iostream.h> |
|
29 #include "builtins.h" |
|
30 #include "help.h" |
|
31 |
|
32 static help_list operators[] = |
|
33 { |
|
34 { "!", |
|
35 "Logical not operator. See also `~'.\n", }, |
|
36 |
|
37 { "!=", |
|
38 "Logical not equals operator. See also `~' and `<>'.\n", }, |
|
39 |
|
40 { "\"", |
|
41 "String delimiter.\n", }, |
|
42 |
|
43 { "#", |
|
44 "Begin comment character. See also `%'.\n", }, |
|
45 |
|
46 { "%", |
|
47 "Begin comment charcter. See also `#'.\n", }, |
|
48 |
|
49 { "&", |
|
50 "Logical and operator. See also `&&'.\n", }, |
|
51 |
|
52 { "&&", |
|
53 "Logical and operator. See also `&'.\n", }, |
|
54 |
|
55 { "'", |
|
56 "Matrix transpose operator. For complex matrices, computes the\n\ |
|
57 complex conjugate (Hermitian) transpose. See also `.''\n\ |
|
58 \n\ |
|
59 The single quote character may also be used to delimit strings, but\n\ |
|
60 it is better to use the double quote character, since that is never\n\ |
|
61 ambiguous\n", }, |
|
62 |
|
63 { "(", |
|
64 "Array index or function argument delimiter.\n", }, |
|
65 |
|
66 { ")", |
|
67 "Array index or function argument delimiter.\n", }, |
|
68 |
|
69 { "*", |
|
70 "Multiplication operator. See also `.*'\n", }, |
|
71 |
|
72 { "**", |
|
73 "Power operator. See also `^', `.**', and `.^'\n", }, |
|
74 |
|
75 { "+", |
|
76 "Addition operator.\n", }, |
|
77 |
|
78 { "++", |
|
79 "Increment operator. As in C, may be applied as a prefix or postfix operator.\n", }, |
|
80 |
|
81 { ",", |
|
82 "Array index, function argument, or command separator.\n", }, |
|
83 |
|
84 { "-", |
|
85 "Subtraction or unary negation operator.\n", }, |
|
86 |
|
87 { "--", |
|
88 "Decrement operator. As in C, may be applied as a prefix or postfix operator.\n", }, |
|
89 |
|
90 { ".'", |
|
91 "Matrix transpose operator. For complex matrices, computes the\n\ |
|
92 transpose, *not* the complex conjugate transpose. See also `''.\n", }, |
|
93 |
|
94 { ".*", |
|
95 "Element by element multiplication operator. See also `*'.\n", }, |
|
96 |
|
97 { ".**", |
|
98 "Element by element power operator. See also `**', `^', and `.^'.\n", }, |
|
99 |
|
100 { "./", |
|
101 "Element by element division operator. See also `/' and `\\'.\n", }, |
|
102 |
|
103 { ".^", |
|
104 "Element by element division operator. See also `/' and `\\'.\n", }, |
|
105 |
|
106 { "/", |
|
107 "Right division. See also `\\' and `./'.\n", }, |
|
108 |
|
109 { ":", |
|
110 "Select entire rows or columns of matrices.\n", }, |
|
111 |
|
112 { ";", |
|
113 "Array row or command separator. See also `,'.\n", }, |
|
114 |
|
115 { "<", |
|
116 "Less than operator.\n", }, |
|
117 |
|
118 { "<=", |
|
119 "Less than or equals operator.\n", }, |
|
120 |
|
121 { "<>", |
|
122 "Logical not equals operator. See also `!=' and `~='.\n", }, |
|
123 |
|
124 { "=", |
|
125 "Assignment operator.\n", }, |
|
126 |
|
127 { "==", |
|
128 "Equality test operator.\n", }, |
|
129 |
|
130 { ">", |
|
131 "Greater than operator.\n", }, |
|
132 |
|
133 { ">=", |
|
134 "Greater than or equals operator.\n", }, |
|
135 |
|
136 { "[", |
|
137 "Return list delimiter. See also `]'.\n", }, |
|
138 |
|
139 { "\\", |
|
140 "Left division operator. See also `/' and `./'.\n", }, |
|
141 |
|
142 { "]", |
|
143 "Return list delimiter. See also `['.\n", }, |
|
144 |
|
145 { "^", |
|
146 "Power operator. See also `**', `.^', and `.**.'\n", }, |
|
147 |
|
148 { "|", |
|
149 "Logical or operator. See also `||'.\n", }, |
|
150 |
|
151 { "||", |
|
152 "Logical or operator. See also `|'.\n", }, |
|
153 |
|
154 { "~", |
|
155 "Logical not operator. See also `!' and `~'.\n", }, |
|
156 |
|
157 { "~=", |
|
158 "Logical not equals operator. See also `<>' and `!='.\n", }, |
|
159 |
|
160 { (char *) NULL, (char *) NULL, }, |
|
161 }; |
|
162 |
|
163 static help_list keywords[] = |
|
164 { |
|
165 { "break", |
|
166 "Exit the innermost enclosing while or for loop.\n", }, |
|
167 |
|
168 { "continue", |
|
169 "Jump to the end of the innermost enclosing while or for loop.\n", }, |
|
170 |
|
171 { "else", |
|
172 "Alternate action for an if block.\n", }, |
|
173 |
|
174 { "elseif", |
|
175 "Alternate conditional test for an if block.\n", }, |
|
176 |
|
177 { "end", |
|
178 "Mark the end of any for, if, while, or function block.\n", }, |
|
179 |
|
180 { "endfor", |
|
181 "Mark the end of a for loop.\n", }, |
|
182 |
|
183 { "endfunction", |
|
184 "Mark the end of a function.\n", }, |
|
185 |
|
186 { "endif", |
|
187 "Mark the end of an if block.\n", }, |
|
188 |
|
189 { "endwhile", |
|
190 "Mark the end of a while loop.\n", }, |
|
191 |
|
192 { "for", |
|
193 "Begin a for loop.\n", }, |
|
194 |
|
195 { "function", |
|
196 "Begin a function body.\n", }, |
|
197 |
|
198 { "global", |
|
199 "Declare variables to have global scope.\n", }, |
|
200 |
|
201 { "gplot", |
|
202 "Produce 2-D plots using gnuplot-like command syntax.\n", }, |
|
203 |
|
204 { "gsplot", |
|
205 "Produce 3-D plots using gnuplot-like command syntax.\n", }, |
|
206 |
|
207 { "if", |
|
208 "Begin an if block.\n", }, |
|
209 |
|
210 { "return", |
|
211 "Return from a function.\n", }, |
|
212 |
|
213 { "while", |
|
214 "Begin a while loop.\n", }, |
|
215 |
|
216 { (char *) NULL, (char *) NULL, }, |
|
217 }; |
|
218 |
|
219 char ** |
|
220 names (help_list *lst, int& count) |
|
221 { |
|
222 count = 0; |
|
223 help_list *ptr = lst; |
|
224 while (ptr->name != (char *) NULL) |
|
225 { |
|
226 count++; |
|
227 ptr++; |
|
228 } |
|
229 |
|
230 if (count == 0) |
|
231 return (char **) NULL; |
|
232 |
|
233 char **name_list = new char * [count+1]; |
|
234 |
|
235 ptr = lst; |
|
236 int i = 0; |
|
237 while (ptr->name != (char *) NULL) |
|
238 { |
|
239 name_list[i++] = ptr->name; |
|
240 ptr++; |
|
241 } |
|
242 |
|
243 name_list[count] = (char *) NULL; |
|
244 return name_list; |
|
245 } |
|
246 |
|
247 help_list * |
|
248 operator_help (void) |
|
249 { |
|
250 return operators; |
|
251 } |
|
252 |
|
253 help_list * |
|
254 keyword_help (void) |
|
255 { |
|
256 return keywords; |
|
257 } |
|
258 |
|
259 /* |
|
260 ;;; Local Variables: *** |
|
261 ;;; mode: C++ *** |
|
262 ;;; page-delimiter: "^/\\*" *** |
|
263 ;;; End: *** |
|
264 */ |