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 |
3988
|
692 "@" { |
|
693 current_input_column++; |
|
694 lexer_flags.cant_be_identifier = false; |
|
695 lexer_flags.quote_is_transpose = false; |
|
696 lexer_flags.convert_spaces_to_comma = false; |
|
697 return '@'; |
|
698 } |
|
699 |
2877
|
700 "+=" { BIN_OP_RETURN (ADD_EQ, false); } |
|
701 "-=" { BIN_OP_RETURN (SUB_EQ, false); } |
|
702 "*=" { BIN_OP_RETURN (MUL_EQ, false); } |
|
703 "/=" { BIN_OP_RETURN (DIV_EQ, false); } |
3204
|
704 "\\=" { BIN_OP_RETURN (LEFTDIV_EQ, false); } |
2877
|
705 ".+=" { BIN_OP_RETURN (ADD_EQ, false); } |
|
706 ".-=" { BIN_OP_RETURN (SUB_EQ, false); } |
|
707 ".*=" { BIN_OP_RETURN (EMUL_EQ, false); } |
|
708 "./=" { BIN_OP_RETURN (EDIV_EQ, false); } |
3204
|
709 ".\\=" { BIN_OP_RETURN (ELEFTDIV_EQ, false); } |
2877
|
710 "&=" { BIN_OP_RETURN (AND_EQ, false); } |
|
711 "|=" { BIN_OP_RETURN (OR_EQ, false); } |
2900
|
712 "<<=" { BIN_OP_RETURN (LSHIFT_EQ, false); } |
|
713 ">>=" { BIN_OP_RETURN (RSHIFT_EQ, false); } |
2877
|
714 |
3351
|
715 "{" { |
|
716 nesting_level.brace (); |
|
717 promptflag--; |
|
718 TOK_RETURN ('{'); |
|
719 } |
|
720 |
|
721 "}" { |
|
722 nesting_level.remove (); |
|
723 |
|
724 current_input_column++; |
|
725 lexer_flags.cant_be_identifier = true; |
|
726 lexer_flags.quote_is_transpose = true; |
|
727 lexer_flags.convert_spaces_to_comma = nesting_level.is_bracket (); |
|
728 do_comma_insert_check (); // Is this really necessary? |
|
729 |
|
730 return '}'; |
|
731 } |
|
732 |
968
|
733 %{ |
2066
|
734 // Unrecognized input is a lexical error. |
968
|
735 %} |
1
|
736 |
2042
|
737 . { |
2066
|
738 current_input_column++; |
|
739 |
3867
|
740 // EOF can't happen here (we catch it above). |
|
741 |
|
742 error ("invalid character `%s' (ASCII %d) near line %d, column %d", |
|
743 undo_string_escape (yytext[0]), static_cast<int> (yytext[0]), |
|
744 input_line_number, current_input_column); |
2066
|
745 |
|
746 return LEXICAL_ERROR; |
|
747 } |
1
|
748 |
|
749 %% |
|
750 |
767
|
751 // GAG. |
|
752 // |
|
753 // If we're reading a matrix and the next character is '[', make sure |
|
754 // that we insert a comma ahead of it. |
|
755 |
146
|
756 void |
1
|
757 do_comma_insert_check (void) |
|
758 { |
1001
|
759 int spc_gobbled = eat_continuation (); |
2970
|
760 |
1
|
761 int c = yyinput (); |
2970
|
762 |
3246
|
763 unput (c); |
2970
|
764 |
1001
|
765 if (spc_gobbled) |
3246
|
766 unput (' '); |
2970
|
767 |
3351
|
768 lexer_flags.do_comma_insert = (lexer_flags.bracketflag && c == '['); |
1
|
769 } |
|
770 |
767
|
771 // Fix things up for errors or interrupts. The parser is never called |
|
772 // recursively, so it is always safe to reinitialize its state before |
|
773 // doing any parsing. |
|
774 |
1
|
775 void |
|
776 reset_parser (void) |
|
777 { |
1826
|
778 // Start off on the right foot. |
1
|
779 BEGIN 0; |
166
|
780 error_state = 0; |
3489
|
781 warning_state = 0; |
3883
|
782 parser_end_of_input = false; |
287
|
783 |
1826
|
784 // We do want a prompt by default. |
1
|
785 promptflag = 1; |
287
|
786 |
3351
|
787 // Error may have occurred inside some brackets, braces, or parentheses. |
985
|
788 nesting_level.clear (); |
287
|
789 |
1826
|
790 // Clear out the stack of token info used to track line and column |
|
791 // numbers. |
143
|
792 while (! token_stack.empty ()) |
|
793 delete token_stack.pop (); |
287
|
794 |
1826
|
795 // Can be reset by defining a function. |
985
|
796 if (! (reading_script_file || reading_fcn_file)) |
|
797 { |
|
798 current_input_column = 1; |
2926
|
799 input_line_number = command_editor::current_command_number () - 1; |
985
|
800 } |
287
|
801 |
1826
|
802 // Only ask for input from stdin if we are expecting interactive |
|
803 // input. |
3174
|
804 if ((interactive || forced_interactive) |
3880
|
805 && ! (reading_fcn_file |
|
806 || reading_script_file |
|
807 || get_input_from_eval_string |
3174
|
808 || input_from_startup_file)) |
287
|
809 yyrestart (stdin); |
991
|
810 |
1826
|
811 // Clear the buffer for help text. |
|
812 help_buf.resize (0); |
1755
|
813 |
1826
|
814 // Reset other flags. |
|
815 lexer_flags.init (); |
1
|
816 } |
|
817 |
767
|
818 // If we read some newlines, we need figure out what column we're |
|
819 // really looking at. |
|
820 |
1
|
821 static void |
|
822 fixup_column_count (char *s) |
|
823 { |
|
824 char c; |
|
825 while ((c = *s++) != '\0') |
|
826 { |
|
827 if (c == '\n') |
143
|
828 current_input_column = 1; |
1
|
829 else |
|
830 current_input_column++; |
|
831 } |
|
832 } |
|
833 |
767
|
834 // Include these so that we don't have to link to libfl.a. |
246
|
835 |
1
|
836 #ifdef yywrap |
|
837 #undef yywrap |
|
838 #endif |
3332
|
839 int |
1
|
840 yywrap (void) |
|
841 { |
287
|
842 return 1; |
1
|
843 } |
|
844 |
767
|
845 // Tell us all what the current buffer is. |
|
846 |
1
|
847 YY_BUFFER_STATE |
|
848 current_buffer (void) |
|
849 { |
|
850 return YY_CURRENT_BUFFER; |
|
851 } |
|
852 |
767
|
853 // Create a new buffer. |
|
854 |
1
|
855 YY_BUFFER_STATE |
|
856 create_buffer (FILE *f) |
|
857 { |
|
858 return yy_create_buffer (f, YY_BUF_SIZE); |
|
859 } |
|
860 |
767
|
861 // Start reading a new buffer. |
|
862 |
1
|
863 void |
|
864 switch_to_buffer (YY_BUFFER_STATE buf) |
|
865 { |
|
866 yy_switch_to_buffer (buf); |
|
867 } |
|
868 |
767
|
869 // Delete a buffer. |
|
870 |
1
|
871 void |
|
872 delete_buffer (YY_BUFFER_STATE buf) |
|
873 { |
|
874 yy_delete_buffer (buf); |
|
875 } |
|
876 |
767
|
877 // Restore a buffer (for unwind-prot). |
|
878 |
1
|
879 void |
|
880 restore_input_buffer (void *buf) |
|
881 { |
2861
|
882 switch_to_buffer (static_cast<YY_BUFFER_STATE> (buf)); |
1
|
883 } |
|
884 |
767
|
885 // Delete a buffer (for unwind-prot). |
|
886 |
1
|
887 void |
|
888 delete_input_buffer (void *buf) |
|
889 { |
2861
|
890 delete_buffer (static_cast<YY_BUFFER_STATE> (buf)); |
1
|
891 } |
|
892 |
767
|
893 // Check to see if a character string matches any of the possible line |
|
894 // styles for plots. |
|
895 |
3536
|
896 static std::string |
3523
|
897 plot_style_token (const std::string& s) |
1
|
898 { |
3523
|
899 std::string retval; |
1823
|
900 |
3575
|
901 // XXX FIXME XXX -- specify minimum match length for these. |
2804
|
902 static const char *plot_styles[] = |
146
|
903 { |
925
|
904 "boxes", |
924
|
905 "boxerrorbars", |
2542
|
906 "boxxyerrorbars", |
|
907 "candlesticks", |
146
|
908 "dots", |
|
909 "errorbars", |
2542
|
910 "financebars", |
|
911 "fsteps", |
|
912 "histeps", |
146
|
913 "impulses", |
|
914 "lines", |
|
915 "linespoints", |
|
916 "points", |
926
|
917 "steps", |
2542
|
918 "vector", |
|
919 "xerrorbars", |
|
920 "xyerrorbars", |
|
921 "yerrorbars", |
522
|
922 0, |
146
|
923 }; |
|
924 |
2804
|
925 const char * const *tmp = plot_styles; |
522
|
926 while (*tmp) |
1
|
927 { |
1823
|
928 if (almost_match (*tmp, s.c_str ())) |
|
929 { |
|
930 retval = *tmp; |
|
931 break; |
|
932 } |
1
|
933 |
|
934 tmp++; |
|
935 } |
|
936 |
1823
|
937 return retval; |
1
|
938 } |
|
939 |
3165
|
940 // Check to see if a character string matches any of the possible axes |
|
941 // tags for plots. |
|
942 |
3536
|
943 static std::string |
3523
|
944 plot_axes_token (const std::string& s) |
3165
|
945 { |
3523
|
946 std::string retval; |
3165
|
947 |
3575
|
948 // XXX FIXME XXX -- specify minimum match length for these. |
3561
|
949 static const char *plot_axes[] = |
3165
|
950 { |
|
951 "x1y1", |
|
952 "x1y2", |
|
953 "x2y1", |
|
954 "x2y2", |
|
955 0, |
|
956 }; |
|
957 |
3561
|
958 const char **tmp = plot_axes; |
3165
|
959 while (*tmp) |
|
960 { |
|
961 if (almost_match (*tmp, s.c_str ())) |
|
962 { |
|
963 retval = *tmp; |
|
964 break; |
|
965 } |
|
966 |
|
967 tmp++; |
|
968 } |
|
969 |
|
970 return retval; |
|
971 } |
|
972 |
767
|
973 // Check to see if a character string matches any one of the plot |
941
|
974 // option keywords. Don't match abbreviations for clear, since that's |
|
975 // not a gnuplot keyword (users will probably only expect to be able |
|
976 // to abbreviate actual gnuplot keywords). |
767
|
977 |
1
|
978 static int |
3523
|
979 is_plot_keyword (const std::string& s) |
1
|
980 { |
1823
|
981 const char *t = s.c_str (); |
3575
|
982 if (almost_match ("title", t, 1)) |
146
|
983 { |
|
984 return TITLE; |
|
985 } |
3575
|
986 else if (almost_match ("using", t, 1)) |
146
|
987 { |
2857
|
988 lexer_flags.in_plot_using = true; |
146
|
989 return USING; |
|
990 } |
3575
|
991 else if (almost_match ("with", t, 1)) |
146
|
992 { |
2857
|
993 lexer_flags.in_plot_style = true; |
146
|
994 return WITH; |
|
995 } |
3575
|
996 else if (almost_match ("axes", t, 2) || almost_match ("axis", t, 2)) |
3165
|
997 { |
|
998 lexer_flags.in_plot_axes = true; |
|
999 return AXES; |
|
1000 } |
1823
|
1001 else if (strcmp ("clear", t) == 0) |
883
|
1002 { |
|
1003 return CLEAR; |
|
1004 } |
1
|
1005 else |
146
|
1006 { |
|
1007 return 0; |
|
1008 } |
1
|
1009 } |
|
1010 |
2877
|
1011 // Handle keywords. |
767
|
1012 |
1
|
1013 static int |
3523
|
1014 is_keyword (const std::string& s) |
1
|
1015 { |
3805
|
1016 int l = input_line_number; |
|
1017 int c = current_input_column; |
|
1018 |
3165
|
1019 if (lexer_flags.plotting) |
1
|
1020 { |
3165
|
1021 if (lexer_flags.in_plot_style) |
1
|
1022 { |
3523
|
1023 std::string sty = plot_style_token (s); |
3165
|
1024 |
|
1025 if (! sty.empty ()) |
|
1026 { |
|
1027 lexer_flags.in_plot_style = false; |
3805
|
1028 yylval.tok_val = new token (sty, l, c); |
3165
|
1029 token_stack.push (yylval.tok_val); |
|
1030 return STYLE; |
|
1031 } |
1
|
1032 } |
3165
|
1033 else if (lexer_flags.in_plot_axes) |
|
1034 { |
3523
|
1035 std::string axes = plot_axes_token (s); |
3165
|
1036 |
|
1037 if (! axes.empty ()) |
|
1038 { |
|
1039 lexer_flags.in_plot_axes = false; |
3805
|
1040 yylval.tok_val = new token (axes, l, c); |
3165
|
1041 token_stack.push (yylval.tok_val); |
|
1042 return AXES_TAG; |
|
1043 } |
|
1044 } |
1
|
1045 } |
|
1046 |
1823
|
1047 int len = s.length (); |
922
|
1048 |
1823
|
1049 const octave_kw *kw = octave_kw_lookup (s.c_str (), len); |
191
|
1050 |
1497
|
1051 if (kw) |
143
|
1052 { |
1497
|
1053 yylval.tok_val = 0; |
|
1054 |
|
1055 switch (kw->kw_id) |
|
1056 { |
|
1057 case all_va_args_kw: |
|
1058 case break_kw: |
2764
|
1059 case case_kw: |
1497
|
1060 case catch_kw: |
|
1061 case continue_kw: |
|
1062 case else_kw: |
|
1063 case elseif_kw: |
|
1064 case global_kw: |
2764
|
1065 case otherwise_kw: |
1497
|
1066 case return_kw: |
2846
|
1067 case static_kw: |
3484
|
1068 case until_kw: |
1497
|
1069 case unwind_protect_cleanup_kw: |
|
1070 break; |
|
1071 |
|
1072 case end_kw: |
|
1073 yylval.tok_val = new token (token::simple_end, l, c); |
|
1074 break; |
|
1075 |
|
1076 case end_try_catch_kw: |
|
1077 yylval.tok_val = new token (token::try_catch_end, l, c); |
|
1078 break; |
|
1079 |
|
1080 case end_unwind_protect_kw: |
|
1081 yylval.tok_val = new token (token::unwind_protect_end, l, c); |
|
1082 break; |
|
1083 |
|
1084 case endfor_kw: |
|
1085 yylval.tok_val = new token (token::for_end, l, c); |
|
1086 break; |
|
1087 |
|
1088 case endfunction_kw: |
|
1089 yylval.tok_val = new token (token::function_end, l, c); |
|
1090 break; |
|
1091 |
|
1092 case endif_kw: |
|
1093 yylval.tok_val = new token (token::if_end, l, c); |
|
1094 break; |
|
1095 |
2764
|
1096 case endswitch_kw: |
|
1097 yylval.tok_val = new token (token::switch_end, l, c); |
|
1098 break; |
|
1099 |
1497
|
1100 case endwhile_kw: |
|
1101 yylval.tok_val = new token (token::while_end, l, c); |
|
1102 break; |
|
1103 |
3484
|
1104 case do_kw: |
1497
|
1105 case for_kw: |
|
1106 case while_kw: |
|
1107 promptflag--; |
1826
|
1108 lexer_flags.looping++; |
1497
|
1109 break; |
|
1110 |
|
1111 case if_kw: |
|
1112 case try_kw: |
2764
|
1113 case switch_kw: |
1497
|
1114 case unwind_protect_kw: |
|
1115 promptflag--; |
|
1116 break; |
|
1117 |
|
1118 case gplot_kw: |
2857
|
1119 lexer_flags.plotting = true; |
1497
|
1120 yylval.tok_val = new token (token::two_dee, l, c); |
|
1121 break; |
|
1122 |
|
1123 case gsplot_kw: |
2857
|
1124 lexer_flags.plotting = true; |
1497
|
1125 yylval.tok_val = new token (token::three_dee, l, c); |
|
1126 break; |
|
1127 |
|
1128 case replot_kw: |
2857
|
1129 lexer_flags.plotting = true; |
1497
|
1130 yylval.tok_val = new token (token::replot, l, c); |
|
1131 break; |
|
1132 |
|
1133 case function_kw: |
1826
|
1134 if (lexer_flags.defining_func) |
1497
|
1135 { |
|
1136 error ("function keyword invalid within a function body"); |
|
1137 |
|
1138 if ((reading_fcn_file || reading_script_file) |
1755
|
1139 && ! curr_fcn_file_name.empty ()) |
1497
|
1140 error ("defining new function near line %d of file `%s.m'", |
1755
|
1141 input_line_number, curr_fcn_file_name.c_str ()); |
1497
|
1142 else |
1755
|
1143 error ("defining new function near line %d", |
|
1144 input_line_number); |
1497
|
1145 |
|
1146 return LEXICAL_ERROR; |
|
1147 } |
|
1148 else |
|
1149 { |
2877
|
1150 // Prepare for local symbols. |
|
1151 |
1497
|
1152 tmp_local_sym_tab = new symbol_table (); |
2877
|
1153 |
|
1154 promptflag--; |
|
1155 |
2857
|
1156 lexer_flags.defining_func = true; |
2877
|
1157 lexer_flags.parsed_function_name = false; |
2857
|
1158 lexer_flags.beginning_of_function = true; |
2877
|
1159 |
1497
|
1160 if (! (reading_fcn_file || reading_script_file)) |
|
1161 input_line_number = 1; |
|
1162 } |
|
1163 break; |
|
1164 |
3174
|
1165 case magic_file_kw: |
|
1166 { |
|
1167 if ((reading_fcn_file || reading_script_file) |
|
1168 && ! curr_fcn_file_full_name.empty ()) |
|
1169 yylval.tok_val = new token (curr_fcn_file_full_name, l, c); |
|
1170 else |
|
1171 yylval.tok_val = new token ("stdin", l, c); |
|
1172 } |
|
1173 break; |
|
1174 |
|
1175 case magic_line_kw: |
|
1176 yylval.tok_val = new token (static_cast<double> (l), "", l, c); |
|
1177 break; |
|
1178 |
3974
|
1179 case varargin_kw: |
|
1180 if (! lexer_flags.looking_at_parameter_list) |
|
1181 return 0; |
|
1182 break; |
|
1183 |
|
1184 case varargout_kw: |
|
1185 if (! lexer_flags.looking_at_return_list) |
|
1186 return 0; |
|
1187 break; |
|
1188 |
1497
|
1189 default: |
|
1190 panic_impossible (); |
|
1191 } |
|
1192 |
|
1193 if (! yylval.tok_val) |
|
1194 yylval.tok_val = new token (l, c); |
|
1195 |
476
|
1196 token_stack.push (yylval.tok_val); |
1497
|
1197 |
|
1198 return kw->tok; |
143
|
1199 } |
1
|
1200 |
|
1201 return 0; |
|
1202 } |
|
1203 |
767
|
1204 // Try to find an identifier. All binding to global or builtin |
|
1205 // variables occurs when expressions are evaluated. |
|
1206 |
1
|
1207 static symbol_record * |
3523
|
1208 lookup_identifier (const std::string& name) |
1
|
1209 { |
2856
|
1210 return curr_sym_tab->lookup (name, true); |
1
|
1211 } |
|
1212 |
2702
|
1213 static bool |
3523
|
1214 is_variable (const std::string& name) |
2702
|
1215 { |
2856
|
1216 symbol_record *sr = curr_sym_tab->lookup (name); |
2702
|
1217 |
|
1218 return sr && sr->is_variable (); |
|
1219 } |
|
1220 |
|
1221 static void |
3523
|
1222 force_local_variable (const std::string& name) |
2702
|
1223 { |
2856
|
1224 symbol_record *sr = curr_sym_tab->lookup (name, true); |
2702
|
1225 |
|
1226 if (sr) |
|
1227 sr->define (octave_value ()); |
|
1228 } |
|
1229 |
1019
|
1230 // Grab the help text from an function file. Always overwrites the |
|
1231 // current contents of help_buf. |
767
|
1232 |
3427
|
1233 // XXX FIXME XXX -- gobble_leading_white_space() in parse.y |
2300
|
1234 // duplicates some of this code! |
|
1235 |
1
|
1236 static void |
|
1237 grab_help_text (void) |
|
1238 { |
1755
|
1239 help_buf.resize (0); |
1019
|
1240 |
2300
|
1241 bool begin_comment = true; |
|
1242 bool in_comment = true; |
3427
|
1243 bool discard_space = true; |
3665
|
1244 |
1019
|
1245 int c = 0; |
1
|
1246 |
1019
|
1247 while ((c = yyinput ()) != EOF) |
|
1248 { |
2300
|
1249 if (begin_comment) |
|
1250 { |
|
1251 if (c == '%' || c == '#') |
|
1252 continue; |
3427
|
1253 else if (discard_space && c == ' ') |
|
1254 { |
|
1255 discard_space = false; |
|
1256 continue; |
|
1257 } |
2300
|
1258 else |
|
1259 begin_comment = false; |
|
1260 } |
|
1261 |
1019
|
1262 if (in_comment) |
1
|
1263 { |
3802
|
1264 help_buf += static_cast<char> (c); |
1755
|
1265 |
1019
|
1266 if (c == '\n') |
3427
|
1267 { |
|
1268 in_comment = false; |
|
1269 discard_space = true; |
|
1270 } |
1019
|
1271 } |
|
1272 else |
|
1273 { |
|
1274 switch (c) |
991
|
1275 { |
1019
|
1276 case '%': |
|
1277 case '#': |
2300
|
1278 in_comment = true; |
|
1279 begin_comment = true; |
1019
|
1280 break; |
777
|
1281 |
1019
|
1282 case ' ': |
|
1283 case '\t': |
|
1284 break; |
777
|
1285 |
1019
|
1286 default: |
|
1287 goto done; |
1
|
1288 } |
|
1289 } |
1019
|
1290 } |
991
|
1291 |
1019
|
1292 done: |
991
|
1293 |
1019
|
1294 if (c) |
3246
|
1295 unput (c); |
1
|
1296 } |
|
1297 |
767
|
1298 // Return 1 if the given character matches any character in the given |
|
1299 // string. |
|
1300 |
2857
|
1301 static bool |
2804
|
1302 match_any (char c, const char *s) |
1
|
1303 { |
|
1304 char tmp; |
|
1305 while ((tmp = *s++) != '\0') |
|
1306 { |
|
1307 if (c == tmp) |
2857
|
1308 return true; |
1
|
1309 } |
2857
|
1310 return false; |
1
|
1311 } |
|
1312 |
767
|
1313 // Given information about the spacing surrounding an operator, |
|
1314 // return 1 if it looks like it should be treated as a binary |
|
1315 // operator. For example, |
|
1316 // |
3774
|
1317 // [ 1 + 2 ] or [ 1+ 2] or [ 1+2 ] ==> binary |
|
1318 // |
|
1319 // [ 1 +2 ] ==> unary |
767
|
1320 |
2857
|
1321 static bool |
3246
|
1322 looks_like_bin_op (bool spc_prev, int next_char) |
1
|
1323 { |
3246
|
1324 bool spc_next = (next_char == ' ' || next_char == '\t'); |
|
1325 |
608
|
1326 return ((spc_prev && spc_next) || ! spc_prev); |
1
|
1327 } |
|
1328 |
3263
|
1329 // Recognize separators. If the separator is a CRLF pair, it is |
|
1330 // replaced by a single LF. |
|
1331 |
|
1332 static bool |
|
1333 next_token_is_sep_op (void) |
|
1334 { |
|
1335 bool retval = false; |
|
1336 |
|
1337 int c1 = yyinput (); |
|
1338 |
|
1339 if (c1 == '\r') |
|
1340 { |
|
1341 int c2 = yyinput (); |
|
1342 |
|
1343 if (c2 == '\n') |
|
1344 { |
|
1345 c1 = '\n'; |
|
1346 |
|
1347 retval = true; |
|
1348 } |
|
1349 else |
|
1350 unput (c2); |
|
1351 } |
|
1352 else |
|
1353 retval = match_any (c1, ",;\n]"); |
|
1354 |
|
1355 unput (c1); |
|
1356 |
|
1357 return retval; |
|
1358 } |
|
1359 |
767
|
1360 // Try to determine if the next token should be treated as a postfix |
|
1361 // unary operator. This is ugly, but it seems to do the right thing. |
|
1362 |
2857
|
1363 static bool |
3246
|
1364 next_token_is_postfix_unary_op (bool spc_prev) |
1
|
1365 { |
2857
|
1366 bool un_op = false; |
1
|
1367 |
|
1368 int c0 = yyinput (); |
|
1369 |
3246
|
1370 if (c0 == '\'' && ! spc_prev) |
|
1371 { |
|
1372 un_op = true; |
|
1373 } |
|
1374 else if (c0 == '.') |
|
1375 { |
|
1376 int c1 = yyinput (); |
|
1377 un_op = (c1 == '\''); |
|
1378 unput (c1); |
|
1379 } |
1
|
1380 |
3246
|
1381 unput (c0); |
1
|
1382 |
|
1383 return un_op; |
|
1384 } |
|
1385 |
767
|
1386 // Try to determine if the next token should be treated as a binary |
3246
|
1387 // operator. |
1521
|
1388 // |
3246
|
1389 // This kluge exists because whitespace is not always ignored inside |
3774
|
1390 // the square brackets that are used to create matrix objects (though |
|
1391 // spacing only really matters in the cases that can be interpreted |
|
1392 // either as binary ops or prefix unary ops: currently just +, -). |
|
1393 // |
3779
|
1394 // Note that a line continuation directly following a + or - operator |
|
1395 // (e.g., the characters '[' 'a' ' ' '+' '\' LFD 'b' ']') will be |
|
1396 // parsed as a binary operator. |
767
|
1397 |
2857
|
1398 static bool |
3246
|
1399 next_token_is_bin_op (bool spc_prev) |
1
|
1400 { |
2857
|
1401 bool bin_op = false; |
1
|
1402 |
|
1403 int c0 = yyinput (); |
|
1404 |
|
1405 switch (c0) |
|
1406 { |
777
|
1407 case '+': |
|
1408 case '-': |
3774
|
1409 { |
|
1410 int c1 = yyinput (); |
|
1411 |
|
1412 switch (c1) |
|
1413 { |
|
1414 case '+': |
|
1415 case '-': |
|
1416 // Unary ops, spacing doesn't matter. |
|
1417 break; |
|
1418 |
|
1419 case '=': |
|
1420 // Binary ops, spacing doesn't matter. |
|
1421 bin_op = true; |
|
1422 break; |
|
1423 |
|
1424 default: |
|
1425 // Could be either, spacing matters. |
|
1426 bin_op = looks_like_bin_op (spc_prev, c1); |
|
1427 break; |
|
1428 } |
|
1429 |
|
1430 unput (c1); |
|
1431 } |
|
1432 break; |
|
1433 |
|
1434 case ':': |
3246
|
1435 case '/': |
|
1436 case '\\': |
|
1437 case '^': |
3774
|
1438 // Always a binary op (may also include /=, \=, and ^=). |
|
1439 bin_op = true; |
1276
|
1440 break; |
|
1441 |
3246
|
1442 // .+ .- ./ .\ .^ .* .** |
1554
|
1443 case '.': |
|
1444 { |
|
1445 int c1 = yyinput (); |
3246
|
1446 |
3774
|
1447 if (match_any (c1, "+-/\\^*")) |
|
1448 // Always a binary op (may also include .+=, .-=, ./=, ...). |
|
1449 bin_op = true; |
3698
|
1450 else if (! isdigit (c1) && c1 != ' ' && c1 != '\t' && c1 != '.') |
3774
|
1451 // A structure element reference is a binary op. |
|
1452 bin_op = true; |
3246
|
1453 |
|
1454 unput (c1); |
1554
|
1455 } |
|
1456 break; |
|
1457 |
3246
|
1458 // = == & && | || * ** |
|
1459 case '=': |
1
|
1460 case '&': |
3246
|
1461 case '|': |
1
|
1462 case '*': |
3774
|
1463 // Always a binary op (may also include ==, &&, ||, **). |
|
1464 bin_op = true; |
3246
|
1465 break; |
|
1466 |
3774
|
1467 // < <= <> > >= |
1
|
1468 case '<': |
|
1469 case '>': |
3774
|
1470 // Always a binary op (may also include <=, <>, >=). |
|
1471 bin_op = true; |
|
1472 break; |
|
1473 |
|
1474 // ~= != |
777
|
1475 case '~': |
|
1476 case '!': |
3246
|
1477 { |
|
1478 int c1 = yyinput (); |
|
1479 |
3774
|
1480 // ~ and ! can be unary ops, so require following =. |
|
1481 if (c1 == '=') |
|
1482 bin_op = true; |
3246
|
1483 |
|
1484 unput (c1); |
|
1485 } |
1
|
1486 break; |
|
1487 |
|
1488 default: |
1276
|
1489 break; |
1
|
1490 } |
|
1491 |
3246
|
1492 unput (c0); |
1
|
1493 |
|
1494 return bin_op; |
|
1495 } |
|
1496 |
767
|
1497 // Used to delete trailing white space from tokens. |
|
1498 |
3536
|
1499 static std::string |
1
|
1500 strip_trailing_whitespace (char *s) |
|
1501 { |
3523
|
1502 std::string retval = s; |
1
|
1503 |
1823
|
1504 size_t pos = retval.find_first_of (" \t"); |
1
|
1505 |
1823
|
1506 if (pos != NPOS) |
|
1507 retval.resize (pos); |
1
|
1508 |
|
1509 return retval; |
|
1510 } |
|
1511 |
3665
|
1512 static void |
|
1513 scan_for_comments (const char *text) |
|
1514 { |
|
1515 std::string comment_buf; |
|
1516 |
|
1517 bool in_comment = false; |
|
1518 bool beginning_of_comment = false; |
|
1519 |
|
1520 int len = strlen (text); |
|
1521 int i = 0; |
|
1522 |
|
1523 while (i < len) |
|
1524 { |
|
1525 char c = text[i++]; |
|
1526 |
|
1527 switch (c) |
|
1528 { |
|
1529 case '%': |
|
1530 case '#': |
|
1531 if (in_comment) |
|
1532 { |
|
1533 if (! beginning_of_comment) |
3802
|
1534 comment_buf += static_cast<char> (c); |
3665
|
1535 } |
|
1536 else |
|
1537 { |
|
1538 in_comment = true; |
|
1539 beginning_of_comment = true; |
|
1540 } |
|
1541 break; |
|
1542 |
|
1543 case '\n': |
|
1544 if (in_comment) |
|
1545 { |
3802
|
1546 comment_buf += static_cast<char> (c); |
3665
|
1547 octave_comment_buffer::append (comment_buf); |
|
1548 comment_buf.resize (0); |
|
1549 in_comment = false; |
|
1550 beginning_of_comment = false; |
|
1551 } |
|
1552 break; |
|
1553 |
|
1554 case '\r': |
|
1555 if (in_comment) |
3802
|
1556 comment_buf += static_cast<char> (c); |
3665
|
1557 if (i < len) |
|
1558 { |
|
1559 c = text[i++]; |
|
1560 |
|
1561 if (c == '\n') |
|
1562 { |
|
1563 if (in_comment) |
|
1564 { |
3802
|
1565 comment_buf += static_cast<char> (c); |
3665
|
1566 octave_comment_buffer::append (comment_buf); |
|
1567 in_comment = false; |
|
1568 beginning_of_comment = false; |
|
1569 } |
|
1570 } |
|
1571 } |
|
1572 |
|
1573 default: |
|
1574 if (in_comment) |
|
1575 { |
3802
|
1576 comment_buf += static_cast<char> (c); |
3665
|
1577 beginning_of_comment = false; |
|
1578 } |
|
1579 break; |
|
1580 } |
|
1581 } |
|
1582 |
|
1583 if (! comment_buf.empty ()) |
|
1584 octave_comment_buffer::append (comment_buf); |
|
1585 } |
|
1586 |
1001
|
1587 // Discard whitespace, including comments and continuations. |
1088
|
1588 // |
|
1589 // Return value is logical OR of the following values: |
|
1590 // |
1826
|
1591 // ATE_NOTHING : no spaces to eat |
1088
|
1592 // ATE_SPACE_OR_TAB : space or tab in input |
|
1593 // ATE_NEWLINE : bare new line in input |
1001
|
1594 |
1826
|
1595 static yum_yum |
975
|
1596 eat_whitespace (void) |
|
1597 { |
1826
|
1598 yum_yum retval = ATE_NOTHING; |
3665
|
1599 |
|
1600 std::string comment_buf; |
|
1601 |
2857
|
1602 bool in_comment = false; |
3665
|
1603 bool beginning_of_comment = false; |
|
1604 |
|
1605 int c = 0; |
|
1606 |
975
|
1607 while ((c = yyinput ()) != EOF) |
|
1608 { |
|
1609 current_input_column++; |
|
1610 |
|
1611 switch (c) |
|
1612 { |
|
1613 case ' ': |
|
1614 case '\t': |
3665
|
1615 if (in_comment) |
|
1616 { |
3802
|
1617 comment_buf += static_cast<char> (c); |
3665
|
1618 beginning_of_comment = false; |
|
1619 } |
1088
|
1620 retval |= ATE_SPACE_OR_TAB; |
975
|
1621 break; |
|
1622 |
|
1623 case '\n': |
1088
|
1624 retval |= ATE_NEWLINE; |
3665
|
1625 if (in_comment) |
|
1626 { |
3802
|
1627 comment_buf += static_cast<char> (c); |
3665
|
1628 octave_comment_buffer::append (comment_buf); |
|
1629 comment_buf.resize (0); |
|
1630 in_comment = false; |
|
1631 beginning_of_comment = false; |
|
1632 } |
975
|
1633 current_input_column = 0; |
|
1634 break; |
|
1635 |
|
1636 case '#': |
|
1637 case '%': |
3665
|
1638 if (in_comment) |
|
1639 { |
|
1640 if (! beginning_of_comment) |
3802
|
1641 comment_buf += static_cast<char> (c); |
3665
|
1642 } |
|
1643 else |
|
1644 { |
|
1645 in_comment = true; |
|
1646 beginning_of_comment = true; |
|
1647 } |
975
|
1648 break; |
|
1649 |
1001
|
1650 case '.': |
|
1651 if (in_comment) |
3665
|
1652 { |
3802
|
1653 comment_buf += static_cast<char> (c); |
3665
|
1654 beginning_of_comment = false; |
|
1655 break; |
|
1656 } |
1001
|
1657 else |
|
1658 { |
|
1659 if (have_ellipsis_continuation ()) |
|
1660 break; |
|
1661 else |
|
1662 goto done; |
|
1663 } |
|
1664 |
|
1665 case '\\': |
|
1666 if (in_comment) |
3665
|
1667 { |
3802
|
1668 comment_buf += static_cast<char> (c); |
3665
|
1669 beginning_of_comment = false; |
|
1670 break; |
|
1671 } |
1001
|
1672 else |
|
1673 { |
3105
|
1674 if (have_continuation ()) |
1001
|
1675 break; |
|
1676 else |
|
1677 goto done; |
|
1678 } |
|
1679 |
975
|
1680 default: |
|
1681 if (in_comment) |
3665
|
1682 { |
3802
|
1683 comment_buf += static_cast<char> (c); |
3665
|
1684 beginning_of_comment = false; |
|
1685 break; |
|
1686 } |
975
|
1687 else |
|
1688 goto done; |
|
1689 } |
|
1690 } |
|
1691 |
3665
|
1692 if (! comment_buf.empty ()) |
|
1693 octave_comment_buffer::append (comment_buf); |
|
1694 |
975
|
1695 done: |
3246
|
1696 unput (c); |
1082
|
1697 current_input_column--; |
1001
|
1698 return retval; |
975
|
1699 } |
|
1700 |
3220
|
1701 static inline bool |
|
1702 looks_like_hex (const char *s, int len) |
|
1703 { |
|
1704 return (len > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')); |
|
1705 } |
|
1706 |
975
|
1707 static void |
3246
|
1708 handle_number (void) |
972
|
1709 { |
3220
|
1710 double value = 0.0; |
|
1711 int nread = 0; |
|
1712 |
3598
|
1713 if (looks_like_hex (yytext, strlen (yytext))) |
3220
|
1714 { |
|
1715 unsigned long ival; |
3598
|
1716 |
|
1717 nread = sscanf (yytext, "%lx", &ival); |
|
1718 |
3220
|
1719 value = static_cast<double> (ival); |
|
1720 } |
|
1721 else |
3598
|
1722 { |
|
1723 char *tmp = strsave (yytext); |
|
1724 |
|
1725 char *idx = strpbrk (tmp, "Dd"); |
2621
|
1726 |
3598
|
1727 if (idx) |
|
1728 *idx = 'e'; |
|
1729 |
|
1730 nread = sscanf (tmp, "%lf", &value); |
|
1731 |
|
1732 delete [] tmp; |
|
1733 } |
972
|
1734 |
1826
|
1735 // If yytext doesn't contain a valid number, we are in deep doo doo. |
985
|
1736 |
972
|
1737 assert (nread == 1); |
|
1738 |
3988
|
1739 lexer_flags.quote_is_transpose = true; |
|
1740 lexer_flags.cant_be_identifier = true; |
|
1741 lexer_flags.convert_spaces_to_comma = true; |
972
|
1742 |
1826
|
1743 if (lexer_flags.plotting && ! lexer_flags.in_plot_range) |
3575
|
1744 lexer_flags.past_plot_range = true; |
972
|
1745 |
|
1746 yylval.tok_val = new token (value, yytext, input_line_number, |
|
1747 current_input_column); |
|
1748 |
|
1749 token_stack.push (yylval.tok_val); |
|
1750 |
|
1751 current_input_column += yyleng; |
|
1752 |
|
1753 do_comma_insert_check (); |
|
1754 } |
|
1755 |
1001
|
1756 // We have seen a backslash and need to find out if it should be |
|
1757 // treated as a continuation character. If so, this eats it, up to |
|
1758 // and including the new line character. |
|
1759 // |
973
|
1760 // Match whitespace only, followed by a comment character or newline. |
|
1761 // Once a comment character is found, discard all input until newline. |
|
1762 // If non-whitespace characters are found before comment |
|
1763 // characters, return 0. Otherwise, return 1. |
|
1764 |
2857
|
1765 static bool |
3096
|
1766 have_continuation (bool trailing_comments_ok) |
973
|
1767 { |
3523
|
1768 std::ostrstream buf; |
973
|
1769 |
3665
|
1770 std::string comment_buf; |
|
1771 |
2857
|
1772 bool in_comment = false; |
3665
|
1773 bool beginning_of_comment = false; |
|
1774 |
|
1775 int c = 0; |
|
1776 |
973
|
1777 while ((c = yyinput ()) != EOF) |
|
1778 { |
3802
|
1779 buf << static_cast<char> (c); |
973
|
1780 |
|
1781 switch (c) |
|
1782 { |
|
1783 case ' ': |
|
1784 case '\t': |
3665
|
1785 if (in_comment) |
|
1786 { |
3802
|
1787 comment_buf += static_cast<char> (c); |
3665
|
1788 beginning_of_comment = false; |
|
1789 } |
973
|
1790 break; |
|
1791 |
|
1792 case '%': |
|
1793 case '#': |
1091
|
1794 if (trailing_comments_ok) |
3665
|
1795 { |
|
1796 if (in_comment) |
|
1797 { |
|
1798 if (! beginning_of_comment) |
3802
|
1799 comment_buf += static_cast<char> (c); |
3665
|
1800 } |
|
1801 else |
|
1802 { |
|
1803 in_comment = true; |
|
1804 beginning_of_comment = true; |
|
1805 } |
|
1806 } |
1091
|
1807 else |
|
1808 goto cleanup; |
973
|
1809 break; |
|
1810 |
|
1811 case '\n': |
3665
|
1812 if (in_comment) |
|
1813 { |
3802
|
1814 comment_buf += static_cast<char> (c); |
3665
|
1815 octave_comment_buffer::append (comment_buf); |
|
1816 } |
975
|
1817 current_input_column = 0; |
1001
|
1818 promptflag--; |
2857
|
1819 return true; |
973
|
1820 |
3263
|
1821 case '\r': |
3665
|
1822 if (in_comment) |
3802
|
1823 comment_buf += static_cast<char> (c); |
3263
|
1824 c = yyinput (); |
|
1825 if (c == EOF) |
|
1826 break; |
|
1827 else if (c == '\n') |
|
1828 { |
3665
|
1829 if (in_comment) |
|
1830 { |
3802
|
1831 comment_buf += static_cast<char> (c); |
3665
|
1832 octave_comment_buffer::append (comment_buf); |
|
1833 } |
3263
|
1834 current_input_column = 0; |
|
1835 promptflag--; |
|
1836 return true; |
3665
|
1837 } |
3263
|
1838 |
3802
|
1839 // Fall through... |
|
1840 |
973
|
1841 default: |
3665
|
1842 if (in_comment) |
|
1843 { |
3802
|
1844 comment_buf += static_cast<char> (c); |
3665
|
1845 beginning_of_comment = false; |
|
1846 } |
|
1847 else |
1091
|
1848 goto cleanup; |
|
1849 break; |
973
|
1850 } |
|
1851 } |
|
1852 |
3246
|
1853 unput (c); |
2857
|
1854 return false; |
973
|
1855 |
3096
|
1856 cleanup: |
3538
|
1857 buf << std::ends; |
1091
|
1858 char *s = buf.str (); |
|
1859 if (s) |
|
1860 { |
|
1861 int len = strlen (s); |
|
1862 while (len--) |
3246
|
1863 unput (s[len]); |
1091
|
1864 } |
|
1865 delete [] s; |
3096
|
1866 |
2857
|
1867 return false; |
973
|
1868 } |
|
1869 |
1001
|
1870 // We have seen a `.' and need to see if it is the start of a |
|
1871 // continuation. If so, this eats it, up to and including the new |
|
1872 // line character. |
|
1873 |
2857
|
1874 static bool |
3096
|
1875 have_ellipsis_continuation (bool trailing_comments_ok) |
973
|
1876 { |
|
1877 char c1 = yyinput (); |
|
1878 if (c1 == '.') |
|
1879 { |
|
1880 char c2 = yyinput (); |
1091
|
1881 if (c2 == '.' && have_continuation (trailing_comments_ok)) |
2857
|
1882 return true; |
973
|
1883 else |
|
1884 { |
3246
|
1885 unput (c2); |
|
1886 unput (c1); |
973
|
1887 } |
|
1888 } |
|
1889 else |
3246
|
1890 unput (c1); |
973
|
1891 |
2857
|
1892 return false; |
973
|
1893 } |
|
1894 |
1001
|
1895 // See if we have a continuation line. If so, eat it and the leading |
|
1896 // whitespace on the next line. |
1088
|
1897 // |
|
1898 // Return value is the same as described for eat_whitespace(). |
1001
|
1899 |
1826
|
1900 static yum_yum |
1001
|
1901 eat_continuation (void) |
|
1902 { |
1826
|
1903 int retval = ATE_NOTHING; |
3665
|
1904 |
1001
|
1905 int c = yyinput (); |
3665
|
1906 |
1001
|
1907 if ((c == '.' && have_ellipsis_continuation ()) |
3105
|
1908 || (c == '\\' && have_continuation ())) |
1001
|
1909 retval = eat_whitespace (); |
|
1910 else |
3246
|
1911 unput (c); |
1001
|
1912 |
|
1913 return retval; |
|
1914 } |
|
1915 |
973
|
1916 static int |
975
|
1917 handle_string (char delim, int text_style) |
973
|
1918 { |
3523
|
1919 std::ostrstream buf; |
973
|
1920 |
3805
|
1921 int bos_line = input_line_number; |
|
1922 int bos_col = current_input_column; |
|
1923 |
973
|
1924 int c; |
1031
|
1925 int escape_pending = 0; |
973
|
1926 |
|
1927 while ((c = yyinput ()) != EOF) |
|
1928 { |
|
1929 current_input_column++; |
|
1930 |
3105
|
1931 if (c == '\\') |
973
|
1932 { |
1053
|
1933 if (escape_pending) |
|
1934 { |
3802
|
1935 buf << static_cast<char> (c); |
1053
|
1936 escape_pending = 0; |
|
1937 } |
|
1938 else |
|
1939 { |
3096
|
1940 if (have_continuation (false)) |
1053
|
1941 escape_pending = 0; |
|
1942 else |
|
1943 { |
3802
|
1944 buf << static_cast<char> (c); |
1053
|
1945 escape_pending = 1; |
|
1946 } |
|
1947 } |
1031
|
1948 continue; |
973
|
1949 } |
|
1950 else if (c == '.') |
|
1951 { |
3096
|
1952 if (! have_ellipsis_continuation (false)) |
3802
|
1953 buf << static_cast<char> (c); |
973
|
1954 } |
|
1955 else if (c == '\n') |
|
1956 { |
1053
|
1957 error ("unterminated string constant"); |
973
|
1958 break; |
|
1959 } |
|
1960 else if (c == delim) |
|
1961 { |
1031
|
1962 if (escape_pending) |
3802
|
1963 buf << static_cast<char> (c); |
973
|
1964 else |
|
1965 { |
|
1966 c = yyinput (); |
|
1967 if (c == delim) |
3802
|
1968 buf << static_cast<char> (c); |
973
|
1969 else |
|
1970 { |
3246
|
1971 unput (c); |
3538
|
1972 buf << std::ends; |
3105
|
1973 char *t = buf.str (); |
3523
|
1974 std::string s = do_string_escapes (t); |
3105
|
1975 delete [] t; |
975
|
1976 |
1826
|
1977 if (text_style && lexer_flags.doing_set) |
975
|
1978 { |
3523
|
1979 s = std::string (1, delim) + s + std::string (1, delim); |
975
|
1980 } |
|
1981 else |
|
1982 { |
2857
|
1983 lexer_flags.quote_is_transpose = true; |
|
1984 lexer_flags.cant_be_identifier = true; |
|
1985 lexer_flags.convert_spaces_to_comma = true; |
975
|
1986 } |
|
1987 |
3805
|
1988 yylval.tok_val = new token (s, bos_line, bos_col); |
973
|
1989 token_stack.push (yylval.tok_val); |
3400
|
1990 |
|
1991 if (delim == '\'') |
|
1992 gripe_single_quote_string (); |
|
1993 |
973
|
1994 return TEXT; |
|
1995 } |
|
1996 } |
|
1997 } |
|
1998 else |
|
1999 { |
3802
|
2000 buf << static_cast<char> (c); |
973
|
2001 } |
|
2002 |
1031
|
2003 escape_pending = 0; |
973
|
2004 } |
|
2005 |
|
2006 return LEXICAL_ERROR; |
|
2007 } |
|
2008 |
3208
|
2009 static bool |
|
2010 next_token_is_assign_op (void) |
|
2011 { |
|
2012 bool retval = false; |
|
2013 |
|
2014 int c0 = yyinput (); |
|
2015 |
|
2016 switch (c0) |
|
2017 { |
|
2018 case '=': |
|
2019 { |
|
2020 int c1 = yyinput (); |
|
2021 unput (c1); |
|
2022 if (c1 != '=') |
|
2023 retval = true; |
|
2024 } |
|
2025 break; |
|
2026 |
|
2027 case '+': |
|
2028 case '-': |
|
2029 case '*': |
|
2030 case '/': |
|
2031 case '\\': |
|
2032 case '&': |
|
2033 case '|': |
|
2034 { |
|
2035 int c1 = yyinput (); |
|
2036 unput (c1); |
|
2037 if (c1 == '=') |
|
2038 retval = true; |
|
2039 } |
|
2040 break; |
|
2041 |
|
2042 case '.': |
|
2043 { |
|
2044 int c1 = yyinput (); |
|
2045 if (match_any (c1, "+-*/\\")) |
|
2046 { |
|
2047 int c2 = yyinput (); |
|
2048 unput (c2); |
|
2049 if (c2 == '=') |
|
2050 retval = true; |
|
2051 } |
|
2052 unput (c1); |
|
2053 } |
|
2054 break; |
|
2055 |
|
2056 case '>': |
|
2057 { |
|
2058 int c1 = yyinput (); |
|
2059 if (c1 == '>') |
|
2060 { |
|
2061 int c2 = yyinput (); |
|
2062 unput (c2); |
|
2063 if (c2 == '=') |
|
2064 retval = true; |
|
2065 } |
|
2066 unput (c1); |
|
2067 } |
|
2068 break; |
|
2069 |
|
2070 case '<': |
|
2071 { |
|
2072 int c1 = yyinput (); |
|
2073 if (c1 == '<') |
|
2074 { |
|
2075 int c2 = yyinput (); |
|
2076 unput (c2); |
|
2077 if (c2 == '=') |
|
2078 retval = true; |
|
2079 } |
|
2080 unput (c1); |
|
2081 } |
|
2082 break; |
|
2083 |
|
2084 default: |
|
2085 break; |
|
2086 } |
|
2087 |
|
2088 unput (c0); |
|
2089 |
|
2090 return retval; |
|
2091 } |
|
2092 |
971
|
2093 static int |
3351
|
2094 handle_close_bracket (int spc_gobbled) |
971
|
2095 { |
3208
|
2096 int retval = ']'; |
|
2097 |
1826
|
2098 if (! nesting_level.none ()) |
971
|
2099 { |
1826
|
2100 nesting_level.remove (); |
3351
|
2101 lexer_flags.bracketflag--; |
971
|
2102 } |
|
2103 |
3351
|
2104 if (lexer_flags.bracketflag == 0) |
1001
|
2105 BEGIN 0; |
|
2106 |
3208
|
2107 if (next_token_is_assign_op () && ! lexer_flags.looking_at_return_list) |
971
|
2108 { |
3208
|
2109 retval = CLOSE_BRACE; |
971
|
2110 } |
|
2111 else |
|
2112 { |
3208
|
2113 int c1 = yyinput (); |
971
|
2114 unput (c1); |
|
2115 |
3388
|
2116 if (lexer_flags.bracketflag) |
971
|
2117 { |
3246
|
2118 int bin_op = next_token_is_bin_op (spc_gobbled); |
3263
|
2119 |
3246
|
2120 int postfix_un_op = next_token_is_postfix_unary_op (spc_gobbled); |
971
|
2121 |
3263
|
2122 int sep_op = next_token_is_sep_op (); |
971
|
2123 |
3263
|
2124 if (! (postfix_un_op || bin_op || sep_op) |
3351
|
2125 && nesting_level.is_bracket () |
1826
|
2126 && lexer_flags.convert_spaces_to_comma) |
971
|
2127 { |
3388
|
2128 maybe_warn_separator_insert (','); |
|
2129 |
|
2130 if (Vwhitespace_in_literal_matrix != 2) |
|
2131 { |
|
2132 unput (','); |
|
2133 return ']'; |
|
2134 } |
971
|
2135 } |
|
2136 } |
|
2137 } |
|
2138 |
2857
|
2139 lexer_flags.quote_is_transpose = true; |
|
2140 lexer_flags.cant_be_identifier = false; |
|
2141 lexer_flags.convert_spaces_to_comma = true; |
3208
|
2142 |
|
2143 return retval; |
971
|
2144 } |
|
2145 |
1072
|
2146 static void |
|
2147 maybe_unput_comma (int spc_gobbled) |
|
2148 { |
3388
|
2149 if (nesting_level.is_bracket ()) |
1072
|
2150 { |
3246
|
2151 int bin_op = next_token_is_bin_op (spc_gobbled); |
1072
|
2152 |
3246
|
2153 int postfix_un_op = next_token_is_postfix_unary_op (spc_gobbled); |
1072
|
2154 |
|
2155 int c1 = yyinput (); |
|
2156 int c2 = yyinput (); |
2970
|
2157 |
1072
|
2158 unput (c2); |
|
2159 unput (c1); |
2970
|
2160 |
3263
|
2161 int sep_op = next_token_is_sep_op (); |
2970
|
2162 |
1072
|
2163 int dot_op = (c1 == '.' |
|
2164 && (isalpha (c2) || isspace (c2) || c2 == '_')); |
2970
|
2165 |
3388
|
2166 if (postfix_un_op || bin_op || sep_op || dot_op) |
|
2167 return; |
|
2168 |
3985
|
2169 int index_op = (c1 == '(' || c1 == '{'); |
3388
|
2170 |
|
2171 if (index_op) |
|
2172 { |
3985
|
2173 // If there is no space before the indexing op, we don't |
|
2174 // insert a comma. |
3388
|
2175 if (! spc_gobbled) |
|
2176 return; |
|
2177 |
|
2178 maybe_warn_separator_insert (','); |
1072
|
2179 |
3388
|
2180 // If there is a space, we only insert a comma if we are |
|
2181 // trying to be Matlab-like. |
|
2182 if (Vwhitespace_in_literal_matrix == 1) |
|
2183 unput (','); |
|
2184 } |
|
2185 else |
|
2186 { |
|
2187 maybe_warn_separator_insert (','); |
|
2188 |
|
2189 if (Vwhitespace_in_literal_matrix != 2) |
|
2190 unput (','); |
|
2191 } |
1072
|
2192 } |
|
2193 } |
|
2194 |
767
|
2195 // Figure out exactly what kind of token to return when we have seen |
|
2196 // an identifier. Handles keywords. |
|
2197 |
146
|
2198 static int |
3974
|
2199 handle_identifier (void) |
146
|
2200 { |
3974
|
2201 std::string tok = strip_trailing_whitespace (yytext); |
|
2202 |
|
2203 int c = yytext[yyleng-1]; |
|
2204 |
|
2205 int cont_is_spc = eat_continuation (); |
|
2206 |
|
2207 int spc_gobbled = (cont_is_spc || c == ' ' || c == '\t'); |
|
2208 |
1826
|
2209 // It is almost always an error for an identifier to be followed |
|
2210 // directly by another identifier. Special cases are handled |
|
2211 // below. |
883
|
2212 |
2857
|
2213 lexer_flags.cant_be_identifier = true; |
883
|
2214 |
2970
|
2215 // If we are expecting a structure element, avoid recognizing |
|
2216 // keywords and other special names and return STRUCT_ELT, which is |
|
2217 // a string that is also a valid identifier. But first, we have to |
|
2218 // decide whether to insert a comma. |
747
|
2219 |
1826
|
2220 if (lexer_flags.looking_at_indirect_ref) |
1072
|
2221 { |
2970
|
2222 do_comma_insert_check (); |
|
2223 |
1072
|
2224 maybe_unput_comma (spc_gobbled); |
2819
|
2225 |
|
2226 yylval.tok_val = new token (tok, input_line_number, |
|
2227 current_input_column); |
|
2228 |
|
2229 token_stack.push (yylval.tok_val); |
|
2230 |
2857
|
2231 lexer_flags.cant_be_identifier = false; |
|
2232 lexer_flags.quote_is_transpose = true; |
|
2233 lexer_flags.convert_spaces_to_comma = true; |
2819
|
2234 |
|
2235 current_input_column += yyleng; |
|
2236 |
2970
|
2237 return STRUCT_ELT; |
1072
|
2238 } |
747
|
2239 |
1826
|
2240 // If we have a regular keyword, or a plot STYLE, return it. |
|
2241 // Keywords can be followed by identifiers (TOK_RETURN handles |
|
2242 // that). |
146
|
2243 |
|
2244 int kw_token = is_keyword (tok); |
2970
|
2245 |
146
|
2246 if (kw_token) |
|
2247 { |
|
2248 if (kw_token == STYLE) |
|
2249 { |
1060
|
2250 current_input_column += yyleng; |
2857
|
2251 lexer_flags.quote_is_transpose = false; |
|
2252 lexer_flags.convert_spaces_to_comma = true; |
146
|
2253 return kw_token; |
|
2254 } |
|
2255 else |
|
2256 TOK_RETURN (kw_token); |
|
2257 } |
|
2258 |
1826
|
2259 // See if we have a plot keyword (title, using, with, or clear). |
146
|
2260 |
1826
|
2261 if (lexer_flags.plotting) |
941
|
2262 { |
1826
|
2263 // Yes, we really do need both of these plot_range variables. |
|
2264 // One is used to mark when we are past all possiblity of a plot |
|
2265 // range, the other is used to mark when we are actually between |
|
2266 // the square brackets that surround the range. |
146
|
2267 |
1826
|
2268 if (! lexer_flags.in_plot_range) |
2857
|
2269 lexer_flags.past_plot_range = true; |
941
|
2270 |
3351
|
2271 // Option keywords can't appear in brackets, braces, or parentheses. |
1273
|
2272 |
|
2273 int plot_option_kw = 0; |
2970
|
2274 |
1826
|
2275 if (nesting_level.none ()) |
1273
|
2276 plot_option_kw = is_plot_keyword (tok); |
3575
|
2277 |
1826
|
2278 if (lexer_flags.cant_be_identifier && plot_option_kw) |
941
|
2279 TOK_RETURN (plot_option_kw); |
|
2280 } |
146
|
2281 |
3480
|
2282 int c1 = yyinput (); |
|
2283 |
|
2284 bool next_tok_is_dot = (c1 == '.'); |
|
2285 bool next_tok_is_paren = (c1 == '('); |
|
2286 |
|
2287 bool next_tok_is_eq = false; |
|
2288 if (c1 == '=') |
|
2289 { |
|
2290 int c2 = yyinput (); |
|
2291 unput (c2); |
|
2292 |
|
2293 if (c2 != '=') |
|
2294 next_tok_is_eq = true; |
|
2295 } |
|
2296 |
|
2297 unput (c1); |
1001
|
2298 |
1826
|
2299 // Make sure we put the return values of a function in the symbol |
|
2300 // table that is local to the function. |
146
|
2301 |
2877
|
2302 // If we are defining a function and we have not seen the function |
|
2303 // name yet and the next token is `=', then this identifier must be |
|
2304 // the only return value for the function and it belongs in the |
|
2305 // local symbol table. |
|
2306 |
1826
|
2307 if (next_tok_is_eq |
2877
|
2308 && lexer_flags.defining_func |
|
2309 && ! lexer_flags.parsed_function_name) |
146
|
2310 curr_sym_tab = tmp_local_sym_tab; |
|
2311 |
2702
|
2312 // Kluge alert. |
|
2313 // |
|
2314 // If we are looking at a text style function, set up to gobble its |
2745
|
2315 // arguments. |
|
2316 // |
|
2317 // If the following token is `=', or if we are parsing a function |
3189
|
2318 // return list or function parameter list, or if we are looking at |
|
2319 // something like [ab,cd] = foo (), force the symbol to be inserted |
|
2320 // as a variable in the current symbol table. |
2702
|
2321 |
|
2322 if (is_text_function_name (tok) && ! is_variable (tok)) |
|
2323 { |
2745
|
2324 if (next_tok_is_eq |
|
2325 || lexer_flags.looking_at_return_list |
3189
|
2326 || lexer_flags.looking_at_parameter_list |
3246
|
2327 || lexer_flags.looking_at_matrix_or_assign_lhs |
|
2328 || (next_tok_is_dot && next_token_is_bin_op (spc_gobbled))) |
2745
|
2329 { |
|
2330 force_local_variable (tok); |
|
2331 } |
2702
|
2332 else if (! next_tok_is_paren) |
|
2333 { |
|
2334 if (tok == "gset") |
2857
|
2335 lexer_flags.doing_set = true; |
2702
|
2336 |
|
2337 BEGIN TEXT_FCN; |
|
2338 } |
|
2339 } |
|
2340 |
1826
|
2341 // Find the token in the symbol table. |
146
|
2342 |
|
2343 yylval.tok_val = new token (lookup_identifier (tok), |
|
2344 input_line_number, |
|
2345 current_input_column); |
|
2346 |
|
2347 token_stack.push (yylval.tok_val); |
|
2348 |
1826
|
2349 // After seeing an identifer, it is ok to convert spaces to a comma |
|
2350 // (if needed). |
146
|
2351 |
2857
|
2352 lexer_flags.convert_spaces_to_comma = true; |
146
|
2353 |
2877
|
2354 if (! next_tok_is_eq) |
|
2355 { |
|
2356 lexer_flags.quote_is_transpose = true; |
146
|
2357 |
2877
|
2358 do_comma_insert_check (); |
|
2359 |
|
2360 maybe_unput_comma (spc_gobbled); |
146
|
2361 } |
|
2362 |
2877
|
2363 current_input_column += yyleng; |
146
|
2364 |
|
2365 return NAME; |
|
2366 } |
|
2367 |
767
|
2368 // Print a warning if a function file that defines a function has |
|
2369 // anything other than comments and whitespace following the END token |
|
2370 // that matches the FUNCTION statement. |
|
2371 |
1
|
2372 void |
|
2373 check_for_garbage_after_fcn_def (void) |
|
2374 { |
1826
|
2375 // By making a newline be the next character to be read, we will |
|
2376 // force the parser to return after reading the function. Calling |
3246
|
2377 // unput with EOF does not work. |
1
|
2378 |
3665
|
2379 std::string comment_buf; |
|
2380 |
2857
|
2381 bool in_comment = false; |
3665
|
2382 bool beginning_of_comment = true; |
|
2383 |
1
|
2384 int lineno = input_line_number; |
3665
|
2385 |
|
2386 int c = 0; |
|
2387 |
1
|
2388 while ((c = yyinput ()) != EOF) |
|
2389 { |
|
2390 switch (c) |
|
2391 { |
|
2392 case ' ': |
|
2393 case '\t': |
|
2394 case ';': |
|
2395 case ',': |
3665
|
2396 if (in_comment) |
|
2397 { |
3802
|
2398 comment_buf += static_cast<char> (c); |
3665
|
2399 beginning_of_comment = false; |
|
2400 } |
1
|
2401 break; |
777
|
2402 |
1
|
2403 case '%': |
|
2404 case '#': |
3665
|
2405 if (in_comment) |
|
2406 { |
|
2407 if (! beginning_of_comment) |
3802
|
2408 comment_buf += static_cast<char> (c); |
3665
|
2409 } |
|
2410 else |
|
2411 { |
|
2412 in_comment = true; |
|
2413 beginning_of_comment = true; |
|
2414 } |
1
|
2415 break; |
777
|
2416 |
3802
|
2417 case '\n': |
|
2418 if (in_comment) |
|
2419 { |
|
2420 comment_buf += static_cast<char> (c); |
|
2421 octave_comment_buffer::append (comment_buf); |
|
2422 comment_buf.resize (0); |
|
2423 in_comment = false; |
|
2424 beginning_of_comment = false; |
|
2425 } |
|
2426 break; |
|
2427 |
|
2428 case '\r': |
|
2429 if (in_comment) |
|
2430 comment_buf += static_cast<char> (c); |
|
2431 c = yyinput (); |
|
2432 if (c == EOF) |
|
2433 break; |
|
2434 else if (c == '\n') |
|
2435 { |
|
2436 if (in_comment) |
|
2437 { |
|
2438 comment_buf += static_cast<char> (c); |
|
2439 octave_comment_buffer::append (comment_buf); |
|
2440 comment_buf.resize (0); |
|
2441 in_comment = false; |
|
2442 beginning_of_comment = false; |
|
2443 } |
|
2444 break; |
|
2445 } |
|
2446 |
|
2447 // Fall through... |
|
2448 |
1
|
2449 default: |
|
2450 if (in_comment) |
3665
|
2451 { |
3802
|
2452 comment_buf += static_cast<char> (c); |
3665
|
2453 beginning_of_comment = false; |
|
2454 break; |
|
2455 } |
1
|
2456 else |
|
2457 { |
|
2458 warning ("ignoring trailing garbage after end of function\n\ |
1755
|
2459 near line %d of file `%s.m'", lineno, curr_fcn_file_name.c_str ()); |
1
|
2460 |
3246
|
2461 unput ('\n'); |
1
|
2462 return; |
|
2463 } |
|
2464 } |
|
2465 } |
3665
|
2466 |
|
2467 if (! comment_buf.empty ()) |
|
2468 octave_comment_buffer::append (comment_buf); |
|
2469 |
3246
|
2470 unput ('\n'); |
1
|
2471 } |
|
2472 |
1826
|
2473 void |
|
2474 lexical_feedback::init (void) |
|
2475 { |
|
2476 // Not initially defining a matrix list. |
3351
|
2477 bracketflag = 0; |
1826
|
2478 |
|
2479 // Not initially inside a loop or if statement. |
|
2480 looping = 0; |
|
2481 |
2857
|
2482 // Not initially defining a function. |
|
2483 beginning_of_function = false; |
|
2484 defining_func = false; |
2877
|
2485 parsed_function_name = false; |
2857
|
2486 |
|
2487 // Not parsing a function return or parameter list. |
|
2488 looking_at_return_list = false; |
|
2489 looking_at_parameter_list = false; |
|
2490 |
3796
|
2491 // Not parsing a matrix or the left hand side of multi-value |
|
2492 // assignment statement. |
|
2493 looking_at_matrix_or_assign_lhs = false; |
|
2494 |
2857
|
2495 // Next token can be identifier. |
|
2496 cant_be_identifier = false; |
|
2497 |
|
2498 // No need to do comma insert or convert spaces to comma at |
|
2499 // beginning of input. |
|
2500 convert_spaces_to_comma = true; |
|
2501 do_comma_insert = false; |
|
2502 |
|
2503 // Not initially doing any plotting or setting of plot attributes. |
|
2504 doing_set = false; |
|
2505 in_plot_range = false; |
|
2506 in_plot_style = false; |
3165
|
2507 in_plot_axes = false; |
2857
|
2508 in_plot_using = false; |
|
2509 past_plot_range = false; |
|
2510 plotting = false; |
|
2511 |
1826
|
2512 // Not initially looking at indirect references. |
2857
|
2513 looking_at_indirect_ref = false; |
1826
|
2514 |
|
2515 // Quote marks strings intially. |
2857
|
2516 quote_is_transpose = false; |
1826
|
2517 } |
|
2518 |
3388
|
2519 static void |
|
2520 maybe_warn_separator_insert (char sep) |
|
2521 { |
3523
|
2522 std::string nm = curr_fcn_file_full_name; |
3388
|
2523 |
|
2524 if (Vwarn_separator_insert) |
|
2525 { |
|
2526 if (nm.empty ()) |
|
2527 warning ("potential auto-insertion of `%c' near line %d", |
|
2528 sep, input_line_number); |
|
2529 else |
|
2530 warning ("potential auto-insertion of `%c' near line %d of file %s", |
|
2531 sep, input_line_number, nm.c_str ()); |
|
2532 } |
|
2533 } |
|
2534 |
3400
|
2535 static void |
|
2536 gripe_single_quote_string (void) |
|
2537 { |
3523
|
2538 std::string nm = curr_fcn_file_full_name; |
3400
|
2539 |
|
2540 if (Vwarn_single_quote_string) |
|
2541 { |
|
2542 if (nm.empty ()) |
|
2543 warning ("single quote delimited string near line %d", |
|
2544 input_line_number); |
|
2545 else |
|
2546 warning ("single quote delimited string near line %d of file %s", |
|
2547 input_line_number, nm.c_str ()); |
|
2548 } |
|
2549 } |
|
2550 |
3388
|
2551 static int |
|
2552 warn_separator_insert (void) |
|
2553 { |
|
2554 Vwarn_separator_insert = check_preference ("warn_separator_insert"); |
|
2555 |
|
2556 return 0; |
|
2557 } |
|
2558 |
3246
|
2559 static int |
3400
|
2560 warn_single_quote_string (void) |
|
2561 { |
|
2562 Vwarn_single_quote_string = check_preference ("warn_single_quote_string"); |
|
2563 |
|
2564 return 0; |
|
2565 } |
|
2566 |
|
2567 static int |
2167
|
2568 whitespace_in_literal_matrix (void) |
|
2569 { |
|
2570 int pref = 0; |
3009
|
2571 |
3523
|
2572 std::string val = builtin_string_variable ("whitespace_in_literal_matrix"); |
3009
|
2573 |
2167
|
2574 if (! val.empty ()) |
|
2575 { |
3565
|
2576 if (val == "ignore") |
2167
|
2577 pref = 2; |
3565
|
2578 else if (val == "traditional") |
2167
|
2579 pref = 1; |
|
2580 } |
3009
|
2581 |
2167
|
2582 Vwhitespace_in_literal_matrix = pref; |
3009
|
2583 |
2167
|
2584 return 0; |
|
2585 } |
|
2586 |
|
2587 void |
|
2588 symbols_of_lex (void) |
|
2589 { |
3388
|
2590 DEFVAR (warn_separator_insert, 0.0, warn_separator_insert, |
3428
|
2591 "-*- texinfo -*-\n\ |
|
2592 @defvr {Built-in Variable} warn_separator_insert\n\ |
3567
|
2593 Print warning if commas or semicolons might be inserted\n\ |
3428
|
2594 automatically in literal matrices.\n\ |
|
2595 @end defvr"); |
3388
|
2596 |
3400
|
2597 DEFVAR (warn_single_quote_string, 0.0, warn_single_quote_string, |
3428
|
2598 "-*- texinfo -*-\n\ |
|
2599 @defvr {Built-in Variable} warn_single_quote_string\n\ |
|
2600 Print warning if a signle quote character is used to introduce a\n\ |
|
2601 string constant.\n\ |
|
2602 @end defvr"); |
3400
|
2603 |
3258
|
2604 DEFVAR (whitespace_in_literal_matrix, "", whitespace_in_literal_matrix, |
3428
|
2605 "-*- texinfo -*-\n\ |
|
2606 @defvr {Built-in Variable} whitespace_in_literal_matrix\n\ |
|
2607 Control auto-insertion of commas and semicolons in literal matrices.\n\ |
|
2608 @end defvr"); |
|
2609 |
2167
|
2610 } |
|
2611 |
1994
|
2612 /* |
|
2613 ;;; Local Variables: *** |
|
2614 ;;; mode: C++ *** |
|
2615 ;;; End: *** |
|
2616 */ |