1994
|
1 /* |
1
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with GNU CC; see the file COPYING. If not, write to the Free |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
20 |
|
21 */ |
|
22 |
|
23 %s TEXT_FCN |
|
24 %s MATRIX |
|
25 |
|
26 %{ |
240
|
27 #ifdef HAVE_CONFIG_H |
1220
|
28 #include <config.h> |
240
|
29 #endif |
|
30 |
1341
|
31 #include <cctype> |
|
32 #include <cstring> |
|
33 |
3503
|
34 #include <strstream> |
1823
|
35 #include <string> |
|
36 |
1
|
37 #include "SLStack.h" |
|
38 |
2926
|
39 #include "cmd-edit.h" |
|
40 |
1497
|
41 // These would be alphabetical, but y.tab.h must be included before |
|
42 // oct-gperf.h and y.tab.h must be included after token.h and the tree |
|
43 // class declarations. We can't include y.tab.h in oct-gperf.h |
|
44 // because it may not be protected to allow it to be included multiple |
|
45 // times. |
|
46 |
3665
|
47 #include "comment-list.h" |
2181
|
48 #include "defun.h" |
1355
|
49 #include "error.h" |
1351
|
50 #include "input.h" |
1355
|
51 #include "lex.h" |
2891
|
52 #include "ov.h" |
1355
|
53 #include "parse.h" |
2987
|
54 #include "pt-all.h" |
2891
|
55 #include "symtab.h" |
|
56 #include "token.h" |
|
57 #include "toplev.h" |
1355
|
58 #include "utils.h" |
|
59 #include "variables.h" |
2492
|
60 #include <y.tab.h> |
|
61 #include <oct-gperf.h> |
1
|
62 |
2716
|
63 #if ! (defined (FLEX_SCANNER) \ |
|
64 && defined (YY_FLEX_MAJOR_VERSION) && YY_FLEX_MAJOR_VERSION >= 2 \ |
|
65 && defined (YY_FLEX_MINOR_VERSION) && YY_FLEX_MINOR_VERSION >= 5) |
|
66 #error lex.l requires flex version 2.5.4 or later |
|
67 #endif |
|
68 |
3883
|
69 // TRUE means that we have encountered EOF on the input stream. |
|
70 bool parser_end_of_input = false; |
|
71 |
1826
|
72 // Flags that need to be shared between the lexer and parser. |
|
73 lexical_feedback lexer_flags; |
|
74 |
1351
|
75 // Stack to hold tokens so that we can delete them when the parser is |
|
76 // reset and avoid growing forever just because we are stashing some |
|
77 // information. This has to appear before lex.h is included, because |
|
78 // one of the macros defined there uses token_stack. |
2614
|
79 // |
|
80 // XXX FIXME XXX -- this should really be static, but that causes |
|
81 // problems on some systems. |
|
82 SLStack <token*> token_stack; |
1351
|
83 |
1826
|
84 // Did eat_whitespace() eat a space or tab, or a newline, or both? |
1
|
85 |
1826
|
86 typedef int yum_yum; |
1
|
87 |
1826
|
88 const yum_yum ATE_NOTHING = 0; |
|
89 const yum_yum ATE_SPACE_OR_TAB = 1; |
|
90 const yum_yum ATE_NEWLINE = 2; |
1088
|
91 |
3351
|
92 // Is the closest nesting level a square bracket, squiggly brace or a paren? |
1826
|
93 |
3351
|
94 class bracket_brace_paren_nesting_level : public SLStack <int> |
1826
|
95 { |
|
96 public: |
|
97 |
3351
|
98 bracket_brace_paren_nesting_level (void) : SLStack<int> () { } |
1826
|
99 |
3351
|
100 ~bracket_brace_paren_nesting_level (void) { } |
|
101 |
|
102 void bracket (void) { push (BRACKET); } |
|
103 bool is_bracket (void) { return ! empty () && top () == BRACKET; } |
1826
|
104 |
|
105 void brace (void) { push (BRACE); } |
|
106 bool is_brace (void) { return ! empty () && top () == BRACE; } |
|
107 |
|
108 void paren (void) { push (PAREN); } |
|
109 bool is_paren (void) { return ! empty () && top () == PAREN; } |
985
|
110 |
1826
|
111 bool none (void) { return empty (); } |
|
112 |
|
113 void remove (void) { if (! empty ()) SLStack<int>::pop (); } |
|
114 |
|
115 private: |
|
116 |
3351
|
117 enum { BRACKET = 1, BRACE = 2, PAREN = 3 }; |
1826
|
118 |
3351
|
119 bracket_brace_paren_nesting_level (const bracket_brace_paren_nesting_level&); |
1826
|
120 |
3351
|
121 bracket_brace_paren_nesting_level& |
|
122 operator = (const bracket_brace_paren_nesting_level&); |
1826
|
123 }; |
|
124 |
3351
|
125 static bracket_brace_paren_nesting_level nesting_level; |
1
|
126 |
2167
|
127 // Should whitespace in a literal matrix list be automatically |
|
128 // converted to commas and semicolons? |
|
129 // |
|
130 // user specifies value of var |
|
131 // -------------- ------------ |
|
132 // "ignore" 2 |
|
133 // "traditional" 1 |
|
134 // anything else 0 |
|
135 // |
|
136 // Octave will never insert a comma in a literal matrix list if the |
|
137 // user specifies "ignore". For example, the statement [1 2] will |
|
138 // result in an error instead of being treated the same as [1, 2], and |
|
139 // the statement |
|
140 // |
|
141 // [ 1, 2, |
|
142 // 3, 4 ] |
|
143 // |
|
144 // will result in the vector [1 2 3 4] instead of a matrix. |
|
145 // |
|
146 // Traditional behavior makes Octave convert spaces to a comma between |
|
147 // identifiers and `('. For example, the statement |
|
148 // |
|
149 // [eye (2)] |
|
150 // |
|
151 // will be parsed as |
|
152 // |
|
153 // [eye, (2)] |
|
154 // |
|
155 // and will result in an error since the `eye' function will be |
|
156 // called with no arguments. To get around this, you would have to |
|
157 // omit the space between `eye' and the `('. |
|
158 // |
|
159 // The default value is 0, which results in behavior that is the same |
|
160 // as traditional, except that Octave does not convert spaces to a |
|
161 // comma between identifiers and `('. For example, the statement |
|
162 // |
|
163 // [eye (2)] |
|
164 // |
|
165 // will result in a call to `eye' with the argument `2'. |
|
166 |
|
167 static int Vwhitespace_in_literal_matrix; |
|
168 |
3388
|
169 static bool Vwarn_separator_insert = false; |
|
170 |
3400
|
171 static bool Vwarn_single_quote_string = false; |
|
172 |
146
|
173 // Forward declarations for functions defined at the bottom of this |
|
174 // file. |
|
175 |
1
|
176 static void fixup_column_count (char *s); |
146
|
177 static void do_comma_insert_check (void); |
3523
|
178 static int is_plot_keyword (const std::string& s); |
|
179 static int is_keyword (const std::string& s); |
|
180 static std::string plot_style_token (const std::string& s); |
|
181 static symbol_record *lookup_identifier (const std::string& s); |
1
|
182 static void grab_help_text (void); |
2857
|
183 static bool match_any (char c, const char *s); |
3263
|
184 static bool next_token_is_sep_op (void); |
3246
|
185 static bool next_token_is_bin_op (bool spc_prev); |
|
186 static bool next_token_is_postfix_unary_op (bool spc_prev); |
3523
|
187 static std::string strip_trailing_whitespace (char *s); |
3246
|
188 static void handle_number (void); |
975
|
189 static int handle_string (char delim, int text_style = 0); |
3351
|
190 static int handle_close_bracket (int spc_gobbled); |
3974
|
191 static int handle_identifier (void); |
3096
|
192 static bool have_continuation (bool trailing_comments_ok = true); |
|
193 static bool have_ellipsis_continuation (bool trailing_comments_ok = true); |
3665
|
194 static void scan_for_comments (const char *); |
1826
|
195 static yum_yum eat_whitespace (void); |
|
196 static yum_yum eat_continuation (void); |
3388
|
197 static void maybe_warn_separator_insert (char sep); |
3400
|
198 static void gripe_single_quote_string (void); |
1
|
199 |
|
200 %} |
|
201 |
|
202 D [0-9] |
|
203 S [ \t] |
2042
|
204 NL ((\n)|(\r\n)) |
|
205 SNL ({S}|{NL}) |
1
|
206 EL (\.\.\.) |
967
|
207 BS (\\) |
|
208 CONT ({EL}|{BS}) |
1
|
209 Im [iIjJ] |
967
|
210 CCHAR [#%] |
|
211 COMMENT ({CCHAR}.*{NL}) |
|
212 SNLCMT ({SNL}|{COMMENT}) |
|
213 NOTEQ ((~=)|(!=)|(<>)) |
|
214 POW ((\*\*)|(\^)) |
|
215 EPOW (\.{POW}) |
|
216 NOT ((\~)|(\!)) |
1
|
217 IDENT ([_a-zA-Z][_a-zA-Z0-9]*) |
|
218 EXPON ([DdEe][+-]?{D}+) |
3220
|
219 NUMBER (({D}+\.?{D}*{EXPON}?)|(\.{D}+{EXPON}?)|(0[xX][0-9a-fA-F]+)) |
1
|
220 %% |
|
221 |
968
|
222 %{ |
|
223 // Help and other text-style functions are a pain in the ass. This |
|
224 // stuff needs to be simplified. May require some changes in the |
|
225 // parser too. |
|
226 %} |
|
227 |
967
|
228 <TEXT_FCN>{NL} { |
|
229 BEGIN 0; |
|
230 current_input_column = 1; |
2857
|
231 lexer_flags.quote_is_transpose = false; |
|
232 lexer_flags.cant_be_identifier = false; |
|
233 lexer_flags.convert_spaces_to_comma = true; |
967
|
234 return '\n'; |
|
235 } |
1
|
236 |
967
|
237 <TEXT_FCN>[\;\,] { |
1826
|
238 if (lexer_flags.doing_set && strcmp (yytext, ",") == 0) |
967
|
239 { |
1060
|
240 TOK_PUSH_AND_RETURN (yytext, TEXT); |
967
|
241 } |
|
242 else |
|
243 { |
|
244 BEGIN 0; |
|
245 if (strcmp (yytext, ",") == 0) |
|
246 TOK_RETURN (','); |
|
247 else |
|
248 TOK_RETURN (';'); |
|
249 } |
|
250 } |
1
|
251 |
975
|
252 <TEXT_FCN>[\"\'] { |
|
253 current_input_column++; |
3246
|
254 return handle_string (yytext[0], true); |
975
|
255 } |
|
256 |
3079
|
257 <TEXT_FCN>[^ \t\n\;\,\"\'][^ \t\n\;\,]*{S}* { |
3523
|
258 std::string tok = strip_trailing_whitespace (yytext); |
1060
|
259 TOK_PUSH_AND_RETURN (tok, TEXT); |
967
|
260 } |
1
|
261 |
968
|
262 %{ |
1
|
263 // For this and the next two rules, we're looking at ']', and we |
971
|
264 // need to know if the next token is `=' or `=='. |
1
|
265 // |
|
266 // It would have been so much easier if the delimiters were simply |
|
267 // different for the expression on the left hand side of the equals |
|
268 // operator. |
971
|
269 // |
|
270 // It's also a pain in the ass to decide whether to insert a comma |
|
271 // after seeing a ']' character... |
968
|
272 %} |
|
273 |
2119
|
274 <MATRIX>{SNLCMT}*\]{S}* { |
3665
|
275 scan_for_comments (yytext); |
1001
|
276 fixup_column_count (yytext); |
|
277 int c = yytext[yyleng-1]; |
|
278 int cont_is_spc = eat_continuation (); |
|
279 int spc_gobbled = (cont_is_spc || c == ' ' || c == '\t'); |
3351
|
280 return handle_close_bracket (spc_gobbled); |
967
|
281 } |
1
|
282 |
968
|
283 %{ |
1088
|
284 // Commas are element separators in matrix constants. If we don't |
|
285 // check for continuations here we can end up inserting too many |
|
286 // commas. |
968
|
287 %} |
|
288 |
967
|
289 <MATRIX>{S}*\,{S}* { |
1088
|
290 current_input_column += yyleng; |
3388
|
291 |
1088
|
292 int tmp = eat_continuation (); |
3388
|
293 |
2857
|
294 lexer_flags.quote_is_transpose = false; |
|
295 lexer_flags.cant_be_identifier = false; |
|
296 lexer_flags.convert_spaces_to_comma = true; |
3388
|
297 |
|
298 if ((tmp & ATE_NEWLINE) == ATE_NEWLINE) |
|
299 { |
|
300 maybe_warn_separator_insert (';'); |
|
301 |
|
302 if (Vwhitespace_in_literal_matrix != 2) |
|
303 unput (';'); |
|
304 } |
|
305 |
1088
|
306 return (','); |
967
|
307 } |
1
|
308 |
968
|
309 %{ |
|
310 // In some cases, spaces in matrix constants can turn into commas. |
|
311 // If commas are required, spaces are not important in matrix |
1088
|
312 // constants so we just eat them. If we don't check for continuations |
|
313 // here we can end up inserting too many commas. |
968
|
314 %} |
430
|
315 |
968
|
316 <MATRIX>{S}+ { |
1088
|
317 current_input_column += yyleng; |
3388
|
318 |
|
319 int tmp = eat_continuation (); |
|
320 int bin_op = next_token_is_bin_op (true); |
|
321 int postfix_un_op = next_token_is_postfix_unary_op (true); |
|
322 |
|
323 if (! (postfix_un_op || bin_op) |
|
324 && nesting_level.is_bracket () |
|
325 && lexer_flags.convert_spaces_to_comma) |
967
|
326 { |
3388
|
327 if ((tmp & ATE_NEWLINE) == ATE_NEWLINE) |
|
328 { |
|
329 maybe_warn_separator_insert (';'); |
967
|
330 |
3388
|
331 if (Vwhitespace_in_literal_matrix != 2) |
|
332 unput (';'); |
|
333 } |
|
334 |
|
335 if (Vwhitespace_in_literal_matrix != 2) |
1088
|
336 { |
2857
|
337 lexer_flags.quote_is_transpose = false; |
|
338 lexer_flags.cant_be_identifier = false; |
|
339 lexer_flags.convert_spaces_to_comma = true; |
3388
|
340 |
|
341 maybe_warn_separator_insert (','); |
|
342 |
1088
|
343 return (','); |
|
344 } |
967
|
345 } |
|
346 } |
430
|
347 |
968
|
348 %{ |
1088
|
349 // Semicolons are handled as row seprators in matrix constants. If we |
|
350 // don't eat whitespace here we can end up inserting too many |
|
351 // semicolons. |
968
|
352 %} |
|
353 |
985
|
354 <MATRIX>{SNLCMT}*;{SNLCMT}* { |
3665
|
355 scan_for_comments (yytext); |
967
|
356 fixup_column_count (yytext); |
1001
|
357 eat_whitespace (); |
2857
|
358 lexer_flags.quote_is_transpose = false; |
|
359 lexer_flags.cant_be_identifier = false; |
|
360 lexer_flags.convert_spaces_to_comma = true; |
967
|
361 return ';'; |
|
362 } |
|
363 |
968
|
364 %{ |
1088
|
365 // In some cases, new lines can also become row separators. If we |
|
366 // don't eat whitespace here we can end up inserting too many |
|
367 // semicolons. |
985
|
368 %} |
|
369 |
3180
|
370 <MATRIX>{S}*{COMMENT}{SNLCMT}* | |
|
371 <MATRIX>{S}*{NL}{SNLCMT}* { |
3665
|
372 scan_for_comments (yytext); |
1082
|
373 fixup_column_count (yytext); |
1088
|
374 eat_whitespace (); |
3388
|
375 |
2167
|
376 if (Vwhitespace_in_literal_matrix != 2) |
985
|
377 { |
2857
|
378 lexer_flags.quote_is_transpose = false; |
|
379 lexer_flags.cant_be_identifier = false; |
|
380 lexer_flags.convert_spaces_to_comma = true; |
985
|
381 |
1826
|
382 if (nesting_level.none ()) |
985
|
383 return LEXICAL_ERROR; |
3388
|
384 } |
985
|
385 |
3388
|
386 if (nesting_level.is_bracket ()) |
|
387 { |
|
388 maybe_warn_separator_insert (';'); |
|
389 |
|
390 if (Vwhitespace_in_literal_matrix != 2) |
985
|
391 return ';'; |
|
392 } |
|
393 } |
|
394 |
|
395 %{ |
3351
|
396 // Open and close bracket are handled differently if we are in the range |
968
|
397 // part of a plot command. |
975
|
398 // |
968
|
399 %} |
1
|
400 |
967
|
401 \[{S}* { |
3351
|
402 nesting_level.bracket (); |
975
|
403 |
1082
|
404 current_input_column += yyleng; |
2857
|
405 lexer_flags.quote_is_transpose = false; |
|
406 lexer_flags.cant_be_identifier = false; |
|
407 lexer_flags.convert_spaces_to_comma = true; |
975
|
408 |
|
409 promptflag--; |
|
410 eat_whitespace (); |
|
411 |
1826
|
412 if (lexer_flags.plotting && ! lexer_flags.past_plot_range) |
967
|
413 { |
2857
|
414 lexer_flags.in_plot_range = true; |
1082
|
415 return OPEN_BRACE; |
967
|
416 } |
|
417 else |
|
418 { |
3351
|
419 lexer_flags.bracketflag++; |
975
|
420 BEGIN MATRIX; |
1082
|
421 return '['; |
967
|
422 } |
|
423 } |
1
|
424 |
968
|
425 \] { |
1826
|
426 nesting_level.remove (); |
968
|
427 |
1826
|
428 if (lexer_flags.plotting && ! lexer_flags.past_plot_range) |
968
|
429 { |
2857
|
430 lexer_flags.in_plot_range = false; |
968
|
431 TOK_RETURN (CLOSE_BRACE); |
|
432 } |
|
433 else |
|
434 TOK_RETURN (']'); |
|
435 } |
|
436 |
|
437 %{ |
|
438 // Imaginary numbers. |
|
439 %} |
|
440 |
|
441 {NUMBER}{Im} { |
3246
|
442 handle_number (); |
968
|
443 return IMAG_NUM; |
|
444 } |
|
445 |
|
446 %{ |
|
447 // Real numbers. Don't grab the `.' part of a dot operator as part of |
|
448 // the constant. |
|
449 %} |
|
450 |
|
451 {D}+/\.[\*/\\^'] | |
|
452 {NUMBER} { |
3246
|
453 handle_number (); |
968
|
454 return NUM; |
|
455 } |
|
456 |
|
457 %{ |
|
458 // Eat whitespace. Whitespace inside matrix constants is handled by |
|
459 // the <MATRIX> start state code above. |
|
460 %} |
|
461 |
967
|
462 {S}* { |
|
463 current_input_column += yyleng; |
|
464 } |
|
465 |
968
|
466 %{ |
|
467 // Continuation lines. Allow comments after continuations. |
|
468 %} |
|
469 |
967
|
470 {CONT}{S}*{NL} | |
|
471 {CONT}{S}*{COMMENT} { |
3665
|
472 scan_for_comments (yytext); |
967
|
473 promptflag--; |
|
474 current_input_column = 1; |
|
475 } |
1
|
476 |
968
|
477 %{ |
|
478 // An ellipsis not at the end of a line is not a continuation, but |
|
479 // does have another meaning. |
|
480 %} |
|
481 |
967
|
482 {EL} { |
3973
|
483 if (lexer_flags.looking_at_parameter_list) |
3974
|
484 { |
|
485 warning ("`...' is deprecated; use varargin instead"); |
|
486 return VARARGIN; |
|
487 } |
3973
|
488 else if (lexer_flags.looking_at_return_list) |
3974
|
489 { |
|
490 warning ("`...' is deprecated; use varargout instead"); |
|
491 return VARARGOUT; |
|
492 } |
3973
|
493 else |
|
494 return LEXICAL_ERROR; |
967
|
495 } |
1
|
496 |
968
|
497 %{ |
|
498 // End of file. |
|
499 %} |
|
500 |
967
|
501 <<EOF>> { |
|
502 TOK_RETURN (END_OF_INPUT); |
|
503 } |
1
|
504 |
968
|
505 %{ |
970
|
506 // Identifiers. Truncate the token at the first space or tab but |
|
507 // don't write directly on yytext. |
968
|
508 %} |
|
509 |
967
|
510 {IDENT}{S}* { |
3974
|
511 return handle_identifier (); |
967
|
512 } |
1
|
513 |
968
|
514 %{ |
|
515 // A new line character. New line characters inside matrix constants |
985
|
516 // are handled by the <MATRIX> start state code above. If closest |
|
517 // nesting is inside parentheses, don't return a row separator. |
968
|
518 %} |
|
519 |
967
|
520 {NL} { |
|
521 current_input_column = 1; |
2857
|
522 lexer_flags.quote_is_transpose = false; |
|
523 lexer_flags.cant_be_identifier = false; |
|
524 lexer_flags.convert_spaces_to_comma = true; |
985
|
525 |
1826
|
526 if (nesting_level.none ()) |
985
|
527 return '\n'; |
|
528 |
3351
|
529 if (nesting_level.is_bracket ()) |
985
|
530 return LEXICAL_ERROR; |
967
|
531 } |
1
|
532 |
968
|
533 %{ |
|
534 // Single quote can either be the beginning of a string or a transpose |
|
535 // operator. |
|
536 %} |
|
537 |
967
|
538 "'" { |
|
539 current_input_column++; |
2857
|
540 lexer_flags.convert_spaces_to_comma = true; |
1
|
541 |
1826
|
542 if (lexer_flags.quote_is_transpose) |
967
|
543 { |
|
544 do_comma_insert_check (); |
|
545 return QUOTE; |
|
546 } |
|
547 else |
973
|
548 return handle_string ('\''); |
967
|
549 } |
1
|
550 |
968
|
551 %{ |
971
|
552 // Double quotes always begin strings. |
|
553 %} |
|
554 |
973
|
555 \" { |
|
556 current_input_column++; |
|
557 return handle_string ('"'); |
|
558 } |
971
|
559 |
|
560 %{ |
|
561 // The colon operator is handled differently if we are in the range |
|
562 // part of a plot command. |
968
|
563 %} |
|
564 |
967
|
565 ":" { |
1826
|
566 if (lexer_flags.plotting |
|
567 && (lexer_flags.in_plot_range || lexer_flags.in_plot_using)) |
2857
|
568 BIN_OP_RETURN (COLON, true); |
967
|
569 else |
2857
|
570 BIN_OP_RETURN (':', false); |
967
|
571 } |
1
|
572 |
968
|
573 %{ |
985
|
574 // Gobble comments. If closest nesting is inside parentheses, don't |
|
575 // return a new line. |
|
576 %} |
968
|
577 |
967
|
578 {CCHAR} { |
1826
|
579 if (help_buf.empty () |
|
580 && lexer_flags.beginning_of_function |
|
581 && nesting_level.none ()) |
967
|
582 { |
3665
|
583 lexer_flags.beginning_of_function = false; |
|
584 |
967
|
585 grab_help_text (); |
3665
|
586 |
|
587 octave_comment_buffer::append (help_buf); |
967
|
588 } |
|
589 else |
|
590 { |
3665
|
591 std::string buf; |
|
592 |
|
593 bool begin_comment = true; |
|
594 |
967
|
595 int c; |
|
596 while ((c = yyinput ()) != EOF && c != '\n') |
3665
|
597 { |
|
598 if (begin_comment && (c == '#' || c == '%')) |
|
599 ; /* Skip leading comment characters. */ |
|
600 else |
3802
|
601 buf += static_cast<char> (c); |
3665
|
602 } |
|
603 |
|
604 octave_comment_buffer::append (buf); |
967
|
605 } |
440
|
606 |
967
|
607 current_input_column = 1; |
2857
|
608 lexer_flags.quote_is_transpose = false; |
|
609 lexer_flags.cant_be_identifier = false; |
|
610 lexer_flags.convert_spaces_to_comma = true; |
985
|
611 |
1826
|
612 if (nesting_level.none ()) |
985
|
613 return '\n'; |
3351
|
614 else if (nesting_level.is_bracket ()) |
1566
|
615 return ';'; |
967
|
616 } |
440
|
617 |
968
|
618 %{ |
|
619 // Other operators. |
|
620 %} |
|
621 |
2857
|
622 ".+" { BIN_OP_RETURN (EPLUS, false); } |
|
623 ".-" { BIN_OP_RETURN (EMINUS, false); } |
|
624 ".*" { BIN_OP_RETURN (EMUL, false); } |
|
625 "./" { BIN_OP_RETURN (EDIV, false); } |
|
626 ".\\" { BIN_OP_RETURN (ELEFTDIV, false); } |
|
627 {EPOW} { BIN_OP_RETURN (EPOW, false); } |
|
628 ".'" { do_comma_insert_check (); BIN_OP_RETURN (TRANSPOSE, true); } |
|
629 "++" { do_comma_insert_check (); BIN_OP_RETURN (PLUS_PLUS, true); } |
|
630 "--" { do_comma_insert_check (); BIN_OP_RETURN (MINUS_MINUS, true); } |
|
631 "<=" { BIN_OP_RETURN (EXPR_LE, false); } |
|
632 "==" { BIN_OP_RETURN (EXPR_EQ, false); } |
|
633 {NOTEQ} { BIN_OP_RETURN (EXPR_NE, false); } |
|
634 ">=" { BIN_OP_RETURN (EXPR_GE, false); } |
2877
|
635 "&" { BIN_OP_RETURN (EXPR_AND, false); } |
2857
|
636 "|" { BIN_OP_RETURN (EXPR_OR, false); } |
|
637 "<" { BIN_OP_RETURN (EXPR_LT, false); } |
|
638 ">" { BIN_OP_RETURN (EXPR_GT, false); } |
|
639 "*" { BIN_OP_RETURN ('*', false); } |
|
640 "/" { BIN_OP_RETURN ('/', false); } |
|
641 "\\" { BIN_OP_RETURN (LEFTDIV, false); } |
|
642 ";" { BIN_OP_RETURN (';', true); } |
|
643 "," { BIN_OP_RETURN (',', true); } |
|
644 {POW} { BIN_OP_RETURN (POW, false); } |
|
645 "=" { BIN_OP_RETURN ('=', true); } |
2877
|
646 "&&" { BIN_OP_RETURN (EXPR_AND_AND, false); } |
2857
|
647 "||" { BIN_OP_RETURN (EXPR_OR_OR, false); } |
2900
|
648 "<<" { BIN_OP_RETURN (LSHIFT, false); } |
|
649 ">>" { BIN_OP_RETURN (RSHIFT, false); } |
967
|
650 |
|
651 {NOT} { |
1826
|
652 if (lexer_flags.plotting && ! lexer_flags.in_plot_range) |
2857
|
653 lexer_flags.past_plot_range = true; |
|
654 BIN_OP_RETURN (EXPR_NOT, false); |
967
|
655 } |
1
|
656 |
1276
|
657 "+" { |
1826
|
658 if (lexer_flags.plotting && ! lexer_flags.in_plot_range) |
2857
|
659 lexer_flags.past_plot_range = true; |
|
660 BIN_OP_RETURN ('+', false); |
967
|
661 } |
|
662 |
1276
|
663 "-" { |
1826
|
664 if (lexer_flags.plotting && ! lexer_flags.in_plot_range) |
2857
|
665 lexer_flags.past_plot_range = true; |
|
666 BIN_OP_RETURN ('-', false); |
967
|
667 } |
|
668 |
|
669 "(" { |
1826
|
670 if (lexer_flags.plotting && ! lexer_flags.in_plot_range) |
2857
|
671 lexer_flags.past_plot_range = true; |
1826
|
672 nesting_level.paren (); |
985
|
673 promptflag--; |
967
|
674 TOK_RETURN ('('); |
|
675 } |
|
676 |
|
677 ")" { |
1826
|
678 nesting_level.remove (); |
1001
|
679 |
967
|
680 current_input_column++; |
2857
|
681 lexer_flags.cant_be_identifier = true; |
|
682 lexer_flags.quote_is_transpose = true; |
3351
|
683 lexer_flags.convert_spaces_to_comma = nesting_level.is_bracket (); |
1001
|
684 do_comma_insert_check (); |
967
|
685 return ')'; |
|
686 } |
|
687 |
2066
|
688 "." { |
|
689 TOK_RETURN ('.'); |
|
690 } |
|
691 |
2877
|
692 "+=" { BIN_OP_RETURN (ADD_EQ, false); } |
|
693 "-=" { BIN_OP_RETURN (SUB_EQ, false); } |
|
694 "*=" { BIN_OP_RETURN (MUL_EQ, false); } |
|
695 "/=" { BIN_OP_RETURN (DIV_EQ, false); } |
3204
|
696 "\\=" { BIN_OP_RETURN (LEFTDIV_EQ, false); } |
2877
|
697 ".+=" { BIN_OP_RETURN (ADD_EQ, false); } |
|
698 ".-=" { BIN_OP_RETURN (SUB_EQ, false); } |
|
699 ".*=" { BIN_OP_RETURN (EMUL_EQ, false); } |
|
700 "./=" { BIN_OP_RETURN (EDIV_EQ, false); } |
3204
|
701 ".\\=" { BIN_OP_RETURN (ELEFTDIV_EQ, false); } |
2877
|
702 "&=" { BIN_OP_RETURN (AND_EQ, false); } |
|
703 "|=" { BIN_OP_RETURN (OR_EQ, false); } |
2900
|
704 "<<=" { BIN_OP_RETURN (LSHIFT_EQ, false); } |
|
705 ">>=" { BIN_OP_RETURN (RSHIFT_EQ, false); } |
2877
|
706 |
3351
|
707 "{" { |
|
708 nesting_level.brace (); |
|
709 promptflag--; |
|
710 TOK_RETURN ('{'); |
|
711 } |
|
712 |
|
713 "}" { |
|
714 nesting_level.remove (); |
|
715 |
|
716 current_input_column++; |
|
717 lexer_flags.cant_be_identifier = true; |
|
718 lexer_flags.quote_is_transpose = true; |
|
719 lexer_flags.convert_spaces_to_comma = nesting_level.is_bracket (); |
|
720 do_comma_insert_check (); // Is this really necessary? |
|
721 |
|
722 return '}'; |
|
723 } |
|
724 |
968
|
725 %{ |
2066
|
726 // Unrecognized input is a lexical error. |
968
|
727 %} |
1
|
728 |
2042
|
729 . { |
2066
|
730 current_input_column++; |
|
731 |
3867
|
732 // EOF can't happen here (we catch it above). |
|
733 |
|
734 error ("invalid character `%s' (ASCII %d) near line %d, column %d", |
|
735 undo_string_escape (yytext[0]), static_cast<int> (yytext[0]), |
|
736 input_line_number, current_input_column); |
2066
|
737 |
|
738 return LEXICAL_ERROR; |
|
739 } |
1
|
740 |
|
741 %% |
|
742 |
767
|
743 // GAG. |
|
744 // |
|
745 // If we're reading a matrix and the next character is '[', make sure |
|
746 // that we insert a comma ahead of it. |
|
747 |
146
|
748 void |
1
|
749 do_comma_insert_check (void) |
|
750 { |
1001
|
751 int spc_gobbled = eat_continuation (); |
2970
|
752 |
1
|
753 int c = yyinput (); |
2970
|
754 |
3246
|
755 unput (c); |
2970
|
756 |
1001
|
757 if (spc_gobbled) |
3246
|
758 unput (' '); |
2970
|
759 |
3351
|
760 lexer_flags.do_comma_insert = (lexer_flags.bracketflag && c == '['); |
1
|
761 } |
|
762 |
767
|
763 // Fix things up for errors or interrupts. The parser is never called |
|
764 // recursively, so it is always safe to reinitialize its state before |
|
765 // doing any parsing. |
|
766 |
1
|
767 void |
|
768 reset_parser (void) |
|
769 { |
1826
|
770 // Start off on the right foot. |
1
|
771 BEGIN 0; |
166
|
772 error_state = 0; |
3489
|
773 warning_state = 0; |
3883
|
774 parser_end_of_input = false; |
287
|
775 |
1826
|
776 // We do want a prompt by default. |
1
|
777 promptflag = 1; |
287
|
778 |
3351
|
779 // Error may have occurred inside some brackets, braces, or parentheses. |
985
|
780 nesting_level.clear (); |
287
|
781 |
1826
|
782 // Clear out the stack of token info used to track line and column |
|
783 // numbers. |
143
|
784 while (! token_stack.empty ()) |
|
785 delete token_stack.pop (); |
287
|
786 |
1826
|
787 // Can be reset by defining a function. |
985
|
788 if (! (reading_script_file || reading_fcn_file)) |
|
789 { |
|
790 current_input_column = 1; |
2926
|
791 input_line_number = command_editor::current_command_number () - 1; |
985
|
792 } |
287
|
793 |
1826
|
794 // Only ask for input from stdin if we are expecting interactive |
|
795 // input. |
3174
|
796 if ((interactive || forced_interactive) |
3880
|
797 && ! (reading_fcn_file |
|
798 || reading_script_file |
|
799 || get_input_from_eval_string |
3174
|
800 || input_from_startup_file)) |
287
|
801 yyrestart (stdin); |
991
|
802 |
1826
|
803 // Clear the buffer for help text. |
|
804 help_buf.resize (0); |
1755
|
805 |
1826
|
806 // Reset other flags. |
|
807 lexer_flags.init (); |
1
|
808 } |
|
809 |
767
|
810 // If we read some newlines, we need figure out what column we're |
|
811 // really looking at. |
|
812 |
1
|
813 static void |
|
814 fixup_column_count (char *s) |
|
815 { |
|
816 char c; |
|
817 while ((c = *s++) != '\0') |
|
818 { |
|
819 if (c == '\n') |
143
|
820 current_input_column = 1; |
1
|
821 else |
|
822 current_input_column++; |
|
823 } |
|
824 } |
|
825 |
767
|
826 // Include these so that we don't have to link to libfl.a. |
246
|
827 |
1
|
828 #ifdef yywrap |
|
829 #undef yywrap |
|
830 #endif |
3332
|
831 int |
1
|
832 yywrap (void) |
|
833 { |
287
|
834 return 1; |
1
|
835 } |
|
836 |
767
|
837 // Tell us all what the current buffer is. |
|
838 |
1
|
839 YY_BUFFER_STATE |
|
840 current_buffer (void) |
|
841 { |
|
842 return YY_CURRENT_BUFFER; |
|
843 } |
|
844 |
767
|
845 // Create a new buffer. |
|
846 |
1
|
847 YY_BUFFER_STATE |
|
848 create_buffer (FILE *f) |
|
849 { |
|
850 return yy_create_buffer (f, YY_BUF_SIZE); |
|
851 } |
|
852 |
767
|
853 // Start reading a new buffer. |
|
854 |
1
|
855 void |
|
856 switch_to_buffer (YY_BUFFER_STATE buf) |
|
857 { |
|
858 yy_switch_to_buffer (buf); |
|
859 } |
|
860 |
767
|
861 // Delete a buffer. |
|
862 |
1
|
863 void |
|
864 delete_buffer (YY_BUFFER_STATE buf) |
|
865 { |
|
866 yy_delete_buffer (buf); |
|
867 } |
|
868 |
767
|
869 // Restore a buffer (for unwind-prot). |
|
870 |
1
|
871 void |
|
872 restore_input_buffer (void *buf) |
|
873 { |
2861
|
874 switch_to_buffer (static_cast<YY_BUFFER_STATE> (buf)); |
1
|
875 } |
|
876 |
767
|
877 // Delete a buffer (for unwind-prot). |
|
878 |
1
|
879 void |
|
880 delete_input_buffer (void *buf) |
|
881 { |
2861
|
882 delete_buffer (static_cast<YY_BUFFER_STATE> (buf)); |
1
|
883 } |
|
884 |
767
|
885 // Check to see if a character string matches any of the possible line |
|
886 // styles for plots. |
|
887 |
3536
|
888 static std::string |
3523
|
889 plot_style_token (const std::string& s) |
1
|
890 { |
3523
|
891 std::string retval; |
1823
|
892 |
3575
|
893 // XXX FIXME XXX -- specify minimum match length for these. |
2804
|
894 static const char *plot_styles[] = |
146
|
895 { |
925
|
896 "boxes", |
924
|
897 "boxerrorbars", |
2542
|
898 "boxxyerrorbars", |
|
899 "candlesticks", |
146
|
900 "dots", |
|
901 "errorbars", |
2542
|
902 "financebars", |
|
903 "fsteps", |
|
904 "histeps", |
146
|
905 "impulses", |
|
906 "lines", |
|
907 "linespoints", |
|
908 "points", |
926
|
909 "steps", |
2542
|
910 "vector", |
|
911 "xerrorbars", |
|
912 "xyerrorbars", |
|
913 "yerrorbars", |
522
|
914 0, |
146
|
915 }; |
|
916 |
2804
|
917 const char * const *tmp = plot_styles; |
522
|
918 while (*tmp) |
1
|
919 { |
1823
|
920 if (almost_match (*tmp, s.c_str ())) |
|
921 { |
|
922 retval = *tmp; |
|
923 break; |
|
924 } |
1
|
925 |
|
926 tmp++; |
|
927 } |
|
928 |
1823
|
929 return retval; |
1
|
930 } |
|
931 |
3165
|
932 // Check to see if a character string matches any of the possible axes |
|
933 // tags for plots. |
|
934 |
3536
|
935 static std::string |
3523
|
936 plot_axes_token (const std::string& s) |
3165
|
937 { |
3523
|
938 std::string retval; |
3165
|
939 |
3575
|
940 // XXX FIXME XXX -- specify minimum match length for these. |
3561
|
941 static const char *plot_axes[] = |
3165
|
942 { |
|
943 "x1y1", |
|
944 "x1y2", |
|
945 "x2y1", |
|
946 "x2y2", |
|
947 0, |
|
948 }; |
|
949 |
3561
|
950 const char **tmp = plot_axes; |
3165
|
951 while (*tmp) |
|
952 { |
|
953 if (almost_match (*tmp, s.c_str ())) |
|
954 { |
|
955 retval = *tmp; |
|
956 break; |
|
957 } |
|
958 |
|
959 tmp++; |
|
960 } |
|
961 |
|
962 return retval; |
|
963 } |
|
964 |
767
|
965 // Check to see if a character string matches any one of the plot |
941
|
966 // option keywords. Don't match abbreviations for clear, since that's |
|
967 // not a gnuplot keyword (users will probably only expect to be able |
|
968 // to abbreviate actual gnuplot keywords). |
767
|
969 |
1
|
970 static int |
3523
|
971 is_plot_keyword (const std::string& s) |
1
|
972 { |
1823
|
973 const char *t = s.c_str (); |
3575
|
974 if (almost_match ("title", t, 1)) |
146
|
975 { |
|
976 return TITLE; |
|
977 } |
3575
|
978 else if (almost_match ("using", t, 1)) |
146
|
979 { |
2857
|
980 lexer_flags.in_plot_using = true; |
146
|
981 return USING; |
|
982 } |
3575
|
983 else if (almost_match ("with", t, 1)) |
146
|
984 { |
2857
|
985 lexer_flags.in_plot_style = true; |
146
|
986 return WITH; |
|
987 } |
3575
|
988 else if (almost_match ("axes", t, 2) || almost_match ("axis", t, 2)) |
3165
|
989 { |
|
990 lexer_flags.in_plot_axes = true; |
|
991 return AXES; |
|
992 } |
1823
|
993 else if (strcmp ("clear", t) == 0) |
883
|
994 { |
|
995 return CLEAR; |
|
996 } |
1
|
997 else |
146
|
998 { |
|
999 return 0; |
|
1000 } |
1
|
1001 } |
|
1002 |
2877
|
1003 // Handle keywords. |
767
|
1004 |
1
|
1005 static int |
3523
|
1006 is_keyword (const std::string& s) |
1
|
1007 { |
3805
|
1008 int l = input_line_number; |
|
1009 int c = current_input_column; |
|
1010 |
3165
|
1011 if (lexer_flags.plotting) |
1
|
1012 { |
3165
|
1013 if (lexer_flags.in_plot_style) |
1
|
1014 { |
3523
|
1015 std::string sty = plot_style_token (s); |
3165
|
1016 |
|
1017 if (! sty.empty ()) |
|
1018 { |
|
1019 lexer_flags.in_plot_style = false; |
3805
|
1020 yylval.tok_val = new token (sty, l, c); |
3165
|
1021 token_stack.push (yylval.tok_val); |
|
1022 return STYLE; |
|
1023 } |
1
|
1024 } |
3165
|
1025 else if (lexer_flags.in_plot_axes) |
|
1026 { |
3523
|
1027 std::string axes = plot_axes_token (s); |
3165
|
1028 |
|
1029 if (! axes.empty ()) |
|
1030 { |
|
1031 lexer_flags.in_plot_axes = false; |
3805
|
1032 yylval.tok_val = new token (axes, l, c); |
3165
|
1033 token_stack.push (yylval.tok_val); |
|
1034 return AXES_TAG; |
|
1035 } |
|
1036 } |
1
|
1037 } |
|
1038 |
1823
|
1039 int len = s.length (); |
922
|
1040 |
1823
|
1041 const octave_kw *kw = octave_kw_lookup (s.c_str (), len); |
191
|
1042 |
1497
|
1043 if (kw) |
143
|
1044 { |
1497
|
1045 yylval.tok_val = 0; |
|
1046 |
|
1047 switch (kw->kw_id) |
|
1048 { |
|
1049 case all_va_args_kw: |
|
1050 case break_kw: |
2764
|
1051 case case_kw: |
1497
|
1052 case catch_kw: |
|
1053 case continue_kw: |
|
1054 case else_kw: |
|
1055 case elseif_kw: |
|
1056 case global_kw: |
2764
|
1057 case otherwise_kw: |
1497
|
1058 case return_kw: |
2846
|
1059 case static_kw: |
3484
|
1060 case until_kw: |
1497
|
1061 case unwind_protect_cleanup_kw: |
|
1062 break; |
|
1063 |
|
1064 case end_kw: |
|
1065 yylval.tok_val = new token (token::simple_end, l, c); |
|
1066 break; |
|
1067 |
|
1068 case end_try_catch_kw: |
|
1069 yylval.tok_val = new token (token::try_catch_end, l, c); |
|
1070 break; |
|
1071 |
|
1072 case end_unwind_protect_kw: |
|
1073 yylval.tok_val = new token (token::unwind_protect_end, l, c); |
|
1074 break; |
|
1075 |
|
1076 case endfor_kw: |
|
1077 yylval.tok_val = new token (token::for_end, l, c); |
|
1078 break; |
|
1079 |
|
1080 case endfunction_kw: |
|
1081 yylval.tok_val = new token (token::function_end, l, c); |
|
1082 break; |
|
1083 |
|
1084 case endif_kw: |
|
1085 yylval.tok_val = new token (token::if_end, l, c); |
|
1086 break; |
|
1087 |
2764
|
1088 case endswitch_kw: |
|
1089 yylval.tok_val = new token (token::switch_end, l, c); |
|
1090 break; |
|
1091 |
1497
|
1092 case endwhile_kw: |
|
1093 yylval.tok_val = new token (token::while_end, l, c); |
|
1094 break; |
|
1095 |
3484
|
1096 case do_kw: |
1497
|
1097 case for_kw: |
|
1098 case while_kw: |
|
1099 promptflag--; |
1826
|
1100 lexer_flags.looping++; |
1497
|
1101 break; |
|
1102 |
|
1103 case if_kw: |
|
1104 case try_kw: |
2764
|
1105 case switch_kw: |
1497
|
1106 case unwind_protect_kw: |
|
1107 promptflag--; |
|
1108 break; |
|
1109 |
|
1110 case gplot_kw: |
2857
|
1111 lexer_flags.plotting = true; |
1497
|
1112 yylval.tok_val = new token (token::two_dee, l, c); |
|
1113 break; |
|
1114 |
|
1115 case gsplot_kw: |
2857
|
1116 lexer_flags.plotting = true; |
1497
|
1117 yylval.tok_val = new token (token::three_dee, l, c); |
|
1118 break; |
|
1119 |
|
1120 case replot_kw: |
2857
|
1121 lexer_flags.plotting = true; |
1497
|
1122 yylval.tok_val = new token (token::replot, l, c); |
|
1123 break; |
|
1124 |
|
1125 case function_kw: |
1826
|
1126 if (lexer_flags.defining_func) |
1497
|
1127 { |
|
1128 error ("function keyword invalid within a function body"); |
|
1129 |
|
1130 if ((reading_fcn_file || reading_script_file) |
1755
|
1131 && ! curr_fcn_file_name.empty ()) |
1497
|
1132 error ("defining new function near line %d of file `%s.m'", |
1755
|
1133 input_line_number, curr_fcn_file_name.c_str ()); |
1497
|
1134 else |
1755
|
1135 error ("defining new function near line %d", |
|
1136 input_line_number); |
1497
|
1137 |
|
1138 return LEXICAL_ERROR; |
|
1139 } |
|
1140 else |
|
1141 { |
2877
|
1142 // Prepare for local symbols. |
|
1143 |
1497
|
1144 tmp_local_sym_tab = new symbol_table (); |
2877
|
1145 |
|
1146 promptflag--; |
|
1147 |
2857
|
1148 lexer_flags.defining_func = true; |
2877
|
1149 lexer_flags.parsed_function_name = false; |
2857
|
1150 lexer_flags.beginning_of_function = true; |
2877
|
1151 |
1497
|
1152 if (! (reading_fcn_file || reading_script_file)) |
|
1153 input_line_number = 1; |
|
1154 } |
|
1155 break; |
|
1156 |
3174
|
1157 case magic_file_kw: |
|
1158 { |
|
1159 if ((reading_fcn_file || reading_script_file) |
|
1160 && ! curr_fcn_file_full_name.empty ()) |
|
1161 yylval.tok_val = new token (curr_fcn_file_full_name, l, c); |
|
1162 else |
|
1163 yylval.tok_val = new token ("stdin", l, c); |
|
1164 } |
|
1165 break; |
|
1166 |
|
1167 case magic_line_kw: |
|
1168 yylval.tok_val = new token (static_cast<double> (l), "", l, c); |
|
1169 break; |
|
1170 |
3974
|
1171 case varargin_kw: |
|
1172 if (! lexer_flags.looking_at_parameter_list) |
|
1173 return 0; |
|
1174 break; |
|
1175 |
|
1176 case varargout_kw: |
|
1177 if (! lexer_flags.looking_at_return_list) |
|
1178 return 0; |
|
1179 break; |
|
1180 |
1497
|
1181 default: |
|
1182 panic_impossible (); |
|
1183 } |
|
1184 |
|
1185 if (! yylval.tok_val) |
|
1186 yylval.tok_val = new token (l, c); |
|
1187 |
476
|
1188 token_stack.push (yylval.tok_val); |
1497
|
1189 |
|
1190 return kw->tok; |
143
|
1191 } |
1
|
1192 |
|
1193 return 0; |
|
1194 } |
|
1195 |
767
|
1196 // Try to find an identifier. All binding to global or builtin |
|
1197 // variables occurs when expressions are evaluated. |
|
1198 |
1
|
1199 static symbol_record * |
3523
|
1200 lookup_identifier (const std::string& name) |
1
|
1201 { |
2856
|
1202 return curr_sym_tab->lookup (name, true); |
1
|
1203 } |
|
1204 |
2702
|
1205 static bool |
3523
|
1206 is_variable (const std::string& name) |
2702
|
1207 { |
2856
|
1208 symbol_record *sr = curr_sym_tab->lookup (name); |
2702
|
1209 |
|
1210 return sr && sr->is_variable (); |
|
1211 } |
|
1212 |
|
1213 static void |
3523
|
1214 force_local_variable (const std::string& name) |
2702
|
1215 { |
2856
|
1216 symbol_record *sr = curr_sym_tab->lookup (name, true); |
2702
|
1217 |
|
1218 if (sr) |
|
1219 sr->define (octave_value ()); |
|
1220 } |
|
1221 |
1019
|
1222 // Grab the help text from an function file. Always overwrites the |
|
1223 // current contents of help_buf. |
767
|
1224 |
3427
|
1225 // XXX FIXME XXX -- gobble_leading_white_space() in parse.y |
2300
|
1226 // duplicates some of this code! |
|
1227 |
1
|
1228 static void |
|
1229 grab_help_text (void) |
|
1230 { |
1755
|
1231 help_buf.resize (0); |
1019
|
1232 |
2300
|
1233 bool begin_comment = true; |
|
1234 bool in_comment = true; |
3427
|
1235 bool discard_space = true; |
3665
|
1236 |
1019
|
1237 int c = 0; |
1
|
1238 |
1019
|
1239 while ((c = yyinput ()) != EOF) |
|
1240 { |
2300
|
1241 if (begin_comment) |
|
1242 { |
|
1243 if (c == '%' || c == '#') |
|
1244 continue; |
3427
|
1245 else if (discard_space && c == ' ') |
|
1246 { |
|
1247 discard_space = false; |
|
1248 continue; |
|
1249 } |
2300
|
1250 else |
|
1251 begin_comment = false; |
|
1252 } |
|
1253 |
1019
|
1254 if (in_comment) |
1
|
1255 { |
3802
|
1256 help_buf += static_cast<char> (c); |
1755
|
1257 |
1019
|
1258 if (c == '\n') |
3427
|
1259 { |
|
1260 in_comment = false; |
|
1261 discard_space = true; |
|
1262 } |
1019
|
1263 } |
|
1264 else |
|
1265 { |
|
1266 switch (c) |
991
|
1267 { |
1019
|
1268 case '%': |
|
1269 case '#': |
2300
|
1270 in_comment = true; |
|
1271 begin_comment = true; |
1019
|
1272 break; |
777
|
1273 |
1019
|
1274 case ' ': |
|
1275 case '\t': |
|
1276 break; |
777
|
1277 |
1019
|
1278 default: |
|
1279 goto done; |
1
|
1280 } |
|
1281 } |
1019
|
1282 } |
991
|
1283 |
1019
|
1284 done: |
991
|
1285 |
1019
|
1286 if (c) |
3246
|
1287 unput (c); |
1
|
1288 } |
|
1289 |
767
|
1290 // Return 1 if the given character matches any character in the given |
|
1291 // string. |
|
1292 |
2857
|
1293 static bool |
2804
|
1294 match_any (char c, const char *s) |
1
|
1295 { |
|
1296 char tmp; |
|
1297 while ((tmp = *s++) != '\0') |
|
1298 { |
|
1299 if (c == tmp) |
2857
|
1300 return true; |
1
|
1301 } |
2857
|
1302 return false; |
1
|
1303 } |
|
1304 |
767
|
1305 // Given information about the spacing surrounding an operator, |
|
1306 // return 1 if it looks like it should be treated as a binary |
|
1307 // operator. For example, |
|
1308 // |
3774
|
1309 // [ 1 + 2 ] or [ 1+ 2] or [ 1+2 ] ==> binary |
|
1310 // |
|
1311 // [ 1 +2 ] ==> unary |
767
|
1312 |
2857
|
1313 static bool |
3246
|
1314 looks_like_bin_op (bool spc_prev, int next_char) |
1
|
1315 { |
3246
|
1316 bool spc_next = (next_char == ' ' || next_char == '\t'); |
|
1317 |
608
|
1318 return ((spc_prev && spc_next) || ! spc_prev); |
1
|
1319 } |
|
1320 |
3263
|
1321 // Recognize separators. If the separator is a CRLF pair, it is |
|
1322 // replaced by a single LF. |
|
1323 |
|
1324 static bool |
|
1325 next_token_is_sep_op (void) |
|
1326 { |
|
1327 bool retval = false; |
|
1328 |
|
1329 int c1 = yyinput (); |
|
1330 |
|
1331 if (c1 == '\r') |
|
1332 { |
|
1333 int c2 = yyinput (); |
|
1334 |
|
1335 if (c2 == '\n') |
|
1336 { |
|
1337 c1 = '\n'; |
|
1338 |
|
1339 retval = true; |
|
1340 } |
|
1341 else |
|
1342 unput (c2); |
|
1343 } |
|
1344 else |
|
1345 retval = match_any (c1, ",;\n]"); |
|
1346 |
|
1347 unput (c1); |
|
1348 |
|
1349 return retval; |
|
1350 } |
|
1351 |
767
|
1352 // Try to determine if the next token should be treated as a postfix |
|
1353 // unary operator. This is ugly, but it seems to do the right thing. |
|
1354 |
2857
|
1355 static bool |
3246
|
1356 next_token_is_postfix_unary_op (bool spc_prev) |
1
|
1357 { |
2857
|
1358 bool un_op = false; |
1
|
1359 |
|
1360 int c0 = yyinput (); |
|
1361 |
3246
|
1362 if (c0 == '\'' && ! spc_prev) |
|
1363 { |
|
1364 un_op = true; |
|
1365 } |
|
1366 else if (c0 == '.') |
|
1367 { |
|
1368 int c1 = yyinput (); |
|
1369 un_op = (c1 == '\''); |
|
1370 unput (c1); |
|
1371 } |
1
|
1372 |
3246
|
1373 unput (c0); |
1
|
1374 |
|
1375 return un_op; |
|
1376 } |
|
1377 |
767
|
1378 // Try to determine if the next token should be treated as a binary |
3246
|
1379 // operator. |
1521
|
1380 // |
3246
|
1381 // This kluge exists because whitespace is not always ignored inside |
3774
|
1382 // the square brackets that are used to create matrix objects (though |
|
1383 // spacing only really matters in the cases that can be interpreted |
|
1384 // either as binary ops or prefix unary ops: currently just +, -). |
|
1385 // |
3779
|
1386 // Note that a line continuation directly following a + or - operator |
|
1387 // (e.g., the characters '[' 'a' ' ' '+' '\' LFD 'b' ']') will be |
|
1388 // parsed as a binary operator. |
767
|
1389 |
2857
|
1390 static bool |
3246
|
1391 next_token_is_bin_op (bool spc_prev) |
1
|
1392 { |
2857
|
1393 bool bin_op = false; |
1
|
1394 |
|
1395 int c0 = yyinput (); |
|
1396 |
|
1397 switch (c0) |
|
1398 { |
777
|
1399 case '+': |
|
1400 case '-': |
3774
|
1401 { |
|
1402 int c1 = yyinput (); |
|
1403 |
|
1404 switch (c1) |
|
1405 { |
|
1406 case '+': |
|
1407 case '-': |
|
1408 // Unary ops, spacing doesn't matter. |
|
1409 break; |
|
1410 |
|
1411 case '=': |
|
1412 // Binary ops, spacing doesn't matter. |
|
1413 bin_op = true; |
|
1414 break; |
|
1415 |
|
1416 default: |
|
1417 // Could be either, spacing matters. |
|
1418 bin_op = looks_like_bin_op (spc_prev, c1); |
|
1419 break; |
|
1420 } |
|
1421 |
|
1422 unput (c1); |
|
1423 } |
|
1424 break; |
|
1425 |
|
1426 case ':': |
3246
|
1427 case '/': |
|
1428 case '\\': |
|
1429 case '^': |
3774
|
1430 // Always a binary op (may also include /=, \=, and ^=). |
|
1431 bin_op = true; |
1276
|
1432 break; |
|
1433 |
3246
|
1434 // .+ .- ./ .\ .^ .* .** |
1554
|
1435 case '.': |
|
1436 { |
|
1437 int c1 = yyinput (); |
3246
|
1438 |
3774
|
1439 if (match_any (c1, "+-/\\^*")) |
|
1440 // Always a binary op (may also include .+=, .-=, ./=, ...). |
|
1441 bin_op = true; |
3698
|
1442 else if (! isdigit (c1) && c1 != ' ' && c1 != '\t' && c1 != '.') |
3774
|
1443 // A structure element reference is a binary op. |
|
1444 bin_op = true; |
3246
|
1445 |
|
1446 unput (c1); |
1554
|
1447 } |
|
1448 break; |
|
1449 |
3246
|
1450 // = == & && | || * ** |
|
1451 case '=': |
1
|
1452 case '&': |
3246
|
1453 case '|': |
1
|
1454 case '*': |
3774
|
1455 // Always a binary op (may also include ==, &&, ||, **). |
|
1456 bin_op = true; |
3246
|
1457 break; |
|
1458 |
3774
|
1459 // < <= <> > >= |
1
|
1460 case '<': |
|
1461 case '>': |
3774
|
1462 // Always a binary op (may also include <=, <>, >=). |
|
1463 bin_op = true; |
|
1464 break; |
|
1465 |
|
1466 // ~= != |
777
|
1467 case '~': |
|
1468 case '!': |
3246
|
1469 { |
|
1470 int c1 = yyinput (); |
|
1471 |
3774
|
1472 // ~ and ! can be unary ops, so require following =. |
|
1473 if (c1 == '=') |
|
1474 bin_op = true; |
3246
|
1475 |
|
1476 unput (c1); |
|
1477 } |
1
|
1478 break; |
|
1479 |
|
1480 default: |
1276
|
1481 break; |
1
|
1482 } |
|
1483 |
3246
|
1484 unput (c0); |
1
|
1485 |
|
1486 return bin_op; |
|
1487 } |
|
1488 |
767
|
1489 // Used to delete trailing white space from tokens. |
|
1490 |
3536
|
1491 static std::string |
1
|
1492 strip_trailing_whitespace (char *s) |
|
1493 { |
3523
|
1494 std::string retval = s; |
1
|
1495 |
1823
|
1496 size_t pos = retval.find_first_of (" \t"); |
1
|
1497 |
1823
|
1498 if (pos != NPOS) |
|
1499 retval.resize (pos); |
1
|
1500 |
|
1501 return retval; |
|
1502 } |
|
1503 |
3665
|
1504 static void |
|
1505 scan_for_comments (const char *text) |
|
1506 { |
|
1507 std::string comment_buf; |
|
1508 |
|
1509 bool in_comment = false; |
|
1510 bool beginning_of_comment = false; |
|
1511 |
|
1512 int len = strlen (text); |
|
1513 int i = 0; |
|
1514 |
|
1515 while (i < len) |
|
1516 { |
|
1517 char c = text[i++]; |
|
1518 |
|
1519 switch (c) |
|
1520 { |
|
1521 case '%': |
|
1522 case '#': |
|
1523 if (in_comment) |
|
1524 { |
|
1525 if (! beginning_of_comment) |
3802
|
1526 comment_buf += static_cast<char> (c); |
3665
|
1527 } |
|
1528 else |
|
1529 { |
|
1530 in_comment = true; |
|
1531 beginning_of_comment = true; |
|
1532 } |
|
1533 break; |
|
1534 |
|
1535 case '\n': |
|
1536 if (in_comment) |
|
1537 { |
3802
|
1538 comment_buf += static_cast<char> (c); |
3665
|
1539 octave_comment_buffer::append (comment_buf); |
|
1540 comment_buf.resize (0); |
|
1541 in_comment = false; |
|
1542 beginning_of_comment = false; |
|
1543 } |
|
1544 break; |
|
1545 |
|
1546 case '\r': |
|
1547 if (in_comment) |
3802
|
1548 comment_buf += static_cast<char> (c); |
3665
|
1549 if (i < len) |
|
1550 { |
|
1551 c = text[i++]; |
|
1552 |
|
1553 if (c == '\n') |
|
1554 { |
|
1555 if (in_comment) |
|
1556 { |
3802
|
1557 comment_buf += static_cast<char> (c); |
3665
|
1558 octave_comment_buffer::append (comment_buf); |
|
1559 in_comment = false; |
|
1560 beginning_of_comment = false; |
|
1561 } |
|
1562 } |
|
1563 } |
|
1564 |
|
1565 default: |
|
1566 if (in_comment) |
|
1567 { |
3802
|
1568 comment_buf += static_cast<char> (c); |
3665
|
1569 beginning_of_comment = false; |
|
1570 } |
|
1571 break; |
|
1572 } |
|
1573 } |
|
1574 |
|
1575 if (! comment_buf.empty ()) |
|
1576 octave_comment_buffer::append (comment_buf); |
|
1577 } |
|
1578 |
1001
|
1579 // Discard whitespace, including comments and continuations. |
1088
|
1580 // |
|
1581 // Return value is logical OR of the following values: |
|
1582 // |
1826
|
1583 // ATE_NOTHING : no spaces to eat |
1088
|
1584 // ATE_SPACE_OR_TAB : space or tab in input |
|
1585 // ATE_NEWLINE : bare new line in input |
1001
|
1586 |
1826
|
1587 static yum_yum |
975
|
1588 eat_whitespace (void) |
|
1589 { |
1826
|
1590 yum_yum retval = ATE_NOTHING; |
3665
|
1591 |
|
1592 std::string comment_buf; |
|
1593 |
2857
|
1594 bool in_comment = false; |
3665
|
1595 bool beginning_of_comment = false; |
|
1596 |
|
1597 int c = 0; |
|
1598 |
975
|
1599 while ((c = yyinput ()) != EOF) |
|
1600 { |
|
1601 current_input_column++; |
|
1602 |
|
1603 switch (c) |
|
1604 { |
|
1605 case ' ': |
|
1606 case '\t': |
3665
|
1607 if (in_comment) |
|
1608 { |
3802
|
1609 comment_buf += static_cast<char> (c); |
3665
|
1610 beginning_of_comment = false; |
|
1611 } |
1088
|
1612 retval |= ATE_SPACE_OR_TAB; |
975
|
1613 break; |
|
1614 |
|
1615 case '\n': |
1088
|
1616 retval |= ATE_NEWLINE; |
3665
|
1617 if (in_comment) |
|
1618 { |
3802
|
1619 comment_buf += static_cast<char> (c); |
3665
|
1620 octave_comment_buffer::append (comment_buf); |
|
1621 comment_buf.resize (0); |
|
1622 in_comment = false; |
|
1623 beginning_of_comment = false; |
|
1624 } |
975
|
1625 current_input_column = 0; |
|
1626 break; |
|
1627 |
|
1628 case '#': |
|
1629 case '%': |
3665
|
1630 if (in_comment) |
|
1631 { |
|
1632 if (! beginning_of_comment) |
3802
|
1633 comment_buf += static_cast<char> (c); |
3665
|
1634 } |
|
1635 else |
|
1636 { |
|
1637 in_comment = true; |
|
1638 beginning_of_comment = true; |
|
1639 } |
975
|
1640 break; |
|
1641 |
1001
|
1642 case '.': |
|
1643 if (in_comment) |
3665
|
1644 { |
3802
|
1645 comment_buf += static_cast<char> (c); |
3665
|
1646 beginning_of_comment = false; |
|
1647 break; |
|
1648 } |
1001
|
1649 else |
|
1650 { |
|
1651 if (have_ellipsis_continuation ()) |
|
1652 break; |
|
1653 else |
|
1654 goto done; |
|
1655 } |
|
1656 |
|
1657 case '\\': |
|
1658 if (in_comment) |
3665
|
1659 { |
3802
|
1660 comment_buf += static_cast<char> (c); |
3665
|
1661 beginning_of_comment = false; |
|
1662 break; |
|
1663 } |
1001
|
1664 else |
|
1665 { |
3105
|
1666 if (have_continuation ()) |
1001
|
1667 break; |
|
1668 else |
|
1669 goto done; |
|
1670 } |
|
1671 |
975
|
1672 default: |
|
1673 if (in_comment) |
3665
|
1674 { |
3802
|
1675 comment_buf += static_cast<char> (c); |
3665
|
1676 beginning_of_comment = false; |
|
1677 break; |
|
1678 } |
975
|
1679 else |
|
1680 goto done; |
|
1681 } |
|
1682 } |
|
1683 |
3665
|
1684 if (! comment_buf.empty ()) |
|
1685 octave_comment_buffer::append (comment_buf); |
|
1686 |
975
|
1687 done: |
3246
|
1688 unput (c); |
1082
|
1689 current_input_column--; |
1001
|
1690 return retval; |
975
|
1691 } |
|
1692 |
3220
|
1693 static inline bool |
|
1694 looks_like_hex (const char *s, int len) |
|
1695 { |
|
1696 return (len > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')); |
|
1697 } |
|
1698 |
975
|
1699 static void |
3246
|
1700 handle_number (void) |
972
|
1701 { |
3220
|
1702 double value = 0.0; |
|
1703 int nread = 0; |
|
1704 |
3598
|
1705 if (looks_like_hex (yytext, strlen (yytext))) |
3220
|
1706 { |
|
1707 unsigned long ival; |
3598
|
1708 |
|
1709 nread = sscanf (yytext, "%lx", &ival); |
|
1710 |
3220
|
1711 value = static_cast<double> (ival); |
|
1712 } |
|
1713 else |
3598
|
1714 { |
|
1715 char *tmp = strsave (yytext); |
|
1716 |
|
1717 char *idx = strpbrk (tmp, "Dd"); |
2621
|
1718 |
3598
|
1719 if (idx) |
|
1720 *idx = 'e'; |
|
1721 |
|
1722 nread = sscanf (tmp, "%lf", &value); |
|
1723 |
|
1724 delete [] tmp; |
|
1725 } |
972
|
1726 |
1826
|
1727 // If yytext doesn't contain a valid number, we are in deep doo doo. |
985
|
1728 |
972
|
1729 assert (nread == 1); |
|
1730 |
1826
|
1731 lexer_flags.quote_is_transpose = 1; |
|
1732 lexer_flags.cant_be_identifier = 1; |
|
1733 lexer_flags.convert_spaces_to_comma = 1; |
972
|
1734 |
1826
|
1735 if (lexer_flags.plotting && ! lexer_flags.in_plot_range) |
3575
|
1736 lexer_flags.past_plot_range = true; |
972
|
1737 |
|
1738 yylval.tok_val = new token (value, yytext, input_line_number, |
|
1739 current_input_column); |
|
1740 |
|
1741 token_stack.push (yylval.tok_val); |
|
1742 |
|
1743 current_input_column += yyleng; |
|
1744 |
|
1745 do_comma_insert_check (); |
|
1746 } |
|
1747 |
1001
|
1748 // We have seen a backslash and need to find out if it should be |
|
1749 // treated as a continuation character. If so, this eats it, up to |
|
1750 // and including the new line character. |
|
1751 // |
973
|
1752 // Match whitespace only, followed by a comment character or newline. |
|
1753 // Once a comment character is found, discard all input until newline. |
|
1754 // If non-whitespace characters are found before comment |
|
1755 // characters, return 0. Otherwise, return 1. |
|
1756 |
2857
|
1757 static bool |
3096
|
1758 have_continuation (bool trailing_comments_ok) |
973
|
1759 { |
3523
|
1760 std::ostrstream buf; |
973
|
1761 |
3665
|
1762 std::string comment_buf; |
|
1763 |
2857
|
1764 bool in_comment = false; |
3665
|
1765 bool beginning_of_comment = false; |
|
1766 |
|
1767 int c = 0; |
|
1768 |
973
|
1769 while ((c = yyinput ()) != EOF) |
|
1770 { |
3802
|
1771 buf << static_cast<char> (c); |
973
|
1772 |
|
1773 switch (c) |
|
1774 { |
|
1775 case ' ': |
|
1776 case '\t': |
3665
|
1777 if (in_comment) |
|
1778 { |
3802
|
1779 comment_buf += static_cast<char> (c); |
3665
|
1780 beginning_of_comment = false; |
|
1781 } |
973
|
1782 break; |
|
1783 |
|
1784 case '%': |
|
1785 case '#': |
1091
|
1786 if (trailing_comments_ok) |
3665
|
1787 { |
|
1788 if (in_comment) |
|
1789 { |
|
1790 if (! beginning_of_comment) |
3802
|
1791 comment_buf += static_cast<char> (c); |
3665
|
1792 } |
|
1793 else |
|
1794 { |
|
1795 in_comment = true; |
|
1796 beginning_of_comment = true; |
|
1797 } |
|
1798 } |
1091
|
1799 else |
|
1800 goto cleanup; |
973
|
1801 break; |
|
1802 |
|
1803 case '\n': |
3665
|
1804 if (in_comment) |
|
1805 { |
3802
|
1806 comment_buf += static_cast<char> (c); |
3665
|
1807 octave_comment_buffer::append (comment_buf); |
|
1808 } |
975
|
1809 current_input_column = 0; |
1001
|
1810 promptflag--; |
2857
|
1811 return true; |
973
|
1812 |
3263
|
1813 case '\r': |
3665
|
1814 if (in_comment) |
3802
|
1815 comment_buf += static_cast<char> (c); |
3263
|
1816 c = yyinput (); |
|
1817 if (c == EOF) |
|
1818 break; |
|
1819 else if (c == '\n') |
|
1820 { |
3665
|
1821 if (in_comment) |
|
1822 { |
3802
|
1823 comment_buf += static_cast<char> (c); |
3665
|
1824 octave_comment_buffer::append (comment_buf); |
|
1825 } |
3263
|
1826 current_input_column = 0; |
|
1827 promptflag--; |
|
1828 return true; |
3665
|
1829 } |
3263
|
1830 |
3802
|
1831 // Fall through... |
|
1832 |
973
|
1833 default: |
3665
|
1834 if (in_comment) |
|
1835 { |
3802
|
1836 comment_buf += static_cast<char> (c); |
3665
|
1837 beginning_of_comment = false; |
|
1838 } |
|
1839 else |
1091
|
1840 goto cleanup; |
|
1841 break; |
973
|
1842 } |
|
1843 } |
|
1844 |
3246
|
1845 unput (c); |
2857
|
1846 return false; |
973
|
1847 |
3096
|
1848 cleanup: |
3538
|
1849 buf << std::ends; |
1091
|
1850 char *s = buf.str (); |
|
1851 if (s) |
|
1852 { |
|
1853 int len = strlen (s); |
|
1854 while (len--) |
3246
|
1855 unput (s[len]); |
1091
|
1856 } |
|
1857 delete [] s; |
3096
|
1858 |
2857
|
1859 return false; |
973
|
1860 } |
|
1861 |
1001
|
1862 // We have seen a `.' and need to see if it is the start of a |
|
1863 // continuation. If so, this eats it, up to and including the new |
|
1864 // line character. |
|
1865 |
2857
|
1866 static bool |
3096
|
1867 have_ellipsis_continuation (bool trailing_comments_ok) |
973
|
1868 { |
|
1869 char c1 = yyinput (); |
|
1870 if (c1 == '.') |
|
1871 { |
|
1872 char c2 = yyinput (); |
1091
|
1873 if (c2 == '.' && have_continuation (trailing_comments_ok)) |
2857
|
1874 return true; |
973
|
1875 else |
|
1876 { |
3246
|
1877 unput (c2); |
|
1878 unput (c1); |
973
|
1879 } |
|
1880 } |
|
1881 else |
3246
|
1882 unput (c1); |
973
|
1883 |
2857
|
1884 return false; |
973
|
1885 } |
|
1886 |
1001
|
1887 // See if we have a continuation line. If so, eat it and the leading |
|
1888 // whitespace on the next line. |
1088
|
1889 // |
|
1890 // Return value is the same as described for eat_whitespace(). |
1001
|
1891 |
1826
|
1892 static yum_yum |
1001
|
1893 eat_continuation (void) |
|
1894 { |
1826
|
1895 int retval = ATE_NOTHING; |
3665
|
1896 |
1001
|
1897 int c = yyinput (); |
3665
|
1898 |
1001
|
1899 if ((c == '.' && have_ellipsis_continuation ()) |
3105
|
1900 || (c == '\\' && have_continuation ())) |
1001
|
1901 retval = eat_whitespace (); |
|
1902 else |
3246
|
1903 unput (c); |
1001
|
1904 |
|
1905 return retval; |
|
1906 } |
|
1907 |
973
|
1908 static int |
975
|
1909 handle_string (char delim, int text_style) |
973
|
1910 { |
3523
|
1911 std::ostrstream buf; |
973
|
1912 |
3805
|
1913 int bos_line = input_line_number; |
|
1914 int bos_col = current_input_column; |
|
1915 |
973
|
1916 int c; |
1031
|
1917 int escape_pending = 0; |
973
|
1918 |
|
1919 while ((c = yyinput ()) != EOF) |
|
1920 { |
|
1921 current_input_column++; |
|
1922 |
3105
|
1923 if (c == '\\') |
973
|
1924 { |
1053
|
1925 if (escape_pending) |
|
1926 { |
3802
|
1927 buf << static_cast<char> (c); |
1053
|
1928 escape_pending = 0; |
|
1929 } |
|
1930 else |
|
1931 { |
3096
|
1932 if (have_continuation (false)) |
1053
|
1933 escape_pending = 0; |
|
1934 else |
|
1935 { |
3802
|
1936 buf << static_cast<char> (c); |
1053
|
1937 escape_pending = 1; |
|
1938 } |
|
1939 } |
1031
|
1940 continue; |
973
|
1941 } |
|
1942 else if (c == '.') |
|
1943 { |
3096
|
1944 if (! have_ellipsis_continuation (false)) |
3802
|
1945 buf << static_cast<char> (c); |
973
|
1946 } |
|
1947 else if (c == '\n') |
|
1948 { |
1053
|
1949 error ("unterminated string constant"); |
973
|
1950 break; |
|
1951 } |
|
1952 else if (c == delim) |
|
1953 { |
1031
|
1954 if (escape_pending) |
3802
|
1955 buf << static_cast<char> (c); |
973
|
1956 else |
|
1957 { |
|
1958 c = yyinput (); |
|
1959 if (c == delim) |
3802
|
1960 buf << static_cast<char> (c); |
973
|
1961 else |
|
1962 { |
3246
|
1963 unput (c); |
3538
|
1964 buf << std::ends; |
3105
|
1965 char *t = buf.str (); |
3523
|
1966 std::string s = do_string_escapes (t); |
3105
|
1967 delete [] t; |
975
|
1968 |
1826
|
1969 if (text_style && lexer_flags.doing_set) |
975
|
1970 { |
3523
|
1971 s = std::string (1, delim) + s + std::string (1, delim); |
975
|
1972 } |
|
1973 else |
|
1974 { |
2857
|
1975 lexer_flags.quote_is_transpose = true; |
|
1976 lexer_flags.cant_be_identifier = true; |
|
1977 lexer_flags.convert_spaces_to_comma = true; |
975
|
1978 } |
|
1979 |
3805
|
1980 yylval.tok_val = new token (s, bos_line, bos_col); |
973
|
1981 token_stack.push (yylval.tok_val); |
3400
|
1982 |
|
1983 if (delim == '\'') |
|
1984 gripe_single_quote_string (); |
|
1985 |
973
|
1986 return TEXT; |
|
1987 } |
|
1988 } |
|
1989 } |
|
1990 else |
|
1991 { |
3802
|
1992 buf << static_cast<char> (c); |
973
|
1993 } |
|
1994 |
1031
|
1995 escape_pending = 0; |
973
|
1996 } |
|
1997 |
|
1998 return LEXICAL_ERROR; |
|
1999 } |
|
2000 |
3208
|
2001 static bool |
|
2002 next_token_is_assign_op (void) |
|
2003 { |
|
2004 bool retval = false; |
|
2005 |
|
2006 int c0 = yyinput (); |
|
2007 |
|
2008 switch (c0) |
|
2009 { |
|
2010 case '=': |
|
2011 { |
|
2012 int c1 = yyinput (); |
|
2013 unput (c1); |
|
2014 if (c1 != '=') |
|
2015 retval = true; |
|
2016 } |
|
2017 break; |
|
2018 |
|
2019 case '+': |
|
2020 case '-': |
|
2021 case '*': |
|
2022 case '/': |
|
2023 case '\\': |
|
2024 case '&': |
|
2025 case '|': |
|
2026 { |
|
2027 int c1 = yyinput (); |
|
2028 unput (c1); |
|
2029 if (c1 == '=') |
|
2030 retval = true; |
|
2031 } |
|
2032 break; |
|
2033 |
|
2034 case '.': |
|
2035 { |
|
2036 int c1 = yyinput (); |
|
2037 if (match_any (c1, "+-*/\\")) |
|
2038 { |
|
2039 int c2 = yyinput (); |
|
2040 unput (c2); |
|
2041 if (c2 == '=') |
|
2042 retval = true; |
|
2043 } |
|
2044 unput (c1); |
|
2045 } |
|
2046 break; |
|
2047 |
|
2048 case '>': |
|
2049 { |
|
2050 int c1 = yyinput (); |
|
2051 if (c1 == '>') |
|
2052 { |
|
2053 int c2 = yyinput (); |
|
2054 unput (c2); |
|
2055 if (c2 == '=') |
|
2056 retval = true; |
|
2057 } |
|
2058 unput (c1); |
|
2059 } |
|
2060 break; |
|
2061 |
|
2062 case '<': |
|
2063 { |
|
2064 int c1 = yyinput (); |
|
2065 if (c1 == '<') |
|
2066 { |
|
2067 int c2 = yyinput (); |
|
2068 unput (c2); |
|
2069 if (c2 == '=') |
|
2070 retval = true; |
|
2071 } |
|
2072 unput (c1); |
|
2073 } |
|
2074 break; |
|
2075 |
|
2076 default: |
|
2077 break; |
|
2078 } |
|
2079 |
|
2080 unput (c0); |
|
2081 |
|
2082 return retval; |
|
2083 } |
|
2084 |
971
|
2085 static int |
3351
|
2086 handle_close_bracket (int spc_gobbled) |
971
|
2087 { |
3208
|
2088 int retval = ']'; |
|
2089 |
1826
|
2090 if (! nesting_level.none ()) |
971
|
2091 { |
1826
|
2092 nesting_level.remove (); |
3351
|
2093 lexer_flags.bracketflag--; |
971
|
2094 } |
|
2095 |
3351
|
2096 if (lexer_flags.bracketflag == 0) |
1001
|
2097 BEGIN 0; |
|
2098 |
3208
|
2099 if (next_token_is_assign_op () && ! lexer_flags.looking_at_return_list) |
971
|
2100 { |
3208
|
2101 retval = CLOSE_BRACE; |
971
|
2102 } |
|
2103 else |
|
2104 { |
3208
|
2105 int c1 = yyinput (); |
971
|
2106 unput (c1); |
|
2107 |
3388
|
2108 if (lexer_flags.bracketflag) |
971
|
2109 { |
3246
|
2110 int bin_op = next_token_is_bin_op (spc_gobbled); |
3263
|
2111 |
3246
|
2112 int postfix_un_op = next_token_is_postfix_unary_op (spc_gobbled); |
971
|
2113 |
3263
|
2114 int sep_op = next_token_is_sep_op (); |
971
|
2115 |
3263
|
2116 if (! (postfix_un_op || bin_op || sep_op) |
3351
|
2117 && nesting_level.is_bracket () |
1826
|
2118 && lexer_flags.convert_spaces_to_comma) |
971
|
2119 { |
3388
|
2120 maybe_warn_separator_insert (','); |
|
2121 |
|
2122 if (Vwhitespace_in_literal_matrix != 2) |
|
2123 { |
|
2124 unput (','); |
|
2125 return ']'; |
|
2126 } |
971
|
2127 } |
|
2128 } |
|
2129 } |
|
2130 |
2857
|
2131 lexer_flags.quote_is_transpose = true; |
|
2132 lexer_flags.cant_be_identifier = false; |
|
2133 lexer_flags.convert_spaces_to_comma = true; |
3208
|
2134 |
|
2135 return retval; |
971
|
2136 } |
|
2137 |
1072
|
2138 static void |
|
2139 maybe_unput_comma (int spc_gobbled) |
|
2140 { |
3388
|
2141 if (nesting_level.is_bracket ()) |
1072
|
2142 { |
3246
|
2143 int bin_op = next_token_is_bin_op (spc_gobbled); |
1072
|
2144 |
3246
|
2145 int postfix_un_op = next_token_is_postfix_unary_op (spc_gobbled); |
1072
|
2146 |
|
2147 int c1 = yyinput (); |
|
2148 int c2 = yyinput (); |
2970
|
2149 |
1072
|
2150 unput (c2); |
|
2151 unput (c1); |
2970
|
2152 |
3263
|
2153 int sep_op = next_token_is_sep_op (); |
2970
|
2154 |
1072
|
2155 int dot_op = (c1 == '.' |
|
2156 && (isalpha (c2) || isspace (c2) || c2 == '_')); |
2970
|
2157 |
3388
|
2158 if (postfix_un_op || bin_op || sep_op || dot_op) |
|
2159 return; |
|
2160 |
3985
|
2161 int index_op = (c1 == '(' || c1 == '{'); |
3388
|
2162 |
|
2163 if (index_op) |
|
2164 { |
3985
|
2165 // If there is no space before the indexing op, we don't |
|
2166 // insert a comma. |
3388
|
2167 if (! spc_gobbled) |
|
2168 return; |
|
2169 |
|
2170 maybe_warn_separator_insert (','); |
1072
|
2171 |
3388
|
2172 // If there is a space, we only insert a comma if we are |
|
2173 // trying to be Matlab-like. |
|
2174 if (Vwhitespace_in_literal_matrix == 1) |
|
2175 unput (','); |
|
2176 } |
|
2177 else |
|
2178 { |
|
2179 maybe_warn_separator_insert (','); |
|
2180 |
|
2181 if (Vwhitespace_in_literal_matrix != 2) |
|
2182 unput (','); |
|
2183 } |
1072
|
2184 } |
|
2185 } |
|
2186 |
767
|
2187 // Figure out exactly what kind of token to return when we have seen |
|
2188 // an identifier. Handles keywords. |
|
2189 |
146
|
2190 static int |
3974
|
2191 handle_identifier (void) |
146
|
2192 { |
3974
|
2193 std::string tok = strip_trailing_whitespace (yytext); |
|
2194 |
|
2195 int c = yytext[yyleng-1]; |
|
2196 |
|
2197 int cont_is_spc = eat_continuation (); |
|
2198 |
|
2199 int spc_gobbled = (cont_is_spc || c == ' ' || c == '\t'); |
|
2200 |
1826
|
2201 // It is almost always an error for an identifier to be followed |
|
2202 // directly by another identifier. Special cases are handled |
|
2203 // below. |
883
|
2204 |
2857
|
2205 lexer_flags.cant_be_identifier = true; |
883
|
2206 |
2970
|
2207 // If we are expecting a structure element, avoid recognizing |
|
2208 // keywords and other special names and return STRUCT_ELT, which is |
|
2209 // a string that is also a valid identifier. But first, we have to |
|
2210 // decide whether to insert a comma. |
747
|
2211 |
1826
|
2212 if (lexer_flags.looking_at_indirect_ref) |
1072
|
2213 { |
2970
|
2214 do_comma_insert_check (); |
|
2215 |
1072
|
2216 maybe_unput_comma (spc_gobbled); |
2819
|
2217 |
|
2218 yylval.tok_val = new token (tok, input_line_number, |
|
2219 current_input_column); |
|
2220 |
|
2221 token_stack.push (yylval.tok_val); |
|
2222 |
2857
|
2223 lexer_flags.cant_be_identifier = false; |
|
2224 lexer_flags.quote_is_transpose = true; |
|
2225 lexer_flags.convert_spaces_to_comma = true; |
2819
|
2226 |
|
2227 current_input_column += yyleng; |
|
2228 |
2970
|
2229 return STRUCT_ELT; |
1072
|
2230 } |
747
|
2231 |
1826
|
2232 // If we have a regular keyword, or a plot STYLE, return it. |
|
2233 // Keywords can be followed by identifiers (TOK_RETURN handles |
|
2234 // that). |
146
|
2235 |
|
2236 int kw_token = is_keyword (tok); |
2970
|
2237 |
146
|
2238 if (kw_token) |
|
2239 { |
|
2240 if (kw_token == STYLE) |
|
2241 { |
1060
|
2242 current_input_column += yyleng; |
2857
|
2243 lexer_flags.quote_is_transpose = false; |
|
2244 lexer_flags.convert_spaces_to_comma = true; |
146
|
2245 return kw_token; |
|
2246 } |
|
2247 else |
|
2248 TOK_RETURN (kw_token); |
|
2249 } |
|
2250 |
1826
|
2251 // See if we have a plot keyword (title, using, with, or clear). |
146
|
2252 |
1826
|
2253 if (lexer_flags.plotting) |
941
|
2254 { |
1826
|
2255 // Yes, we really do need both of these plot_range variables. |
|
2256 // One is used to mark when we are past all possiblity of a plot |
|
2257 // range, the other is used to mark when we are actually between |
|
2258 // the square brackets that surround the range. |
146
|
2259 |
1826
|
2260 if (! lexer_flags.in_plot_range) |
2857
|
2261 lexer_flags.past_plot_range = true; |
941
|
2262 |
3351
|
2263 // Option keywords can't appear in brackets, braces, or parentheses. |
1273
|
2264 |
|
2265 int plot_option_kw = 0; |
2970
|
2266 |
1826
|
2267 if (nesting_level.none ()) |
1273
|
2268 plot_option_kw = is_plot_keyword (tok); |
3575
|
2269 |
1826
|
2270 if (lexer_flags.cant_be_identifier && plot_option_kw) |
941
|
2271 TOK_RETURN (plot_option_kw); |
|
2272 } |
146
|
2273 |
3480
|
2274 int c1 = yyinput (); |
|
2275 |
|
2276 bool next_tok_is_dot = (c1 == '.'); |
|
2277 bool next_tok_is_paren = (c1 == '('); |
|
2278 |
|
2279 bool next_tok_is_eq = false; |
|
2280 if (c1 == '=') |
|
2281 { |
|
2282 int c2 = yyinput (); |
|
2283 unput (c2); |
|
2284 |
|
2285 if (c2 != '=') |
|
2286 next_tok_is_eq = true; |
|
2287 } |
|
2288 |
|
2289 unput (c1); |
1001
|
2290 |
1826
|
2291 // Make sure we put the return values of a function in the symbol |
|
2292 // table that is local to the function. |
146
|
2293 |
2877
|
2294 // If we are defining a function and we have not seen the function |
|
2295 // name yet and the next token is `=', then this identifier must be |
|
2296 // the only return value for the function and it belongs in the |
|
2297 // local symbol table. |
|
2298 |
1826
|
2299 if (next_tok_is_eq |
2877
|
2300 && lexer_flags.defining_func |
|
2301 && ! lexer_flags.parsed_function_name) |
146
|
2302 curr_sym_tab = tmp_local_sym_tab; |
|
2303 |
2702
|
2304 // Kluge alert. |
|
2305 // |
|
2306 // If we are looking at a text style function, set up to gobble its |
2745
|
2307 // arguments. |
|
2308 // |
|
2309 // If the following token is `=', or if we are parsing a function |
3189
|
2310 // return list or function parameter list, or if we are looking at |
|
2311 // something like [ab,cd] = foo (), force the symbol to be inserted |
|
2312 // as a variable in the current symbol table. |
2702
|
2313 |
|
2314 if (is_text_function_name (tok) && ! is_variable (tok)) |
|
2315 { |
2745
|
2316 if (next_tok_is_eq |
|
2317 || lexer_flags.looking_at_return_list |
3189
|
2318 || lexer_flags.looking_at_parameter_list |
3246
|
2319 || lexer_flags.looking_at_matrix_or_assign_lhs |
|
2320 || (next_tok_is_dot && next_token_is_bin_op (spc_gobbled))) |
2745
|
2321 { |
|
2322 force_local_variable (tok); |
|
2323 } |
2702
|
2324 else if (! next_tok_is_paren) |
|
2325 { |
|
2326 if (tok == "gset") |
2857
|
2327 lexer_flags.doing_set = true; |
2702
|
2328 |
|
2329 BEGIN TEXT_FCN; |
|
2330 } |
|
2331 } |
|
2332 |
1826
|
2333 // Find the token in the symbol table. |
146
|
2334 |
|
2335 yylval.tok_val = new token (lookup_identifier (tok), |
|
2336 input_line_number, |
|
2337 current_input_column); |
|
2338 |
|
2339 token_stack.push (yylval.tok_val); |
|
2340 |
1826
|
2341 // After seeing an identifer, it is ok to convert spaces to a comma |
|
2342 // (if needed). |
146
|
2343 |
2857
|
2344 lexer_flags.convert_spaces_to_comma = true; |
146
|
2345 |
2877
|
2346 if (! next_tok_is_eq) |
|
2347 { |
|
2348 lexer_flags.quote_is_transpose = true; |
146
|
2349 |
2877
|
2350 do_comma_insert_check (); |
|
2351 |
|
2352 maybe_unput_comma (spc_gobbled); |
146
|
2353 } |
|
2354 |
2877
|
2355 current_input_column += yyleng; |
146
|
2356 |
|
2357 return NAME; |
|
2358 } |
|
2359 |
767
|
2360 // Print a warning if a function file that defines a function has |
|
2361 // anything other than comments and whitespace following the END token |
|
2362 // that matches the FUNCTION statement. |
|
2363 |
1
|
2364 void |
|
2365 check_for_garbage_after_fcn_def (void) |
|
2366 { |
1826
|
2367 // By making a newline be the next character to be read, we will |
|
2368 // force the parser to return after reading the function. Calling |
3246
|
2369 // unput with EOF does not work. |
1
|
2370 |
3665
|
2371 std::string comment_buf; |
|
2372 |
2857
|
2373 bool in_comment = false; |
3665
|
2374 bool beginning_of_comment = true; |
|
2375 |
1
|
2376 int lineno = input_line_number; |
3665
|
2377 |
|
2378 int c = 0; |
|
2379 |
1
|
2380 while ((c = yyinput ()) != EOF) |
|
2381 { |
|
2382 switch (c) |
|
2383 { |
|
2384 case ' ': |
|
2385 case '\t': |
|
2386 case ';': |
|
2387 case ',': |
3665
|
2388 if (in_comment) |
|
2389 { |
3802
|
2390 comment_buf += static_cast<char> (c); |
3665
|
2391 beginning_of_comment = false; |
|
2392 } |
1
|
2393 break; |
777
|
2394 |
1
|
2395 case '%': |
|
2396 case '#': |
3665
|
2397 if (in_comment) |
|
2398 { |
|
2399 if (! beginning_of_comment) |
3802
|
2400 comment_buf += static_cast<char> (c); |
3665
|
2401 } |
|
2402 else |
|
2403 { |
|
2404 in_comment = true; |
|
2405 beginning_of_comment = true; |
|
2406 } |
1
|
2407 break; |
777
|
2408 |
3802
|
2409 case '\n': |
|
2410 if (in_comment) |
|
2411 { |
|
2412 comment_buf += static_cast<char> (c); |
|
2413 octave_comment_buffer::append (comment_buf); |
|
2414 comment_buf.resize (0); |
|
2415 in_comment = false; |
|
2416 beginning_of_comment = false; |
|
2417 } |
|
2418 break; |
|
2419 |
|
2420 case '\r': |
|
2421 if (in_comment) |
|
2422 comment_buf += static_cast<char> (c); |
|
2423 c = yyinput (); |
|
2424 if (c == EOF) |
|
2425 break; |
|
2426 else if (c == '\n') |
|
2427 { |
|
2428 if (in_comment) |
|
2429 { |
|
2430 comment_buf += static_cast<char> (c); |
|
2431 octave_comment_buffer::append (comment_buf); |
|
2432 comment_buf.resize (0); |
|
2433 in_comment = false; |
|
2434 beginning_of_comment = false; |
|
2435 } |
|
2436 break; |
|
2437 } |
|
2438 |
|
2439 // Fall through... |
|
2440 |
1
|
2441 default: |
|
2442 if (in_comment) |
3665
|
2443 { |
3802
|
2444 comment_buf += static_cast<char> (c); |
3665
|
2445 beginning_of_comment = false; |
|
2446 break; |
|
2447 } |
1
|
2448 else |
|
2449 { |
|
2450 warning ("ignoring trailing garbage after end of function\n\ |
1755
|
2451 near line %d of file `%s.m'", lineno, curr_fcn_file_name.c_str ()); |
1
|
2452 |
3246
|
2453 unput ('\n'); |
1
|
2454 return; |
|
2455 } |
|
2456 } |
|
2457 } |
3665
|
2458 |
|
2459 if (! comment_buf.empty ()) |
|
2460 octave_comment_buffer::append (comment_buf); |
|
2461 |
3246
|
2462 unput ('\n'); |
1
|
2463 } |
|
2464 |
1826
|
2465 void |
|
2466 lexical_feedback::init (void) |
|
2467 { |
|
2468 // Not initially defining a matrix list. |
3351
|
2469 bracketflag = 0; |
1826
|
2470 |
|
2471 // Not initially inside a loop or if statement. |
|
2472 looping = 0; |
|
2473 |
2857
|
2474 // Not initially defining a function. |
|
2475 beginning_of_function = false; |
|
2476 defining_func = false; |
2877
|
2477 parsed_function_name = false; |
2857
|
2478 |
|
2479 // Not parsing a function return or parameter list. |
|
2480 looking_at_return_list = false; |
|
2481 looking_at_parameter_list = false; |
|
2482 |
3796
|
2483 // Not parsing a matrix or the left hand side of multi-value |
|
2484 // assignment statement. |
|
2485 looking_at_matrix_or_assign_lhs = false; |
|
2486 |
2857
|
2487 // Next token can be identifier. |
|
2488 cant_be_identifier = false; |
|
2489 |
|
2490 // No need to do comma insert or convert spaces to comma at |
|
2491 // beginning of input. |
|
2492 convert_spaces_to_comma = true; |
|
2493 do_comma_insert = false; |
|
2494 |
|
2495 // Not initially doing any plotting or setting of plot attributes. |
|
2496 doing_set = false; |
|
2497 in_plot_range = false; |
|
2498 in_plot_style = false; |
3165
|
2499 in_plot_axes = false; |
2857
|
2500 in_plot_using = false; |
|
2501 past_plot_range = false; |
|
2502 plotting = false; |
|
2503 |
1826
|
2504 // Not initially looking at indirect references. |
2857
|
2505 looking_at_indirect_ref = false; |
1826
|
2506 |
|
2507 // Quote marks strings intially. |
2857
|
2508 quote_is_transpose = false; |
1826
|
2509 } |
|
2510 |
3388
|
2511 static void |
|
2512 maybe_warn_separator_insert (char sep) |
|
2513 { |
3523
|
2514 std::string nm = curr_fcn_file_full_name; |
3388
|
2515 |
|
2516 if (Vwarn_separator_insert) |
|
2517 { |
|
2518 if (nm.empty ()) |
|
2519 warning ("potential auto-insertion of `%c' near line %d", |
|
2520 sep, input_line_number); |
|
2521 else |
|
2522 warning ("potential auto-insertion of `%c' near line %d of file %s", |
|
2523 sep, input_line_number, nm.c_str ()); |
|
2524 } |
|
2525 } |
|
2526 |
3400
|
2527 static void |
|
2528 gripe_single_quote_string (void) |
|
2529 { |
3523
|
2530 std::string nm = curr_fcn_file_full_name; |
3400
|
2531 |
|
2532 if (Vwarn_single_quote_string) |
|
2533 { |
|
2534 if (nm.empty ()) |
|
2535 warning ("single quote delimited string near line %d", |
|
2536 input_line_number); |
|
2537 else |
|
2538 warning ("single quote delimited string near line %d of file %s", |
|
2539 input_line_number, nm.c_str ()); |
|
2540 } |
|
2541 } |
|
2542 |
3388
|
2543 static int |
|
2544 warn_separator_insert (void) |
|
2545 { |
|
2546 Vwarn_separator_insert = check_preference ("warn_separator_insert"); |
|
2547 |
|
2548 return 0; |
|
2549 } |
|
2550 |
3246
|
2551 static int |
3400
|
2552 warn_single_quote_string (void) |
|
2553 { |
|
2554 Vwarn_single_quote_string = check_preference ("warn_single_quote_string"); |
|
2555 |
|
2556 return 0; |
|
2557 } |
|
2558 |
|
2559 static int |
2167
|
2560 whitespace_in_literal_matrix (void) |
|
2561 { |
|
2562 int pref = 0; |
3009
|
2563 |
3523
|
2564 std::string val = builtin_string_variable ("whitespace_in_literal_matrix"); |
3009
|
2565 |
2167
|
2566 if (! val.empty ()) |
|
2567 { |
3565
|
2568 if (val == "ignore") |
2167
|
2569 pref = 2; |
3565
|
2570 else if (val == "traditional") |
2167
|
2571 pref = 1; |
|
2572 } |
3009
|
2573 |
2167
|
2574 Vwhitespace_in_literal_matrix = pref; |
3009
|
2575 |
2167
|
2576 return 0; |
|
2577 } |
|
2578 |
|
2579 void |
|
2580 symbols_of_lex (void) |
|
2581 { |
3388
|
2582 DEFVAR (warn_separator_insert, 0.0, warn_separator_insert, |
3428
|
2583 "-*- texinfo -*-\n\ |
|
2584 @defvr {Built-in Variable} warn_separator_insert\n\ |
3567
|
2585 Print warning if commas or semicolons might be inserted\n\ |
3428
|
2586 automatically in literal matrices.\n\ |
|
2587 @end defvr"); |
3388
|
2588 |
3400
|
2589 DEFVAR (warn_single_quote_string, 0.0, warn_single_quote_string, |
3428
|
2590 "-*- texinfo -*-\n\ |
|
2591 @defvr {Built-in Variable} warn_single_quote_string\n\ |
|
2592 Print warning if a signle quote character is used to introduce a\n\ |
|
2593 string constant.\n\ |
|
2594 @end defvr"); |
3400
|
2595 |
3258
|
2596 DEFVAR (whitespace_in_literal_matrix, "", whitespace_in_literal_matrix, |
3428
|
2597 "-*- texinfo -*-\n\ |
|
2598 @defvr {Built-in Variable} whitespace_in_literal_matrix\n\ |
|
2599 Control auto-insertion of commas and semicolons in literal matrices.\n\ |
|
2600 @end defvr"); |
|
2601 |
2167
|
2602 } |
|
2603 |
1994
|
2604 /* |
|
2605 ;;; Local Variables: *** |
|
2606 ;;; mode: C++ *** |
|
2607 ;;; End: *** |
|
2608 */ |