1829
|
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 Octave; 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 // Parser for Octave. |
|
24 |
767
|
25 // C decarations. |
|
26 |
1
|
27 %{ |
|
28 #define YYDEBUG 1 |
|
29 |
240
|
30 #ifdef HAVE_CONFIG_H |
1229
|
31 #include <config.h> |
240
|
32 #endif |
|
33 |
2427
|
34 #ifdef YYBYACC |
|
35 #include <cstdlib> |
|
36 #endif |
|
37 |
581
|
38 #include <strstream.h> |
|
39 |
1
|
40 #include "Matrix.h" |
|
41 |
2166
|
42 #include "defun.h" |
1351
|
43 #include "error.h" |
|
44 #include "input.h" |
|
45 #include "lex.h" |
1743
|
46 #include "oct-hist.h" |
2891
|
47 #include "oct-usr-fcn.h" |
1670
|
48 #include "toplev.h" |
1351
|
49 #include "pager.h" |
|
50 #include "parse.h" |
1740
|
51 #include "pt-cmd.h" |
|
52 #include "pt-const.h" |
2891
|
53 #include "pt-exp.h" |
|
54 #include "pt-id.h" |
|
55 #include "pt-indir.h" |
1740
|
56 #include "pt-mat.h" |
2891
|
57 #include "pt-misc.h" |
1740
|
58 #include "pt-mvr.h" |
|
59 #include "pt-plot.h" |
2533
|
60 #include "pt-pr-code.h" |
1351
|
61 #include "symtab.h" |
|
62 #include "token.h" |
1
|
63 #include "utils.h" |
1351
|
64 #include "variables.h" |
1
|
65 |
2166
|
66 // If TRUE, generate a warning for the assignment in things like |
|
67 // |
|
68 // octave> if (a = 2 < n) |
|
69 // |
|
70 // but not |
|
71 // |
|
72 // octave> if ((a = 2) < n) |
|
73 // |
|
74 static bool Vwarn_assign_as_truth_value; |
|
75 |
2764
|
76 // If TRUE, generate a warning for variable swich labels. |
|
77 static bool Vwarn_variable_switch_label; |
|
78 |
2166
|
79 // If TRUE, generate warning if declared function name disagrees with |
|
80 // the name of the file in which it is defined. |
|
81 static bool Vwarn_function_name_clash; |
|
82 |
|
83 // If TRUE, generate warning if a statement in a function is not |
|
84 // terminated with a semicolon. Useful for checking functions that |
|
85 // should only produce output using explicit printing statements. |
|
86 static bool Vwarn_missing_semicolon; |
|
87 |
1
|
88 // Temporary symbol table pointer used to cope with bogus function syntax. |
522
|
89 symbol_table *tmp_local_sym_tab = 0; |
1
|
90 |
|
91 // The current input line number. |
|
92 int input_line_number = 0; |
|
93 |
|
94 // The column of the current token. |
143
|
95 int current_input_column = 1; |
1
|
96 |
338
|
97 // Buffer for help text snagged from function files. |
1755
|
98 string help_buf; |
1
|
99 |
496
|
100 // Forward declarations for some functions defined at the bottom of |
|
101 // the file. |
|
102 |
|
103 // Generic error messages. |
2805
|
104 static void yyerror (const char *s); |
1
|
105 |
578
|
106 // Error mesages for mismatched end tokens. |
2805
|
107 static void end_error |
|
108 (const char *type, token::end_tok_type ettype, int l, int c); |
1
|
109 |
578
|
110 // Check to see that end tokens are properly matched. |
2857
|
111 static bool end_token_ok (token *tok, token::end_tok_type expected); |
1
|
112 |
496
|
113 // Try to figure out early if an expression should become an |
1623
|
114 // assignment to the built-in variable ans. |
496
|
115 static tree_expression *maybe_convert_to_ans_assign (tree_expression *expr); |
|
116 |
|
117 // Maybe print a warning if an assignment expression is used as the |
|
118 // test in a logical expression. |
|
119 static void maybe_warn_assign_as_truth_value (tree_expression *expr); |
1
|
120 |
2764
|
121 // Maybe print a warning about switch labels that aren't constants. |
|
122 static void maybe_warn_variable_switch_label (tree_expression *expr); |
|
123 |
1623
|
124 // Create a plot command. |
|
125 static tree_plot_command *make_plot_command |
|
126 (token *tok, plot_limits *range, subplot_list *list); |
|
127 |
|
128 // Finish building a range. |
|
129 static tree_expression *finish_colon_expression (tree_colon_expression *e); |
|
130 |
1607
|
131 // Build a constant. |
2375
|
132 static tree_constant *make_constant (int op, token *tok_val); |
1607
|
133 |
578
|
134 // Build a binary expression. |
751
|
135 static tree_expression *make_binary_op |
|
136 (int op, tree_expression *op1, token *tok_val, tree_expression *op2); |
578
|
137 |
2375
|
138 // Build a boolean expression. |
|
139 static tree_expression *make_boolean_op |
|
140 (int op, tree_expression *op1, token *tok_val, tree_expression *op2); |
|
141 |
578
|
142 // Build a prefix expression. |
751
|
143 static tree_expression *make_prefix_op |
2960
|
144 (int op, tree_expression *op1, token *tok_val); |
578
|
145 |
|
146 // Build a postfix expression. |
751
|
147 static tree_expression *make_postfix_op |
|
148 (int op, tree_expression *op1, token *tok_val); |
578
|
149 |
1623
|
150 // Build an unwind-protect command. |
|
151 static tree_command *make_unwind_command |
|
152 (token *unwind_tok, tree_statement_list *body, |
|
153 tree_statement_list *cleanup, token *end_tok); |
|
154 |
|
155 // Build a try-catch command. |
|
156 static tree_command *make_try_command |
|
157 (token *try_tok, tree_statement_list *body, |
|
158 tree_statement_list *cleanup, token *end_tok); |
|
159 |
|
160 // Build a while command. |
|
161 static tree_command *make_while_command |
|
162 (token *while_tok, tree_expression *expr, |
|
163 tree_statement_list *body, token *end_tok); |
|
164 |
|
165 // Build a for command. |
|
166 static tree_command *make_for_command |
|
167 (token *for_tok, tree_index_expression *var, |
|
168 tree_expression *expr, tree_statement_list *body, |
|
169 token *end_tok); |
|
170 |
|
171 // Build a for command a different way. |
|
172 static tree_command *make_for_command |
1829
|
173 (token *for_tok, tree_matrix_row *mr, tree_expression *expr, |
1623
|
174 tree_statement_list *body, token *end_tok); |
|
175 |
|
176 // Build a break command. |
|
177 static tree_command *make_break_command (token *break_tok); |
|
178 |
|
179 // Build a continue command. |
|
180 static tree_command *make_continue_command (token *continue_tok); |
|
181 |
|
182 // Build a return command. |
|
183 static tree_command *make_return_command (token *return_tok); |
|
184 |
|
185 // Start an if command. |
|
186 static tree_if_command_list *start_if_command |
|
187 (tree_expression *expr, tree_statement_list *list); |
|
188 |
|
189 // Finish an if command. |
|
190 static tree_if_command *finish_if_command |
|
191 (token *if_tok, tree_if_command_list *list, token *end_tok); |
|
192 |
|
193 // Build an elseif clause. |
|
194 static tree_if_clause *make_elseif_clause |
|
195 (tree_expression *expr, tree_statement_list *list); |
|
196 |
2764
|
197 // Finish a switch command. |
|
198 static tree_switch_command *finish_switch_command |
|
199 (token *switch_tok, tree_expression *expr, |
|
200 tree_switch_case_list *list, token *end_tok); |
|
201 |
|
202 // Build a switch case. |
|
203 static tree_switch_case *make_switch_case |
|
204 (tree_expression *expr, tree_statement_list *list); |
|
205 |
1623
|
206 // Build an assignment to a variable. |
2883
|
207 static tree_expression *make_assign_op |
|
208 (int op, tree_index_expression *var, token *eq_tok, |
|
209 tree_expression *expr); |
1623
|
210 |
666
|
211 // Make an expression that handles assignment of multiple values. |
751
|
212 static tree_expression *make_multi_val_ret |
1829
|
213 (tree_matrix_row *mr, tree_expression *rhs, token *eq_tok); |
1623
|
214 |
|
215 // Begin defining a function. |
2891
|
216 static octave_user_function *start_function |
1623
|
217 (tree_parameter_list *param_list, tree_statement_list *body); |
|
218 |
|
219 // Do most of the work for defining a function. |
2891
|
220 static octave_user_function *frob_function |
|
221 (tree_identifier *id, octave_user_function *fcn); |
1623
|
222 |
|
223 // Finish defining a function. |
2891
|
224 static octave_user_function *finish_function |
|
225 (tree_identifier *id, octave_user_function *fcn); |
1623
|
226 |
|
227 // Finish defining a function a different way. |
2891
|
228 static octave_user_function *finish_function |
|
229 (tree_parameter_list *ret_list, octave_user_function *fcn); |
751
|
230 |
2883
|
231 // Reset state after parsing function. |
|
232 static void recover_from_parsing_function (void); |
|
233 |
751
|
234 // Make an index expression. |
|
235 static tree_index_expression *make_index_expression |
|
236 (tree_indirect_ref *indir, tree_argument_list *args); |
666
|
237 |
2846
|
238 // Make a declaration command. |
|
239 static tree_decl_command *make_decl_command |
|
240 (int tok, token *tok_val, tree_decl_init_list *lst); |
|
241 |
1623
|
242 // Finish building a matrix list. |
1829
|
243 static tree_expression *finish_matrix (tree_matrix *m); |
1623
|
244 |
1511
|
245 // Maybe print a warning. Duh. |
|
246 static void maybe_warn_missing_semi (tree_statement_list *); |
|
247 |
2525
|
248 // Set the print flag for a statement based on the separator type. |
|
249 static void set_stmt_print_flag (tree_statement_list *, char, bool); |
|
250 |
1
|
251 #define ABORT_PARSE \ |
|
252 do \ |
|
253 { \ |
522
|
254 global_command = 0; \ |
1
|
255 yyerrok; \ |
2865
|
256 if (interactive || forced_interactive) \ |
1
|
257 YYACCEPT; \ |
|
258 else \ |
|
259 YYABORT; \ |
|
260 } \ |
|
261 while (0) |
|
262 |
|
263 %} |
|
264 |
666
|
265 // Bison declarations. |
|
266 |
1
|
267 %union |
|
268 { |
2891
|
269 // The type of the basic tokens returned by the lexer. |
143
|
270 token *tok_val; |
|
271 |
2891
|
272 // Types for the nonterminals we generate. |
2525
|
273 char sep_type; |
1
|
274 tree *tree_type; |
1829
|
275 tree_matrix *tree_matrix_type; |
|
276 tree_matrix_row *tree_matrix_row_type; |
496
|
277 tree_expression *tree_expression_type; |
2375
|
278 tree_constant *tree_constant_type; |
1
|
279 tree_identifier *tree_identifier_type; |
751
|
280 tree_indirect_ref *tree_indirect_ref_type; |
1
|
281 tree_index_expression *tree_index_expression_type; |
|
282 tree_colon_expression *tree_colon_expression_type; |
|
283 tree_argument_list *tree_argument_list_type; |
|
284 tree_parameter_list *tree_parameter_list_type; |
|
285 tree_command *tree_command_type; |
|
286 tree_if_command *tree_if_command_type; |
578
|
287 tree_if_clause *tree_if_clause_type; |
|
288 tree_if_command_list *tree_if_command_list_type; |
2764
|
289 tree_switch_command *tree_switch_command_type; |
|
290 tree_switch_case *tree_switch_case_type; |
|
291 tree_switch_case_list *tree_switch_case_list_type; |
2846
|
292 tree_decl_elt *tree_decl_elt_type; |
|
293 tree_decl_init_list *tree_decl_init_list_type; |
|
294 tree_decl_command *tree_decl_command_type; |
578
|
295 tree_statement *tree_statement_type; |
|
296 tree_statement_list *tree_statement_list_type; |
1
|
297 tree_plot_command *tree_plot_command_type; |
578
|
298 subplot *subplot_type; |
|
299 subplot_list *subplot_list_type; |
|
300 plot_limits *plot_limits_type; |
|
301 plot_range *plot_range_type; |
|
302 subplot_using *subplot_using_type; |
|
303 subplot_style *subplot_style_type; |
2891
|
304 octave_user_function *octave_user_function_type; |
1
|
305 } |
|
306 |
143
|
307 // Tokens with line and column information. |
|
308 %token <tok_val> '=' ':' '-' '+' '*' '/' |
2883
|
309 %token <tok_val> ADD_EQ SUB_EQ MUL_EQ DIV_EQ EMUL_EQ EDIV_EQ AND_EQ OR_EQ |
2899
|
310 %token <tok_val> LSHIFT_EQ RSHIFT_EQ LSHIFT RSHIFT |
428
|
311 %token <tok_val> EXPR_AND_AND EXPR_OR_OR |
143
|
312 %token <tok_val> EXPR_AND EXPR_OR EXPR_NOT |
|
313 %token <tok_val> EXPR_LT EXPR_LE EXPR_EQ EXPR_NE EXPR_GE EXPR_GT |
1276
|
314 %token <tok_val> LEFTDIV EMUL EDIV ELEFTDIV EPLUS EMINUS |
|
315 %token <tok_val> QUOTE TRANSPOSE |
143
|
316 %token <tok_val> PLUS_PLUS MINUS_MINUS POW EPOW |
|
317 %token <tok_val> NUM IMAG_NUM |
2883
|
318 %token <tok_val> NAME |
143
|
319 %token <tok_val> END |
|
320 %token <tok_val> PLOT |
|
321 %token <tok_val> TEXT STYLE |
1491
|
322 %token <tok_val> FOR WHILE |
|
323 %token <tok_val> IF ELSEIF ELSE |
2764
|
324 %token <tok_val> SWITCH CASE OTHERWISE |
1491
|
325 %token <tok_val> BREAK CONTINUE FUNC_RET |
924
|
326 %token <tok_val> UNWIND CLEANUP |
1489
|
327 %token <tok_val> TRY CATCH |
2846
|
328 %token <tok_val> GLOBAL STATIC |
751
|
329 %token <tok_val> TEXT_ID |
1
|
330 |
143
|
331 // Other tokens. |
627
|
332 %token LEXICAL_ERROR |
191
|
333 %token FCN SCREW_TWO |
206
|
334 %token ELLIPSIS |
922
|
335 %token ALL_VA_ARGS |
206
|
336 %token END_OF_INPUT |
883
|
337 %token USING TITLE WITH COLON OPEN_BRACE CLOSE_BRACE CLEAR |
1
|
338 |
143
|
339 // Nonterminals we construct. |
2525
|
340 %type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep |
578
|
341 %type <tree_type> input |
2960
|
342 %type <tree_constant_type> constant magic_colon |
1829
|
343 %type <tree_matrix_type> rows rows1 |
|
344 %type <tree_matrix_row_type> matrix_row matrix_row1 |
496
|
345 %type <tree_expression_type> expression simple_expr simple_expr1 |
1623
|
346 %type <tree_expression_type> ans_expression title matrix |
1
|
347 %type <tree_identifier_type> identifier |
751
|
348 %type <tree_indirect_ref_type> indirect_ref indirect_ref1 |
2891
|
349 %type <octave_user_function_type> function1 function2 function3 |
482
|
350 %type <tree_index_expression_type> variable word_list_cmd |
1
|
351 %type <tree_colon_expression_type> colon_expr |
578
|
352 %type <tree_argument_list_type> arg_list word_list |
723
|
353 %type <tree_parameter_list_type> param_list param_list1 |
|
354 %type <tree_parameter_list_type> return_list return_list1 |
2891
|
355 %type <tree_command_type> command function |
578
|
356 %type <tree_if_command_type> if_command |
|
357 %type <tree_if_clause_type> elseif_clause else_clause |
|
358 %type <tree_if_command_list_type> if_cmd_list1 if_cmd_list |
2764
|
359 %type <tree_switch_command_type> switch_command |
|
360 %type <tree_switch_case_type> switch_case default_case |
|
361 %type <tree_switch_case_list_type> case_list1 case_list |
2846
|
362 %type <tree_decl_elt_type> decl2 |
|
363 %type <tree_decl_init_list_type> decl1 |
|
364 %type <tree_decl_command_type> declaration |
578
|
365 %type <tree_statement_type> statement |
627
|
366 %type <tree_statement_list_type> simple_list simple_list1 list list1 |
2891
|
367 %type <tree_statement_list_type> opt_list input1 function4 |
1
|
368 %type <tree_plot_command_type> plot_command |
578
|
369 %type <subplot_type> plot_command2 plot_options |
|
370 %type <subplot_list_type> plot_command1 |
|
371 %type <plot_limits_type> ranges |
|
372 %type <plot_range_type> ranges1 |
|
373 %type <subplot_using_type> using using1 |
|
374 %type <subplot_style_type> style |
1
|
375 |
143
|
376 // Precedence and associativity. |
1
|
377 %left ';' ',' '\n' |
2899
|
378 %right '=' ADD_EQ SUB_EQ MUL_EQ DIV_EQ EMUL_EQ EDIV_EQ OR_EQ AND_EQ LSHIFT_EQ RSHIFT_EQ |
428
|
379 %left EXPR_AND_AND EXPR_OR_OR |
1
|
380 %left EXPR_AND EXPR_OR |
|
381 %left EXPR_LT EXPR_LE EXPR_EQ EXPR_NE EXPR_GE EXPR_GT |
2899
|
382 %left LSHIFT RSHIFT |
1
|
383 %left ':' |
1276
|
384 %left '-' '+' EPLUS EMINUS |
1
|
385 %left '*' '/' LEFTDIV EMUL EDIV ELEFTDIV |
|
386 %left QUOTE TRANSPOSE |
|
387 %left UNARY PLUS_PLUS MINUS_MINUS EXPR_NOT |
|
388 %right POW EPOW |
|
389 |
143
|
390 // Where to start. |
1
|
391 %start input |
|
392 |
666
|
393 // Grammar rules. |
|
394 |
1
|
395 %% |
|
396 |
627
|
397 input : input1 |
1
|
398 { |
627
|
399 global_command = $1; |
1
|
400 promptflag = 1; |
|
401 YYACCEPT; |
|
402 } |
|
403 | END_OF_INPUT |
|
404 { |
522
|
405 global_command = 0; |
1
|
406 promptflag = 1; |
|
407 YYABORT; |
|
408 } |
627
|
409 | simple_list parse_error |
1091
|
410 { ABORT_PARSE; } |
627
|
411 | parse_error |
1091
|
412 { ABORT_PARSE; } |
627
|
413 ; |
|
414 |
|
415 input1 : '\n' |
|
416 { $$ = 0; } |
327
|
417 | simple_list |
627
|
418 { $$ = $1; } |
1
|
419 | simple_list '\n' |
627
|
420 { $$ = $1; } |
1
|
421 | simple_list END_OF_INPUT |
627
|
422 { $$ = $1; } |
|
423 ; |
|
424 |
|
425 parse_error : LEXICAL_ERROR |
1091
|
426 { yyerror ("parse error"); } |
1
|
427 | error |
|
428 ; |
|
429 |
2525
|
430 simple_list : simple_list1 opt_sep_no_nl |
1
|
431 { |
2525
|
432 set_stmt_print_flag ($1, $2, false); |
1511
|
433 $$ = $1; |
1
|
434 } |
|
435 ; |
|
436 |
578
|
437 simple_list1 : statement |
|
438 { $$ = new tree_statement_list ($1); } |
2525
|
439 | simple_list1 sep_no_nl statement |
1
|
440 { |
2525
|
441 set_stmt_print_flag ($1, $2, false); |
578
|
442 $1->append ($3); |
1511
|
443 $$ = $1; |
1
|
444 } |
|
445 ; |
|
446 |
|
447 opt_list : // empty |
578
|
448 { $$ = new tree_statement_list (); } |
1
|
449 | list |
|
450 { $$ = $1; } |
496
|
451 ; |
1
|
452 |
2525
|
453 list : list1 opt_sep |
1511
|
454 { |
2525
|
455 set_stmt_print_flag ($1, $2, true); |
1829
|
456 $$ = $1; |
1
|
457 } |
|
458 ; |
|
459 |
578
|
460 list1 : statement |
440
|
461 { |
2857
|
462 lexer_flags.beginning_of_function = false; |
578
|
463 $$ = new tree_statement_list ($1); |
440
|
464 } |
2525
|
465 | list1 sep statement |
1511
|
466 { |
2525
|
467 set_stmt_print_flag ($1, $2, true); |
578
|
468 $1->append ($3); |
1511
|
469 $$ = $1; |
1
|
470 } |
|
471 ; |
|
472 |
578
|
473 statement : command |
|
474 { $$ = new tree_statement ($1); } |
1
|
475 | ans_expression |
578
|
476 { $$ = new tree_statement ($1); } |
883
|
477 | PLOT CLEAR |
|
478 { |
|
479 symbol_record *sr = lookup_by_name ("clearplot", 0); |
|
480 tree_identifier *id = new tree_identifier (sr); |
|
481 $$ = new tree_statement (id); |
|
482 } |
1
|
483 ; |
|
484 |
|
485 plot_command : PLOT plot_command1 |
|
486 { |
1623
|
487 if (! ($$ = make_plot_command ($1, 0, $2))) |
|
488 ABORT_PARSE; |
1
|
489 } |
|
490 | PLOT ranges plot_command1 |
|
491 { |
1623
|
492 if (! ($$ = make_plot_command ($1, $2, $3))) |
|
493 ABORT_PARSE; |
1
|
494 } |
|
495 ; |
|
496 |
|
497 ranges : ranges1 |
578
|
498 { $$ = new plot_limits ($1); } |
1
|
499 | ranges1 ranges1 |
578
|
500 { $$ = new plot_limits ($1, $2); } |
1
|
501 | ranges1 ranges1 ranges1 |
578
|
502 { $$ = new plot_limits ($1, $2, $3); } |
1
|
503 ; |
|
504 |
|
505 ranges1 : OPEN_BRACE expression COLON expression CLOSE_BRACE |
578
|
506 { $$ = new plot_range ($2, $4); } |
1
|
507 | OPEN_BRACE COLON expression CLOSE_BRACE |
578
|
508 { $$ = new plot_range (0, $3); } |
1
|
509 | OPEN_BRACE expression COLON CLOSE_BRACE |
578
|
510 { $$ = new plot_range ($2, 0); } |
1
|
511 | OPEN_BRACE COLON CLOSE_BRACE |
578
|
512 { $$ = new plot_range (); } |
1
|
513 | OPEN_BRACE CLOSE_BRACE |
578
|
514 { $$ = new plot_range (); } |
1
|
515 ; |
|
516 |
478
|
517 plot_command1 : // empty |
522
|
518 { $$ = 0; } |
478
|
519 | plot_command2 |
578
|
520 { $$ = new subplot_list ($1); } |
1
|
521 | plot_command1 ',' plot_command2 |
1829
|
522 { |
|
523 $1->append ($3); |
|
524 $$ = $1; |
|
525 } |
1
|
526 ; |
|
527 |
|
528 plot_command2 : expression |
578
|
529 { $$ = new subplot ($1); } |
1
|
530 | expression plot_options |
1623
|
531 { $$ = $2->set_data ($1); } |
1
|
532 ; |
|
533 |
|
534 plot_options : using |
578
|
535 { $$ = new subplot ($1, 0, 0); } |
1
|
536 | title |
578
|
537 { $$ = new subplot (0, $1, 0); } |
1
|
538 | style |
578
|
539 { $$ = new subplot (0, 0, $1); } |
1
|
540 | using title |
578
|
541 { $$ = new subplot ($1, $2, 0); } |
|
542 | title using |
|
543 { $$ = new subplot ($2, $1, 0); } |
|
544 | using style |
|
545 { $$ = new subplot ($1, 0, $2); } |
|
546 | style using |
|
547 { $$ = new subplot ($2, 0, $1); } |
|
548 | title style |
|
549 { $$ = new subplot (0, $1, $2); } |
|
550 | style title |
|
551 { $$ = new subplot (0, $2, $1); } |
|
552 | using title style |
|
553 { $$ = new subplot ($1, $2, $3); } |
|
554 | using style title |
|
555 { $$ = new subplot ($1, $3, $2); } |
|
556 | title using style |
|
557 { $$ = new subplot ($2, $1, $3); } |
|
558 | title style using |
|
559 { $$ = new subplot ($3, $1, $2); } |
|
560 | style using title |
|
561 { $$ = new subplot ($2, $3, $1); } |
|
562 | style title using |
|
563 { $$ = new subplot ($3, $2, $1); } |
1
|
564 ; |
|
565 |
|
566 using : using1 |
|
567 { |
2857
|
568 lexer_flags.in_plot_using = false; |
1
|
569 $$ = $1; |
|
570 } |
|
571 | using1 expression |
|
572 { |
2857
|
573 lexer_flags.in_plot_using = false; |
1
|
574 $$ = $1->set_format ($2); |
|
575 } |
|
576 ; |
|
577 |
|
578 using1 : USING expression |
|
579 { |
578
|
580 subplot_using *tmp = new subplot_using (); |
1
|
581 $$ = tmp->add_qualifier ($2); |
|
582 } |
|
583 | using1 COLON expression |
|
584 { $$ = $1->add_qualifier ($3); } |
|
585 ; |
|
586 |
|
587 title : TITLE expression |
|
588 { $$ = $2; } |
|
589 ; |
|
590 |
|
591 style : WITH STYLE |
1755
|
592 { $$ = new subplot_style ($2->text ()); } |
1
|
593 | WITH STYLE expression |
1755
|
594 { $$ = new subplot_style ($2->text (), $3); } |
2542
|
595 | WITH STYLE expression expression |
|
596 { $$ = new subplot_style ($2->text (), $3, $4); } |
1
|
597 ; |
|
598 |
|
599 ans_expression : expression |
|
600 { $$ = maybe_convert_to_ans_assign ($1); } |
|
601 ; |
|
602 |
2846
|
603 decl1 : decl2 |
|
604 { $$ = new tree_decl_init_list ($1); } |
|
605 | decl1 decl2 |
578
|
606 { |
2846
|
607 $1->append ($2); |
|
608 $$ = $1; |
578
|
609 } |
2846
|
610 ; |
|
611 |
|
612 decl2 : identifier |
|
613 { $$ = new tree_decl_elt ($1); } |
578
|
614 | identifier '=' expression |
1
|
615 { |
578
|
616 tree_simple_assignment_expression *tmp_ass; |
|
617 tmp_ass = new tree_simple_assignment_expression |
581
|
618 ($1, $3, 0, 0, $2->line (), $2->column ()); |
2846
|
619 $$ = new tree_decl_elt (tmp_ass); |
1
|
620 } |
|
621 ; |
|
622 |
2846
|
623 declaration : GLOBAL decl1 |
|
624 { $$ = make_decl_command (GLOBAL, $1, $2); } |
|
625 | STATIC decl1 |
|
626 { $$ = make_decl_command (STATIC, $1, $2); } |
1
|
627 ; |
|
628 |
578
|
629 command : plot_command |
|
630 { $$ = $1; } |
2891
|
631 | function |
578
|
632 { $$ = $1; } |
2846
|
633 | declaration |
578
|
634 { $$ = $1; } |
2764
|
635 | switch_command |
|
636 { $$ = $1; } |
578
|
637 | if_command |
2764
|
638 { $$ = $1; } |
2525
|
639 | UNWIND opt_sep opt_list CLEANUP opt_sep opt_list END |
916
|
640 { |
1623
|
641 if (! ($$ = make_unwind_command ($1, $3, $6, $7))) |
916
|
642 ABORT_PARSE; |
|
643 } |
2525
|
644 | TRY opt_sep opt_list CATCH opt_sep opt_list END |
1489
|
645 { |
1623
|
646 if (! ($$ = make_try_command ($1, $3, $6, $7))) |
1489
|
647 ABORT_PARSE; |
|
648 } |
2525
|
649 | WHILE expression opt_sep opt_list END |
1
|
650 { |
1623
|
651 if (! ($$ = make_while_command ($1, $2, $4, $5))) |
143
|
652 ABORT_PARSE; |
1
|
653 } |
2525
|
654 | FOR variable '=' expression opt_sep opt_list END |
1
|
655 { |
1623
|
656 if (! ($$ = make_for_command ($1, $2, $4, $6, $7))) |
143
|
657 ABORT_PARSE; |
1
|
658 } |
1229
|
659 | FOR '[' screwed_again matrix_row SCREW_TWO '=' |
2525
|
660 expression opt_sep opt_list END |
1229
|
661 { |
1829
|
662 if (! ($$ = make_for_command ($1, $4, $7, $9, $10))) |
1229
|
663 ABORT_PARSE; |
|
664 } |
1
|
665 | BREAK |
|
666 { |
1623
|
667 if (! ($$ = make_break_command ($1))) |
|
668 ABORT_PARSE; |
1
|
669 } |
|
670 | CONTINUE |
|
671 { |
1623
|
672 if (! ($$ = make_continue_command ($1))) |
|
673 ABORT_PARSE; |
1
|
674 } |
|
675 | FUNC_RET |
|
676 { |
1623
|
677 if (! ($$ = make_return_command ($1))) |
|
678 ABORT_PARSE; |
1
|
679 } |
|
680 ; |
|
681 |
578
|
682 if_command : IF if_cmd_list END |
|
683 { |
1623
|
684 if (! ($$ = finish_if_command ($1, $2, $3))) |
578
|
685 ABORT_PARSE; |
|
686 } |
|
687 ; |
|
688 |
|
689 if_cmd_list : if_cmd_list1 |
2427
|
690 { $$ = $1; } |
578
|
691 | if_cmd_list1 else_clause |
1829
|
692 { |
|
693 $1->append ($2); |
|
694 $$ = $1; |
|
695 } |
578
|
696 ; |
|
697 |
2525
|
698 if_cmd_list1 : expression opt_sep opt_list |
1623
|
699 { $$ = start_if_command ($1, $3); } |
578
|
700 | if_cmd_list1 elseif_clause |
1829
|
701 { |
|
702 $1->append ($2); |
|
703 $$ = $1; |
|
704 } |
578
|
705 ; |
|
706 |
2525
|
707 elseif_clause : ELSEIF opt_sep expression opt_sep opt_list |
1623
|
708 { $$ = make_elseif_clause ($3, $5); } |
578
|
709 ; |
|
710 |
2525
|
711 else_clause : ELSE opt_sep opt_list |
578
|
712 { $$ = new tree_if_clause ($3); } |
1
|
713 ; |
|
714 |
2764
|
715 switch_command : SWITCH expression opt_sep case_list END |
|
716 { |
|
717 if (! ($$ = finish_switch_command ($1, $2, $4, $5))) |
|
718 ABORT_PARSE; |
|
719 } |
|
720 ; |
|
721 |
|
722 case_list : case_list1 |
|
723 { $$ = $1; } |
|
724 | case_list1 default_case |
|
725 { |
|
726 $1->append ($2); |
|
727 $$ = $1; |
|
728 } |
|
729 ; |
|
730 |
|
731 case_list1 : switch_case |
|
732 { $$ = new tree_switch_case_list ($1); } |
|
733 | case_list1 switch_case |
|
734 { |
|
735 $1->append ($2); |
|
736 $$ = $1; |
|
737 } |
|
738 ; |
|
739 |
|
740 switch_case : CASE opt_sep expression opt_sep list |
|
741 { $$ = make_switch_case ($3, $5); } |
|
742 ; |
|
743 |
|
744 default_case : OTHERWISE opt_sep opt_list |
|
745 { $$ = new tree_switch_case ($3); } |
|
746 ; |
|
747 |
1
|
748 screwed_again : // empty |
1826
|
749 { lexer_flags.maybe_screwed_again++; } |
1
|
750 ; |
|
751 |
1623
|
752 expression : simple_expr |
|
753 { $$ = $1; } |
1
|
754 | NUM '=' expression |
|
755 { |
1005
|
756 yyerror ("invalid assignment to a number"); |
522
|
757 $$ = 0; |
1
|
758 ABORT_PARSE; |
|
759 } |
1623
|
760 ; |
|
761 |
|
762 // Now that we do some simple constant folding, we have to make sure |
|
763 // that we get something valid back make_binary_op and make_unary_op. |
|
764 |
|
765 simple_expr : simple_expr1 |
666
|
766 { |
1623
|
767 if (! ($$ = $1)) |
666
|
768 ABORT_PARSE; |
|
769 } |
1
|
770 ; |
|
771 |
2960
|
772 constant : NUM |
1623
|
773 { $$ = make_constant (NUM, $1); } |
|
774 | IMAG_NUM |
|
775 { $$ = make_constant (IMAG_NUM, $1); } |
|
776 | TEXT |
|
777 { $$ = make_constant (TEXT, $1); } |
2960
|
778 ; |
|
779 |
|
780 simple_expr1 : constant |
|
781 { $$ = $1; } |
1623
|
782 | '(' simple_expr ')' |
2960
|
783 { $$ = $2->mark_in_parens (); } |
1623
|
784 | word_list_cmd |
|
785 { $$ = $1; } |
|
786 | variable |
|
787 { $$ = $1; } |
2533
|
788 | colon_expr |
|
789 { $$ = finish_colon_expression ($1); } |
1623
|
790 | matrix |
1
|
791 { $$ = $1; } |
1623
|
792 | '[' ']' |
2883
|
793 { $$ = new tree_constant (octave_value (Matrix ())); } |
1623
|
794 | '[' ';' ']' |
2883
|
795 { $$ = new tree_constant (octave_value (Matrix ())); } |
2960
|
796 | PLUS_PLUS simple_expr %prec UNARY |
1623
|
797 { $$ = make_prefix_op (PLUS_PLUS, $2, $1); } |
2960
|
798 | MINUS_MINUS simple_expr %prec UNARY |
1623
|
799 { $$ = make_prefix_op (MINUS_MINUS, $2, $1); } |
2960
|
800 | EXPR_NOT simple_expr %prec UNARY |
|
801 { $$ = make_prefix_op (EXPR_NOT, $2, $1); } |
1623
|
802 | '+' simple_expr %prec UNARY |
|
803 { $$ = $2; } |
|
804 | '-' simple_expr %prec UNARY |
2960
|
805 { $$ = make_prefix_op ('-', $2, $1); } |
1623
|
806 | variable '=' simple_expr |
2883
|
807 { $$ = make_assign_op ('=', $1, $2, $3); } |
|
808 | variable ADD_EQ simple_expr |
|
809 { $$ = make_assign_op (ADD_EQ, $1, $2, $3); } |
|
810 | variable SUB_EQ simple_expr |
|
811 { $$ = make_assign_op (SUB_EQ, $1, $2, $3); } |
|
812 | variable MUL_EQ simple_expr |
|
813 { $$ = make_assign_op (MUL_EQ, $1, $2, $3); } |
|
814 | variable DIV_EQ simple_expr |
|
815 { $$ = make_assign_op (DIV_EQ, $1, $2, $3); } |
2899
|
816 | variable LSHIFT_EQ simple_expr |
|
817 { $$ = make_assign_op (LSHIFT_EQ, $1, $2, $3); } |
|
818 | variable RSHIFT_EQ simple_expr |
|
819 { $$ = make_assign_op (RSHIFT_EQ, $1, $2, $3); } |
2883
|
820 | variable EMUL_EQ simple_expr |
|
821 { $$ = make_assign_op (EMUL_EQ, $1, $2, $3); } |
|
822 | variable EDIV_EQ simple_expr |
|
823 { $$ = make_assign_op (EDIV_EQ, $1, $2, $3); } |
|
824 | variable AND_EQ simple_expr |
|
825 { $$ = make_assign_op (AND_EQ, $1, $2, $3); } |
|
826 | variable OR_EQ simple_expr |
|
827 { $$ = make_assign_op (OR_EQ, $1, $2, $3); } |
1623
|
828 | '[' screwed_again matrix_row SCREW_TWO '=' simple_expr |
2960
|
829 { $$ = make_multi_val_ret ($3, $6, $5); } |
|
830 | simple_expr PLUS_PLUS |
578
|
831 { $$ = make_postfix_op (PLUS_PLUS, $1, $2); } |
2960
|
832 | simple_expr MINUS_MINUS |
578
|
833 { $$ = make_postfix_op (MINUS_MINUS, $1, $2); } |
1
|
834 | simple_expr QUOTE |
2960
|
835 { $$ = make_postfix_op (QUOTE, $1, $2); } |
1
|
836 | simple_expr TRANSPOSE |
2960
|
837 { $$ = make_postfix_op (TRANSPOSE, $1, $2); } |
1
|
838 | simple_expr POW simple_expr |
578
|
839 { $$ = make_binary_op (POW, $1, $2, $3); } |
1
|
840 | simple_expr EPOW simple_expr |
578
|
841 { $$ = make_binary_op (EPOW, $1, $2, $3); } |
1
|
842 | simple_expr '+' simple_expr |
578
|
843 { $$ = make_binary_op ('+', $1, $2, $3); } |
1
|
844 | simple_expr '-' simple_expr |
578
|
845 { $$ = make_binary_op ('-', $1, $2, $3); } |
1
|
846 | simple_expr '*' simple_expr |
578
|
847 { $$ = make_binary_op ('*', $1, $2, $3); } |
1
|
848 | simple_expr '/' simple_expr |
578
|
849 { $$ = make_binary_op ('/', $1, $2, $3); } |
1276
|
850 | simple_expr EPLUS simple_expr |
|
851 { $$ = make_binary_op ('+', $1, $2, $3); } |
|
852 | simple_expr EMINUS simple_expr |
|
853 { $$ = make_binary_op ('-', $1, $2, $3); } |
1
|
854 | simple_expr EMUL simple_expr |
578
|
855 { $$ = make_binary_op (EMUL, $1, $2, $3); } |
1
|
856 | simple_expr EDIV simple_expr |
578
|
857 { $$ = make_binary_op (EDIV, $1, $2, $3); } |
1
|
858 | simple_expr LEFTDIV simple_expr |
578
|
859 { $$ = make_binary_op (LEFTDIV, $1, $2, $3); } |
1
|
860 | simple_expr ELEFTDIV simple_expr |
578
|
861 { $$ = make_binary_op (ELEFTDIV, $1, $2, $3); } |
2899
|
862 | simple_expr LSHIFT simple_expr |
|
863 { $$ = make_binary_op (LSHIFT, $1, $2, $3); } |
|
864 | simple_expr RSHIFT simple_expr |
|
865 { $$ = make_binary_op (RSHIFT, $1, $2, $3); } |
1
|
866 | simple_expr EXPR_LT simple_expr |
578
|
867 { $$ = make_binary_op (EXPR_LT, $1, $2, $3); } |
1
|
868 | simple_expr EXPR_LE simple_expr |
578
|
869 { $$ = make_binary_op (EXPR_LE, $1, $2, $3); } |
1
|
870 | simple_expr EXPR_EQ simple_expr |
578
|
871 { $$ = make_binary_op (EXPR_EQ, $1, $2, $3); } |
1
|
872 | simple_expr EXPR_GE simple_expr |
578
|
873 { $$ = make_binary_op (EXPR_GE, $1, $2, $3); } |
1
|
874 | simple_expr EXPR_GT simple_expr |
578
|
875 { $$ = make_binary_op (EXPR_GT, $1, $2, $3); } |
1
|
876 | simple_expr EXPR_NE simple_expr |
578
|
877 { $$ = make_binary_op (EXPR_NE, $1, $2, $3); } |
1
|
878 | simple_expr EXPR_AND simple_expr |
578
|
879 { $$ = make_binary_op (EXPR_AND, $1, $2, $3); } |
1
|
880 | simple_expr EXPR_OR simple_expr |
578
|
881 { $$ = make_binary_op (EXPR_OR, $1, $2, $3); } |
2375
|
882 | simple_expr EXPR_AND_AND simple_expr |
|
883 { $$ = make_boolean_op (EXPR_AND_AND, $1, $2, $3); } |
|
884 | simple_expr EXPR_OR_OR simple_expr |
|
885 { $$ = make_boolean_op (EXPR_OR_OR, $1, $2, $3); } |
1
|
886 ; |
|
887 |
1623
|
888 colon_expr : simple_expr ':' simple_expr |
1
|
889 { |
1623
|
890 $$ = new tree_colon_expression |
|
891 ($1, $3, $2->line (), $2->column ()); |
240
|
892 } |
1
|
893 | colon_expr ':' simple_expr |
|
894 { |
1623
|
895 if (! ($$ = $1->chain ($3))) |
1005
|
896 ABORT_PARSE; |
1
|
897 } |
|
898 ; |
|
899 |
|
900 word_list_cmd : identifier word_list |
482
|
901 { |
|
902 $$ = new tree_index_expression |
1623
|
903 ($1, $2, $1->line (), $1->column ()); |
482
|
904 } |
1
|
905 ; |
|
906 |
578
|
907 word_list : TEXT |
482
|
908 { |
2375
|
909 tree_constant *tmp = make_constant (TEXT, $1); |
482
|
910 $$ = new tree_argument_list (tmp); |
|
911 } |
578
|
912 | word_list TEXT |
482
|
913 { |
2375
|
914 tree_constant *tmp = make_constant (TEXT, $2); |
578
|
915 $1->append (tmp); |
1829
|
916 $$ = $1; |
482
|
917 } |
1
|
918 ; |
|
919 |
2883
|
920 global_symtab : // empty |
1
|
921 { curr_sym_tab = global_sym_tab; } |
|
922 ; |
|
923 |
|
924 local_symtab : // empty |
|
925 { curr_sym_tab = tmp_local_sym_tab; } |
|
926 ; |
|
927 |
2883
|
928 in_return_list : // empty |
|
929 { lexer_flags.looking_at_return_list = true; } |
1
|
930 ; |
|
931 |
2883
|
932 parsed_fcn_name : // empty |
|
933 { lexer_flags.parsed_function_name = true; } |
|
934 |
|
935 return_list_beg : '[' local_symtab in_return_list |
1
|
936 ; |
|
937 |
2883
|
938 return_list : return_list_beg return_list_end |
2745
|
939 { |
2857
|
940 lexer_flags.looking_at_return_list = false; |
2745
|
941 $$ = new tree_parameter_list (); |
|
942 } |
2883
|
943 | return_list_beg ELLIPSIS return_list_end |
723
|
944 { |
2857
|
945 lexer_flags.looking_at_return_list = false; |
723
|
946 tree_parameter_list *tmp = new tree_parameter_list (); |
|
947 tmp->mark_varargs_only (); |
|
948 $$ = tmp; |
|
949 } |
2883
|
950 | return_list_beg return_list1 return_list_end |
2745
|
951 { |
2857
|
952 lexer_flags.looking_at_return_list = false; |
2883
|
953 $$ = $2; |
2745
|
954 } |
2883
|
955 | return_list_beg return_list1 ',' ELLIPSIS return_list_end |
723
|
956 { |
2857
|
957 lexer_flags.looking_at_return_list = false; |
2883
|
958 $2->mark_varargs (); |
|
959 $$ = $2; |
723
|
960 } |
|
961 ; |
|
962 |
2883
|
963 return_list1 : identifier |
|
964 { $$ = new tree_parameter_list ($1); } |
723
|
965 | return_list1 ',' identifier |
1829
|
966 { |
|
967 $1->append ($3); |
|
968 $$ = $1; |
|
969 } |
1
|
970 ; |
|
971 |
2891
|
972 return_list_end : global_symtab ']' |
2883
|
973 ; |
|
974 |
2891
|
975 function_beg : FCN global_symtab |
|
976 ; |
|
977 |
|
978 function : function_beg function2 |
2883
|
979 { |
|
980 recover_from_parsing_function (); |
|
981 $$ = 0; |
|
982 } |
2891
|
983 | function_beg identifier function1 |
2883
|
984 { |
2891
|
985 finish_function ($2, $3); |
2883
|
986 recover_from_parsing_function (); |
|
987 $$ = 0; |
|
988 } |
2891
|
989 | function_beg return_list function1 |
2883
|
990 { |
2891
|
991 finish_function ($2, $3); |
2883
|
992 recover_from_parsing_function (); |
|
993 $$ = 0; |
|
994 } |
|
995 ; |
|
996 |
2891
|
997 function1 : global_symtab '=' function2 |
2883
|
998 { $$ = $3; } |
|
999 ; |
|
1000 |
2891
|
1001 function2 : identifier local_symtab parsed_fcn_name function3 |
1
|
1002 { |
2891
|
1003 if (! ($$ = frob_function ($1, $4))) |
1623
|
1004 ABORT_PARSE; |
1
|
1005 } |
|
1006 ; |
|
1007 |
2891
|
1008 function3 : param_list function4 |
|
1009 { $$ = start_function ($1, $2); } |
|
1010 | function4 |
|
1011 { $$ = start_function (0, $1); } |
2883
|
1012 ; |
|
1013 |
2891
|
1014 function4 : opt_sep opt_list function_end |
2883
|
1015 { $$ = $2; } |
1
|
1016 ; |
|
1017 |
2891
|
1018 function_end : END |
1
|
1019 { |
2857
|
1020 if (end_token_ok ($1, token::function_end)) |
|
1021 { |
|
1022 if (reading_fcn_file) |
|
1023 check_for_garbage_after_fcn_def (); |
|
1024 } |
|
1025 else |
1829
|
1026 ABORT_PARSE; |
1
|
1027 } |
|
1028 | END_OF_INPUT |
|
1029 { |
338
|
1030 if (! (reading_fcn_file || reading_script_file)) |
1
|
1031 YYABORT; |
|
1032 } |
|
1033 ; |
|
1034 |
751
|
1035 indirect_ref : indirect_ref1 |
191
|
1036 { |
2857
|
1037 lexer_flags.looking_at_indirect_ref = false; |
751
|
1038 $$ = $1; |
191
|
1039 } |
751
|
1040 |
|
1041 indirect_ref1 : identifier |
191
|
1042 { |
751
|
1043 $$ = new tree_indirect_ref ($1, $1->line (), |
|
1044 $1->column ()); |
191
|
1045 } |
1826
|
1046 | indirect_ref1 '.' |
2857
|
1047 { lexer_flags.looking_at_indirect_ref = true; } TEXT_ID |
2375
|
1048 { $$ = new tree_indirect_ref ($1, $4->text ()); } |
751
|
1049 ; |
|
1050 |
|
1051 variable : indirect_ref |
|
1052 { $$ = make_index_expression ($1, 0); } |
|
1053 | indirect_ref '(' ')' |
|
1054 { $$ = make_index_expression ($1, 0); } |
|
1055 | indirect_ref '(' arg_list ')' |
|
1056 { $$ = make_index_expression ($1, $3); } |
|
1057 | indirect_ref '[' |
1
|
1058 { |
1005
|
1059 yyerror ("use `(\' and `)\' as index operators, not\ |
1
|
1060 `[\' and `]\'"); |
522
|
1061 $$ = 0; |
1
|
1062 ABORT_PARSE; |
|
1063 } |
|
1064 ; |
|
1065 |
2818
|
1066 param_list_beg : '(' |
2857
|
1067 { lexer_flags.looking_at_parameter_list = true; } |
2745
|
1068 ; |
|
1069 |
2818
|
1070 param_list_end : ')' |
2857
|
1071 { lexer_flags.looking_at_parameter_list = false; } |
2818
|
1072 ; |
|
1073 |
|
1074 param_list : param_list_beg param_list_end |
1
|
1075 { |
2857
|
1076 lexer_flags.quote_is_transpose = false; |
522
|
1077 $$ = 0; |
240
|
1078 } |
2818
|
1079 | param_list_beg ELLIPSIS param_list_end |
504
|
1080 { |
2857
|
1081 lexer_flags.quote_is_transpose = false; |
504
|
1082 tree_parameter_list *tmp = new tree_parameter_list (); |
|
1083 tmp->mark_varargs_only (); |
|
1084 $$ = tmp; |
|
1085 } |
2818
|
1086 | param_list1 param_list_end |
240
|
1087 { |
2857
|
1088 lexer_flags.quote_is_transpose = false; |
578
|
1089 $1->mark_as_formal_parameters (); |
1829
|
1090 $$ = $1; |
1
|
1091 } |
2818
|
1092 | param_list1 ',' ELLIPSIS param_list_end |
206
|
1093 { |
2857
|
1094 lexer_flags.quote_is_transpose = false; |
578
|
1095 $1->mark_as_formal_parameters (); |
|
1096 $1->mark_varargs (); |
1829
|
1097 $$ = $1; |
206
|
1098 } |
504
|
1099 ; |
1
|
1100 |
2818
|
1101 param_list1 : param_list_beg identifier |
|
1102 { $$ = new tree_parameter_list ($2); } |
1
|
1103 | param_list1 ',' identifier |
1829
|
1104 { |
|
1105 $1->append ($3); |
|
1106 $$ = $1; |
|
1107 } |
2818
|
1108 | param_list_beg error |
1
|
1109 { |
1005
|
1110 yyerror ("invalid parameter list"); |
1829
|
1111 $$ = 0; |
206
|
1112 ABORT_PARSE; |
1
|
1113 } |
|
1114 | param_list1 ',' error |
|
1115 { |
1005
|
1116 yyerror ("invalid parameter list"); |
1829
|
1117 $$ = 0; |
206
|
1118 ABORT_PARSE; |
1
|
1119 } |
|
1120 ; |
|
1121 |
|
1122 identifier : NAME |
504
|
1123 { |
|
1124 $$ = new tree_identifier |
|
1125 ($1->sym_rec (), $1->line (), $1->column ()); |
|
1126 } |
|
1127 ; |
1
|
1128 |
2884
|
1129 magic_colon : ':' |
1
|
1130 { |
2883
|
1131 octave_value tmp (octave_value::magic_colon_t); |
2884
|
1132 $$ = new tree_constant (tmp); |
1
|
1133 } |
2884
|
1134 ; |
|
1135 |
|
1136 arg_list : magic_colon |
2891
|
1137 { $$ = new tree_argument_list ($1); } |
922
|
1138 | expression |
|
1139 { $$ = new tree_argument_list ($1); } |
|
1140 | ALL_VA_ARGS |
|
1141 { |
2883
|
1142 octave_value tmp (octave_value::all_va_args_t); |
|
1143 tree_constant *all_va_args = new tree_constant (tmp); |
922
|
1144 $$ = new tree_argument_list (all_va_args); |
|
1145 } |
2884
|
1146 | arg_list ',' magic_colon |
1
|
1147 { |
2884
|
1148 $1->append ($3); |
1829
|
1149 $$ = $1; |
1
|
1150 } |
578
|
1151 | arg_list ',' expression |
1829
|
1152 { |
|
1153 $1->append ($3); |
|
1154 $$ = $1; |
|
1155 } |
922
|
1156 | arg_list ',' ALL_VA_ARGS |
|
1157 { |
2883
|
1158 octave_value tmp (octave_value::all_va_args_t); |
|
1159 tree_constant *all_va_args = new tree_constant (tmp); |
922
|
1160 $1->append (all_va_args); |
1829
|
1161 $$ = $1; |
922
|
1162 } |
1
|
1163 ; |
|
1164 |
240
|
1165 matrix : '[' screwed_again rows ']' |
1829
|
1166 { $$ = finish_matrix ($3); } |
1
|
1167 ; |
|
1168 |
1084
|
1169 rows : rows1 |
1829
|
1170 { $$ = $1; } |
1084
|
1171 | rows1 ';' // Ignore trailing semicolon. |
1829
|
1172 { $$ = $1; } |
1
|
1173 ; |
|
1174 |
1084
|
1175 rows1 : matrix_row |
1829
|
1176 { $$ = new tree_matrix ($1); } |
1084
|
1177 | rows1 ';' matrix_row |
1829
|
1178 { |
|
1179 $1->append ($3); |
|
1180 $$ = $1; |
|
1181 } |
1084
|
1182 ; |
|
1183 |
|
1184 matrix_row : matrix_row1 |
1829
|
1185 { $$ = $1; } |
1084
|
1186 | matrix_row1 ',' // Ignore trailing comma. |
1829
|
1187 { $$ = $1; } |
1084
|
1188 ; |
|
1189 |
|
1190 matrix_row1 : expression // First element on row. |
1829
|
1191 { $$ = new tree_matrix_row ($1); } |
1084
|
1192 | matrix_row1 ',' expression |
1
|
1193 { |
1829
|
1194 $1->append ($3); |
|
1195 $$ = $1; |
1
|
1196 } |
|
1197 ; |
|
1198 |
2525
|
1199 sep_no_nl : ',' |
|
1200 { $$ = ','; } |
|
1201 | ';' |
|
1202 { $$ = ';'; } |
|
1203 | sep_no_nl ',' |
|
1204 { $$ = $1; } |
|
1205 | sep_no_nl ';' |
|
1206 { $$ = $1; } |
|
1207 ; |
|
1208 |
|
1209 opt_sep_no_nl : // empty |
|
1210 { $$ = 0; } |
|
1211 | sep_no_nl |
|
1212 { $$ = $1; } |
|
1213 ; |
|
1214 |
|
1215 sep : ',' |
|
1216 { $$ = ','; } |
|
1217 | ';' |
|
1218 { $$ = ';'; } |
|
1219 | '\n' |
|
1220 { $$ = '\n'; } |
|
1221 | sep ',' |
|
1222 { $$ = $1; } |
|
1223 | sep ';' |
|
1224 { $$ = $1; } |
|
1225 | sep '\n' |
|
1226 { $$ = $1; } |
|
1227 ; |
|
1228 |
|
1229 opt_sep : // empty |
|
1230 { $$ = 0; } |
|
1231 | sep |
|
1232 { $$ = $1; } |
|
1233 ; |
|
1234 |
1
|
1235 %% |
|
1236 |
666
|
1237 // Generic error messages. |
|
1238 |
1
|
1239 static void |
2805
|
1240 yyerror (const char *s) |
1
|
1241 { |
143
|
1242 int err_col = current_input_column - 1; |
1
|
1243 |
581
|
1244 ostrstream output_buf; |
1
|
1245 |
1005
|
1246 if (reading_fcn_file || reading_script_file) |
|
1247 output_buf << "parse error near line " << input_line_number |
1607
|
1248 << " of file " << curr_fcn_file_full_name; |
1005
|
1249 else |
|
1250 output_buf << "parse error:"; |
581
|
1251 |
1005
|
1252 if (s && strcmp (s, "parse error") != 0) |
|
1253 output_buf << "\n\n " << s; |
|
1254 |
|
1255 output_buf << "\n\n"; |
1
|
1256 |
1755
|
1257 if (! current_input_line.empty ()) |
1
|
1258 { |
1755
|
1259 size_t len = current_input_line.length (); |
1060
|
1260 |
1755
|
1261 if (current_input_line[len-1] == '\n') |
|
1262 current_input_line.resize (len-1); |
1005
|
1263 |
335
|
1264 // Print the line, maybe with a pointer near the error token. |
1005
|
1265 |
1755
|
1266 output_buf << ">>> " << current_input_line << "\n"; |
1060
|
1267 |
|
1268 if (err_col == 0) |
|
1269 err_col = len; |
|
1270 |
|
1271 for (int i = 0; i < err_col + 3; i++) |
|
1272 output_buf << " "; |
|
1273 |
|
1274 output_buf << "^"; |
1
|
1275 } |
1005
|
1276 |
|
1277 output_buf << "\n" << ends; |
581
|
1278 |
1005
|
1279 char *msg = output_buf.str (); |
|
1280 |
1090
|
1281 parse_error ("%s", msg); |
1005
|
1282 |
|
1283 delete [] msg; |
1
|
1284 } |
|
1285 |
666
|
1286 // Error mesages for mismatched end tokens. |
|
1287 |
496
|
1288 static void |
2805
|
1289 end_error (const char *type, token::end_tok_type ettype, int l, int c) |
496
|
1290 { |
2805
|
1291 static const char *fmt |
|
1292 = "`%s' command matched by `%s' near line %d column %d"; |
496
|
1293 |
|
1294 switch (ettype) |
|
1295 { |
|
1296 case token::simple_end: |
|
1297 error (fmt, type, "end", l, c); |
|
1298 break; |
777
|
1299 |
496
|
1300 case token::for_end: |
|
1301 error (fmt, type, "endfor", l, c); |
|
1302 break; |
777
|
1303 |
496
|
1304 case token::function_end: |
|
1305 error (fmt, type, "endfunction", l, c); |
|
1306 break; |
777
|
1307 |
496
|
1308 case token::if_end: |
|
1309 error (fmt, type, "endif", l, c); |
|
1310 break; |
777
|
1311 |
496
|
1312 case token::while_end: |
|
1313 error (fmt, type, "endwhile", l, c); |
|
1314 break; |
777
|
1315 |
1371
|
1316 case token::unwind_protect_end: |
|
1317 error (fmt, type, "end_unwind_protect", l, c); |
|
1318 break; |
|
1319 |
496
|
1320 default: |
|
1321 panic_impossible (); |
|
1322 break; |
|
1323 } |
|
1324 } |
|
1325 |
666
|
1326 // Check to see that end tokens are properly matched. |
|
1327 |
2857
|
1328 static bool |
|
1329 end_token_ok (token *tok, token::end_tok_type expected) |
143
|
1330 { |
2857
|
1331 bool retval = true; |
|
1332 |
143
|
1333 token::end_tok_type ettype = tok->ettype (); |
2857
|
1334 |
143
|
1335 if (ettype != expected && ettype != token::simple_end) |
|
1336 { |
2857
|
1337 retval = false; |
|
1338 |
143
|
1339 yyerror ("parse error"); |
|
1340 |
|
1341 int l = tok->line (); |
|
1342 int c = tok->column (); |
|
1343 |
|
1344 switch (expected) |
|
1345 { |
|
1346 case token::for_end: |
|
1347 end_error ("for", ettype, l, c); |
|
1348 break; |
777
|
1349 |
143
|
1350 case token::function_end: |
|
1351 end_error ("function", ettype, l, c); |
|
1352 break; |
777
|
1353 |
143
|
1354 case token::if_end: |
|
1355 end_error ("if", ettype, l, c); |
|
1356 break; |
777
|
1357 |
1489
|
1358 case token::try_catch_end: |
|
1359 end_error ("try", ettype, l, c); |
|
1360 break; |
|
1361 |
2764
|
1362 case token::switch_end: |
|
1363 end_error ("switch", ettype, l, c); |
|
1364 break; |
|
1365 |
1489
|
1366 case token::unwind_protect_end: |
|
1367 end_error ("unwind_protect", ettype, l, c); |
|
1368 break; |
|
1369 |
143
|
1370 case token::while_end: |
|
1371 end_error ("while", ettype, l, c); |
|
1372 break; |
777
|
1373 |
143
|
1374 default: |
|
1375 panic_impossible (); |
|
1376 break; |
|
1377 } |
|
1378 } |
2857
|
1379 |
|
1380 return retval; |
143
|
1381 } |
|
1382 |
666
|
1383 // Try to figure out early if an expression should become an |
1623
|
1384 // assignment to the built-in variable ans. |
666
|
1385 // |
2375
|
1386 // Need to make sure that the expression is not already an identifier |
666
|
1387 // that has a name, or an assignment expression. |
|
1388 // |
2375
|
1389 // Note that an expression can not be just an identifier now -- it |
666
|
1390 // must at least be an index expression (see the definition of the |
2375
|
1391 // non-terminal variable above). |
666
|
1392 |
496
|
1393 static tree_expression * |
|
1394 maybe_convert_to_ans_assign (tree_expression *expr) |
1
|
1395 { |
|
1396 if (expr->is_index_expression ()) |
|
1397 { |
195
|
1398 expr->mark_for_possible_ans_assign (); |
|
1399 return expr; |
|
1400 } |
|
1401 else if (expr->is_assignment_expression () |
|
1402 || expr->is_prefix_expression ()) |
|
1403 { |
|
1404 return expr; |
|
1405 } |
|
1406 else |
|
1407 { |
1266
|
1408 // XXX FIXME XXX -- making ans_id static, passing its address to |
|
1409 // tree_simple_assignment_expression along with a flag to not |
|
1410 // delete it seems to create a memory leak. Hmm. |
|
1411 |
2856
|
1412 static symbol_record *sr = global_sym_tab->lookup ("ans", true); |
1266
|
1413 tree_identifier *ans_id = new tree_identifier (sr); |
1
|
1414 |
1607
|
1415 int l = expr->line (); |
|
1416 int c = expr->column (); |
|
1417 |
|
1418 return new tree_simple_assignment_expression (ans_id, expr, 0, 1, l, c); |
1
|
1419 } |
|
1420 } |
|
1421 |
666
|
1422 // Maybe print a warning if an assignment expression is used as the |
|
1423 // test in a logical expression. |
|
1424 |
496
|
1425 static void |
|
1426 maybe_warn_assign_as_truth_value (tree_expression *expr) |
1
|
1427 { |
2166
|
1428 if (Vwarn_assign_as_truth_value |
1
|
1429 && expr->is_assignment_expression () |
2961
|
1430 && expr->paren_count () < 2) |
1
|
1431 { |
|
1432 warning ("suggest parenthesis around assignment used as truth value"); |
|
1433 } |
|
1434 } |
578
|
1435 |
2764
|
1436 // Maybe print a warning about switch labels that aren't constants. |
|
1437 |
|
1438 static void |
|
1439 maybe_warn_variable_switch_label (tree_expression *expr) |
|
1440 { |
|
1441 if (Vwarn_variable_switch_label && ! expr->is_constant ()) |
|
1442 { |
|
1443 warning ("variable switch label"); |
|
1444 } |
|
1445 } |
|
1446 |
1623
|
1447 // Create a plot command. |
|
1448 |
|
1449 static tree_plot_command * |
|
1450 make_plot_command (token *tok, plot_limits *range, subplot_list *list) |
|
1451 { |
|
1452 if (range) |
|
1453 { |
|
1454 if (tok->pttype () == token::replot) |
|
1455 { |
|
1456 yyerror ("cannot specify new ranges with replot"); |
|
1457 return 0; |
|
1458 } |
|
1459 } |
|
1460 else if (! list && tok->pttype () != token::replot) |
|
1461 { |
|
1462 yyerror ("must have something to plot"); |
|
1463 return 0; |
|
1464 } |
|
1465 |
2857
|
1466 lexer_flags.plotting = false; |
|
1467 lexer_flags.past_plot_range = false; |
|
1468 lexer_flags.in_plot_range = false; |
|
1469 lexer_flags.in_plot_using = false; |
|
1470 lexer_flags.in_plot_style = false; |
1623
|
1471 |
|
1472 return new tree_plot_command (list, range, tok->pttype ()); |
|
1473 } |
|
1474 |
2533
|
1475 static tree_expression * |
|
1476 fold (tree_binary_expression *e) |
|
1477 { |
|
1478 tree_expression *retval = 0; |
|
1479 |
|
1480 tree_expression *op1 = e->lhs (); |
|
1481 tree_expression *op2 = e->rhs (); |
|
1482 |
|
1483 if (op1->is_constant () && op2->is_constant ()) |
|
1484 { |
2859
|
1485 octave_value tmp = e->eval (); |
2533
|
1486 |
|
1487 if (! error_state) |
|
1488 { |
|
1489 tree_constant *tc_retval = new tree_constant (tmp); |
|
1490 |
|
1491 ostrstream buf; |
|
1492 |
|
1493 tree_print_code tpc (buf); |
|
1494 |
|
1495 e->accept (tpc); |
|
1496 |
|
1497 buf << ends; |
|
1498 |
|
1499 char *s = buf.str (); |
|
1500 |
|
1501 tc_retval->stash_original_text (s); |
|
1502 |
|
1503 delete [] s; |
|
1504 |
|
1505 delete e; |
|
1506 |
|
1507 retval = tc_retval; |
|
1508 } |
|
1509 else |
|
1510 delete e; |
|
1511 } |
|
1512 else |
|
1513 retval = e; |
|
1514 |
|
1515 return retval; |
|
1516 } |
|
1517 |
1623
|
1518 // Finish building a range. |
|
1519 |
|
1520 static tree_expression * |
|
1521 finish_colon_expression (tree_colon_expression *e) |
|
1522 { |
|
1523 tree_expression *retval = 0; |
|
1524 |
2533
|
1525 tree_expression *base = e->base (); |
|
1526 tree_expression *limit = e->limit (); |
|
1527 tree_expression *incr = e->increment (); |
|
1528 |
|
1529 if (base->is_constant () && limit->is_constant () |
|
1530 && (! incr || (incr && incr->is_constant ()))) |
1623
|
1531 { |
2859
|
1532 octave_value tmp = e->eval (); |
1623
|
1533 |
2533
|
1534 if (! error_state) |
|
1535 { |
|
1536 tree_constant *tc_retval = new tree_constant (tmp); |
|
1537 |
|
1538 ostrstream buf; |
|
1539 |
|
1540 tree_print_code tpc (buf); |
|
1541 |
|
1542 e->accept (tpc); |
|
1543 |
|
1544 buf << ends; |
1623
|
1545 |
2533
|
1546 char *s = buf.str (); |
|
1547 |
|
1548 tc_retval->stash_original_text (s); |
|
1549 |
|
1550 delete [] s; |
|
1551 |
|
1552 delete e; |
|
1553 |
|
1554 retval = tc_retval; |
|
1555 } |
|
1556 else |
|
1557 delete e; |
1623
|
1558 } |
|
1559 else |
|
1560 retval = e; |
|
1561 |
|
1562 return retval; |
|
1563 } |
|
1564 |
1607
|
1565 // Make a constant. |
|
1566 |
2375
|
1567 static tree_constant * |
1607
|
1568 make_constant (int op, token *tok_val) |
|
1569 { |
|
1570 int l = tok_val->line (); |
|
1571 int c = tok_val->column (); |
|
1572 |
2375
|
1573 tree_constant *retval; |
1607
|
1574 |
|
1575 switch (op) |
|
1576 { |
|
1577 case NUM: |
2533
|
1578 { |
2883
|
1579 octave_value tmp (tok_val->number ()); |
|
1580 retval = new tree_constant (tmp, l, c); |
2533
|
1581 retval->stash_original_text (tok_val->text_rep ()); |
|
1582 } |
1607
|
1583 break; |
|
1584 |
|
1585 case IMAG_NUM: |
|
1586 { |
2883
|
1587 octave_value tmp (Complex (0.0, tok_val->number ())); |
|
1588 retval = new tree_constant (tmp, l, c); |
1607
|
1589 retval->stash_original_text (tok_val->text_rep ()); |
|
1590 } |
|
1591 break; |
|
1592 |
|
1593 case TEXT: |
2883
|
1594 { |
|
1595 octave_value tmp (tok_val->text ()); |
|
1596 retval = new tree_constant (tmp, l, c); |
|
1597 } |
1607
|
1598 break; |
|
1599 |
|
1600 default: |
|
1601 panic_impossible (); |
|
1602 break; |
|
1603 } |
|
1604 |
|
1605 return retval; |
|
1606 } |
|
1607 |
666
|
1608 // Build a binary expression. |
|
1609 |
578
|
1610 static tree_expression * |
|
1611 make_binary_op (int op, tree_expression *op1, token *tok_val, |
|
1612 tree_expression *op2) |
|
1613 { |
2883
|
1614 octave_value::binary_op t = octave_value::unknown_binary_op; |
1623
|
1615 |
578
|
1616 switch (op) |
|
1617 { |
|
1618 case POW: |
2883
|
1619 t = octave_value::pow; |
578
|
1620 break; |
777
|
1621 |
578
|
1622 case EPOW: |
2883
|
1623 t = octave_value::el_pow; |
578
|
1624 break; |
777
|
1625 |
578
|
1626 case '+': |
2883
|
1627 t = octave_value::add; |
578
|
1628 break; |
777
|
1629 |
578
|
1630 case '-': |
2883
|
1631 t = octave_value::sub; |
578
|
1632 break; |
777
|
1633 |
578
|
1634 case '*': |
2883
|
1635 t = octave_value::mul; |
578
|
1636 break; |
777
|
1637 |
578
|
1638 case '/': |
2883
|
1639 t = octave_value::div; |
578
|
1640 break; |
777
|
1641 |
578
|
1642 case EMUL: |
2883
|
1643 t = octave_value::el_mul; |
578
|
1644 break; |
777
|
1645 |
578
|
1646 case EDIV: |
2883
|
1647 t = octave_value::el_div; |
578
|
1648 break; |
777
|
1649 |
578
|
1650 case LEFTDIV: |
2883
|
1651 t = octave_value::ldiv; |
578
|
1652 break; |
777
|
1653 |
578
|
1654 case ELEFTDIV: |
2883
|
1655 t = octave_value::el_ldiv; |
578
|
1656 break; |
777
|
1657 |
2899
|
1658 case LSHIFT: |
|
1659 t = octave_value::lshift; |
|
1660 break; |
|
1661 |
|
1662 case RSHIFT: |
|
1663 t = octave_value::rshift; |
|
1664 break; |
|
1665 |
578
|
1666 case EXPR_LT: |
2883
|
1667 t = octave_value::lt; |
578
|
1668 break; |
777
|
1669 |
578
|
1670 case EXPR_LE: |
2883
|
1671 t = octave_value::le; |
578
|
1672 break; |
777
|
1673 |
578
|
1674 case EXPR_EQ: |
2883
|
1675 t = octave_value::eq; |
578
|
1676 break; |
777
|
1677 |
578
|
1678 case EXPR_GE: |
2883
|
1679 t = octave_value::ge; |
578
|
1680 break; |
777
|
1681 |
578
|
1682 case EXPR_GT: |
2883
|
1683 t = octave_value::gt; |
578
|
1684 break; |
777
|
1685 |
578
|
1686 case EXPR_NE: |
2883
|
1687 t = octave_value::ne; |
578
|
1688 break; |
777
|
1689 |
578
|
1690 case EXPR_AND: |
2883
|
1691 t = octave_value::el_and; |
578
|
1692 break; |
777
|
1693 |
578
|
1694 case EXPR_OR: |
2883
|
1695 t = octave_value::el_or; |
578
|
1696 break; |
777
|
1697 |
578
|
1698 default: |
|
1699 panic_impossible (); |
|
1700 break; |
|
1701 } |
|
1702 |
|
1703 int l = tok_val->line (); |
|
1704 int c = tok_val->column (); |
|
1705 |
2533
|
1706 tree_binary_expression *e |
|
1707 = new tree_binary_expression (op1, op2, l, c, t); |
1623
|
1708 |
2533
|
1709 return fold (e); |
578
|
1710 } |
|
1711 |
2375
|
1712 // Build a boolean expression. |
666
|
1713 |
578
|
1714 static tree_expression * |
2375
|
1715 make_boolean_op (int op, tree_expression *op1, token *tok_val, |
|
1716 tree_expression *op2) |
578
|
1717 { |
2375
|
1718 tree_boolean_expression::type t; |
|
1719 |
578
|
1720 switch (op) |
|
1721 { |
2375
|
1722 case EXPR_AND_AND: |
2805
|
1723 t = tree_boolean_expression::bool_and; |
578
|
1724 break; |
777
|
1725 |
2375
|
1726 case EXPR_OR_OR: |
2805
|
1727 t = tree_boolean_expression::bool_or; |
578
|
1728 break; |
777
|
1729 |
578
|
1730 default: |
|
1731 panic_impossible (); |
|
1732 break; |
|
1733 } |
|
1734 |
|
1735 int l = tok_val->line (); |
|
1736 int c = tok_val->column (); |
|
1737 |
2533
|
1738 tree_boolean_expression *e |
|
1739 = new tree_boolean_expression (op1, op2, l, c, t); |
2375
|
1740 |
2533
|
1741 return fold (e); |
578
|
1742 } |
|
1743 |
2375
|
1744 // Build a prefix expression. |
666
|
1745 |
578
|
1746 static tree_expression * |
2960
|
1747 make_prefix_op (int op, tree_expression *op1, token *tok_val) |
578
|
1748 { |
2375
|
1749 tree_prefix_expression::type t; |
|
1750 |
578
|
1751 switch (op) |
|
1752 { |
2960
|
1753 case EXPR_NOT: |
|
1754 t = tree_prefix_expression::unot; |
|
1755 break; |
|
1756 |
|
1757 case '-': |
|
1758 t = tree_prefix_expression::uminus; |
|
1759 break; |
|
1760 |
578
|
1761 case PLUS_PLUS: |
2375
|
1762 t = tree_prefix_expression::increment; |
578
|
1763 break; |
777
|
1764 |
578
|
1765 case MINUS_MINUS: |
2375
|
1766 t = tree_prefix_expression::decrement; |
578
|
1767 break; |
777
|
1768 |
578
|
1769 default: |
|
1770 panic_impossible (); |
|
1771 break; |
|
1772 } |
|
1773 |
|
1774 int l = tok_val->line (); |
|
1775 int c = tok_val->column (); |
|
1776 |
2960
|
1777 return new tree_prefix_expression (t, op1, l, c); |
578
|
1778 } |
|
1779 |
2375
|
1780 // Build a postfix expression. |
666
|
1781 |
578
|
1782 static tree_expression * |
2960
|
1783 make_postfix_op (int op, tree_expression *op1, token *tok_val) |
578
|
1784 { |
2375
|
1785 tree_postfix_expression::type t; |
1623
|
1786 |
578
|
1787 switch (op) |
|
1788 { |
2960
|
1789 case QUOTE: |
|
1790 t = tree_postfix_expression::hermitian; |
|
1791 break; |
|
1792 |
|
1793 case TRANSPOSE: |
|
1794 t = tree_postfix_expression::transpose; |
|
1795 break; |
|
1796 |
2375
|
1797 case PLUS_PLUS: |
|
1798 t = tree_postfix_expression::increment; |
578
|
1799 break; |
777
|
1800 |
2375
|
1801 case MINUS_MINUS: |
|
1802 t = tree_postfix_expression::decrement; |
578
|
1803 break; |
777
|
1804 |
578
|
1805 default: |
|
1806 panic_impossible (); |
|
1807 break; |
|
1808 } |
|
1809 |
|
1810 int l = tok_val->line (); |
|
1811 int c = tok_val->column (); |
|
1812 |
2960
|
1813 return new tree_postfix_expression (t, op1, l, c); |
1623
|
1814 } |
|
1815 |
|
1816 // Build an unwind-protect command. |
|
1817 |
|
1818 static tree_command * |
|
1819 make_unwind_command (token *unwind_tok, tree_statement_list *body, |
|
1820 tree_statement_list *cleanup, token *end_tok) |
|
1821 { |
|
1822 tree_command *retval = 0; |
|
1823 |
2857
|
1824 if (end_token_ok (end_tok, token::unwind_protect_end)) |
1623
|
1825 { |
|
1826 int l = unwind_tok->line (); |
|
1827 int c = unwind_tok->column (); |
|
1828 |
|
1829 retval = new tree_unwind_protect_command (body, cleanup, l, c); |
|
1830 } |
|
1831 |
|
1832 return retval; |
|
1833 } |
|
1834 |
|
1835 // Build a try-catch command. |
|
1836 |
|
1837 static tree_command * |
|
1838 make_try_command (token *try_tok, tree_statement_list *body, |
|
1839 tree_statement_list *cleanup, token *end_tok) |
|
1840 { |
|
1841 tree_command *retval = 0; |
|
1842 |
2857
|
1843 if (end_token_ok (end_tok, token::try_catch_end)) |
1623
|
1844 { |
|
1845 int l = try_tok->line (); |
|
1846 int c = try_tok->column (); |
|
1847 |
|
1848 retval = new tree_try_catch_command (body, cleanup, l, c); |
|
1849 } |
|
1850 |
|
1851 return retval; |
|
1852 } |
|
1853 |
|
1854 // Build a while command. |
|
1855 |
|
1856 static tree_command * |
|
1857 make_while_command (token *while_tok, tree_expression *expr, |
|
1858 tree_statement_list *body, token *end_tok) |
|
1859 { |
|
1860 tree_command *retval = 0; |
|
1861 |
|
1862 maybe_warn_assign_as_truth_value (expr); |
|
1863 |
2857
|
1864 if (end_token_ok (end_tok, token::while_end)) |
1623
|
1865 { |
1826
|
1866 lexer_flags.looping--; |
1623
|
1867 |
|
1868 int l = while_tok->line (); |
|
1869 int c = while_tok->column (); |
|
1870 |
|
1871 retval = new tree_while_command (expr, body, l, c); |
|
1872 } |
|
1873 |
|
1874 return retval; |
|
1875 } |
|
1876 |
|
1877 // Build a for command. |
|
1878 |
|
1879 static tree_command * |
|
1880 make_for_command (token *for_tok, tree_index_expression *var, |
|
1881 tree_expression *expr, tree_statement_list *body, |
|
1882 token *end_tok) |
|
1883 { |
|
1884 tree_command *retval = 0; |
|
1885 |
2857
|
1886 if (end_token_ok (end_tok, token::for_end)) |
1623
|
1887 { |
1826
|
1888 lexer_flags.looping--; |
1623
|
1889 |
|
1890 int l = for_tok->line (); |
|
1891 int c = for_tok->column (); |
|
1892 |
|
1893 retval = new tree_for_command (var, expr, body, l, c); |
|
1894 } |
|
1895 |
|
1896 return retval; |
|
1897 } |
|
1898 |
|
1899 // Build a for command a different way. |
|
1900 |
|
1901 static tree_command * |
1829
|
1902 make_for_command (token *for_tok, tree_matrix_row *mr, |
|
1903 tree_expression *expr, tree_statement_list *body, |
|
1904 token *end_tok) |
1623
|
1905 { |
|
1906 tree_command *retval = 0; |
|
1907 |
2857
|
1908 if (end_token_ok (end_tok, token::for_end)) |
1623
|
1909 { |
1826
|
1910 lexer_flags.looping--; |
1623
|
1911 |
1829
|
1912 tree_return_list *id_list = mr->to_return_list (); |
1623
|
1913 |
|
1914 int l = for_tok->line (); |
|
1915 int c = for_tok->column (); |
|
1916 |
|
1917 retval = new tree_for_command (id_list, expr, body, l, c); |
|
1918 } |
|
1919 |
|
1920 return retval; |
|
1921 } |
|
1922 |
|
1923 // Build a break command. |
|
1924 |
|
1925 static tree_command * |
|
1926 make_break_command (token *break_tok) |
|
1927 { |
|
1928 tree_command *retval = 0; |
|
1929 |
2620
|
1930 int l = break_tok->line (); |
|
1931 int c = break_tok->column (); |
|
1932 |
|
1933 if (lexer_flags.looping || lexer_flags.defining_func || reading_script_file) |
|
1934 retval = new tree_break_command (l, c); |
1623
|
1935 else |
2620
|
1936 retval = new tree_no_op_command ("break", l, c); |
1623
|
1937 |
|
1938 return retval; |
|
1939 } |
|
1940 |
|
1941 // Build a continue command. |
|
1942 |
|
1943 static tree_command * |
|
1944 make_continue_command (token *continue_tok) |
|
1945 { |
|
1946 tree_command *retval = 0; |
|
1947 |
2620
|
1948 int l = continue_tok->line (); |
|
1949 int c = continue_tok->column (); |
|
1950 |
|
1951 if (lexer_flags.looping) |
|
1952 retval = new tree_continue_command (l, c); |
1623
|
1953 else |
2620
|
1954 retval = new tree_no_op_command ("continue", l, c); |
1623
|
1955 |
|
1956 return retval; |
|
1957 } |
|
1958 |
|
1959 // Build a return command. |
|
1960 |
|
1961 static tree_command * |
|
1962 make_return_command (token *return_tok) |
|
1963 { |
|
1964 tree_command *retval = 0; |
|
1965 |
2620
|
1966 int l = return_tok->line (); |
|
1967 int c = return_tok->column (); |
|
1968 |
|
1969 if (lexer_flags.defining_func || reading_script_file) |
|
1970 retval = new tree_return_command (l, c); |
1623
|
1971 else |
2620
|
1972 retval = new tree_no_op_command ("return", l, c); |
1623
|
1973 |
|
1974 return retval; |
|
1975 } |
|
1976 |
|
1977 // Start an if command. |
|
1978 |
|
1979 static tree_if_command_list * |
|
1980 start_if_command (tree_expression *expr, tree_statement_list *list) |
|
1981 { |
|
1982 maybe_warn_assign_as_truth_value (expr); |
|
1983 |
|
1984 tree_if_clause *t = new tree_if_clause (expr, list); |
|
1985 |
|
1986 return new tree_if_command_list (t); |
|
1987 } |
|
1988 |
|
1989 // Finish an if command. |
|
1990 |
|
1991 static tree_if_command * |
|
1992 finish_if_command (token *if_tok, tree_if_command_list *list, |
|
1993 token *end_tok) |
|
1994 { |
|
1995 tree_if_command *retval = 0; |
|
1996 |
2857
|
1997 if (end_token_ok (end_tok, token::if_end)) |
1623
|
1998 { |
|
1999 int l = if_tok->line (); |
|
2000 int c = if_tok->column (); |
|
2001 |
|
2002 retval = new tree_if_command (list, l, c); |
|
2003 } |
|
2004 |
|
2005 return retval; |
|
2006 } |
|
2007 |
|
2008 // Build an elseif clause. |
|
2009 |
|
2010 static tree_if_clause * |
|
2011 make_elseif_clause (tree_expression *expr, tree_statement_list *list) |
|
2012 { |
|
2013 maybe_warn_assign_as_truth_value (expr); |
|
2014 |
|
2015 return new tree_if_clause (expr, list); |
|
2016 } |
|
2017 |
2764
|
2018 // Finish a switch command. |
|
2019 |
|
2020 static tree_switch_command * |
|
2021 finish_switch_command (token *switch_tok, tree_expression *expr, |
|
2022 tree_switch_case_list *list, token *end_tok) |
|
2023 { |
|
2024 tree_switch_command *retval = 0; |
|
2025 |
2857
|
2026 if (end_token_ok (end_tok, token::switch_end)) |
2764
|
2027 { |
|
2028 int l = switch_tok->line (); |
|
2029 int c = switch_tok->column (); |
|
2030 |
|
2031 retval = new tree_switch_command (expr, list, l, c); |
|
2032 } |
|
2033 |
|
2034 return retval; |
|
2035 } |
|
2036 |
|
2037 // Build a switch case. |
|
2038 |
|
2039 static tree_switch_case * |
|
2040 make_switch_case (tree_expression *expr, tree_statement_list *list) |
|
2041 { |
|
2042 maybe_warn_variable_switch_label (expr); |
|
2043 |
|
2044 return new tree_switch_case (expr, list); |
|
2045 } |
|
2046 |
1623
|
2047 // Build an assignment to a variable. |
|
2048 |
|
2049 static tree_expression * |
2883
|
2050 make_assign_op (int op, tree_index_expression *var, token *eq_tok, |
|
2051 tree_expression *expr) |
1623
|
2052 { |
2883
|
2053 octave_value::assign_op t = octave_value::unknown_assign_op; |
|
2054 |
|
2055 switch (op) |
|
2056 { |
|
2057 case '=': |
|
2058 t = octave_value::asn_eq; |
|
2059 break; |
|
2060 |
|
2061 case ADD_EQ: |
|
2062 t = octave_value::add_eq; |
|
2063 break; |
|
2064 |
|
2065 case SUB_EQ: |
|
2066 t = octave_value::sub_eq; |
|
2067 break; |
|
2068 |
|
2069 case MUL_EQ: |
|
2070 t = octave_value::mul_eq; |
|
2071 break; |
|
2072 |
|
2073 case DIV_EQ: |
|
2074 t = octave_value::div_eq; |
|
2075 break; |
|
2076 |
2899
|
2077 case LSHIFT_EQ: |
|
2078 t = octave_value::lshift_eq; |
|
2079 break; |
|
2080 |
|
2081 case RSHIFT_EQ: |
|
2082 t = octave_value::rshift_eq; |
|
2083 break; |
|
2084 |
2883
|
2085 case EMUL_EQ: |
|
2086 t = octave_value::el_mul_eq; |
|
2087 break; |
|
2088 |
|
2089 case EDIV_EQ: |
|
2090 t = octave_value::el_div_eq; |
|
2091 break; |
|
2092 |
|
2093 case AND_EQ: |
|
2094 t = octave_value::el_and_eq; |
|
2095 break; |
|
2096 |
|
2097 case OR_EQ: |
|
2098 t = octave_value::el_or_eq; |
|
2099 break; |
|
2100 |
|
2101 default: |
|
2102 panic_impossible (); |
|
2103 break; |
|
2104 } |
|
2105 |
1623
|
2106 int l = eq_tok->line (); |
|
2107 int c = eq_tok->column (); |
|
2108 |
2883
|
2109 return new tree_simple_assignment_expression (var, expr, 0, 0, l, c, t); |
578
|
2110 } |
666
|
2111 |
|
2112 // Make an expression that handles assignment of multiple values. |
|
2113 |
|
2114 static tree_expression * |
1829
|
2115 make_multi_val_ret (tree_matrix_row *mr, tree_expression *rhs, token *eq_tok) |
666
|
2116 { |
|
2117 // Convert the matrix list to a list of identifiers. If that fails, |
|
2118 // we can abort here, without losing anything -- no other possible |
|
2119 // syntax is valid if we've seen the equals sign as the next token |
|
2120 // after the `]'. |
|
2121 |
|
2122 tree_expression *retval = 0; |
|
2123 |
1826
|
2124 lexer_flags.maybe_screwed_again--; |
666
|
2125 |
1829
|
2126 tree_return_list *id_list = mr->to_return_list (); |
666
|
2127 |
|
2128 if (id_list) |
|
2129 { |
|
2130 int list_len = id_list->length (); |
|
2131 |
|
2132 if (list_len == 1) |
|
2133 { |
|
2134 tree_index_expression *lhs = id_list->remove_front (); |
1623
|
2135 |
|
2136 int l = eq_tok->line (); |
|
2137 int c = eq_tok->column (); |
|
2138 |
947
|
2139 retval = new tree_simple_assignment_expression (lhs, rhs, |
|
2140 0, 0, l, c); |
666
|
2141 } |
|
2142 else if (list_len > 1) |
|
2143 { |
|
2144 if (rhs->is_multi_val_ret_expression ()) |
|
2145 { |
|
2146 tree_multi_val_ret *t = (tree_multi_val_ret *) rhs; |
1623
|
2147 |
|
2148 int l = eq_tok->line (); |
|
2149 int c = eq_tok->column (); |
|
2150 |
1229
|
2151 retval = new tree_multi_assignment_expression (id_list, t, |
|
2152 0, l, c); |
666
|
2153 } |
|
2154 else |
1005
|
2155 yyerror ("RHS must be an expression that returns multiple values"); |
666
|
2156 } |
|
2157 else |
|
2158 panic_impossible (); |
|
2159 } |
|
2160 else |
1005
|
2161 yyerror ("invalid identifier list for assignment"); |
666
|
2162 |
|
2163 return retval; |
|
2164 } |
751
|
2165 |
1623
|
2166 // Begin defining a function. |
|
2167 |
2891
|
2168 static octave_user_function * |
|
2169 start_function (tree_parameter_list *param_list, tree_statement_list *body) |
1623
|
2170 { |
|
2171 body->mark_as_function_body (); |
|
2172 |
2891
|
2173 // We'll fill in the return list later. |
|
2174 |
|
2175 octave_user_function *fcn |
|
2176 = new octave_user_function (param_list, 0, body, curr_sym_tab); |
1623
|
2177 |
|
2178 return fcn; |
|
2179 } |
|
2180 |
|
2181 // Do most of the work for defining a function. |
|
2182 |
2891
|
2183 static octave_user_function * |
|
2184 frob_function (tree_identifier *id, octave_user_function *fcn) |
1623
|
2185 { |
1755
|
2186 string id_name = id->name (); |
1623
|
2187 |
|
2188 // If input is coming from a file, issue a warning if the name of |
|
2189 // the file does not match the name of the function stated in the |
|
2190 // file. Matlab doesn't provide a diagnostic (it ignores the stated |
|
2191 // name). |
|
2192 |
|
2193 fcn->stash_function_name (id_name); |
|
2194 |
|
2195 if (reading_fcn_file) |
|
2196 { |
1755
|
2197 if (curr_fcn_file_name != id_name) |
1623
|
2198 { |
2166
|
2199 if (Vwarn_function_name_clash) |
1623
|
2200 warning ("function name `%s' does not agree with function\ |
1755
|
2201 file name `%s'", id_name.c_str (), curr_fcn_file_full_name.c_str ()); |
1623
|
2202 |
|
2203 global_sym_tab->rename (id_name, curr_fcn_file_name); |
|
2204 |
|
2205 if (error_state) |
|
2206 return 0; |
|
2207 |
|
2208 id_name = id->name (); |
|
2209 } |
|
2210 |
|
2211 fcn->stash_function_name (id_name); |
|
2212 fcn->stash_fcn_file_name (); |
|
2213 fcn->stash_fcn_file_time (time (0)); |
|
2214 fcn->mark_as_system_fcn_file (); |
|
2215 } |
|
2216 else if (! (input_from_tmp_history_file || input_from_startup_file) |
|
2217 && reading_script_file |
1755
|
2218 && curr_fcn_file_name == id_name) |
1623
|
2219 { |
|
2220 warning ("function `%s' defined within script file `%s'", |
1755
|
2221 id_name.c_str (), curr_fcn_file_full_name.c_str ()); |
1623
|
2222 } |
|
2223 |
|
2224 top_level_sym_tab->clear (id_name); |
|
2225 |
2856
|
2226 symbol_record *sr = global_sym_tab->lookup (id_name); |
2791
|
2227 |
|
2228 if (sr) |
|
2229 fcn->stash_symtab_ptr (sr); |
|
2230 else |
|
2231 panic_impossible (); |
|
2232 |
2891
|
2233 id->define (fcn, symbol_def::USER_FUNCTION); |
1755
|
2234 |
1623
|
2235 id->document (help_buf); |
|
2236 |
|
2237 return fcn; |
|
2238 } |
|
2239 |
|
2240 // Finish defining a function. |
|
2241 |
2891
|
2242 static octave_user_function * |
|
2243 finish_function (tree_identifier *id, octave_user_function *fcn) |
1623
|
2244 { |
2883
|
2245 tree_parameter_list *tpl = new tree_parameter_list (id); |
1623
|
2246 |
|
2247 tpl->mark_as_formal_parameters (); |
|
2248 |
|
2249 return fcn->define_ret_list (tpl); |
|
2250 } |
|
2251 |
|
2252 // Finish defining a function a different way. |
|
2253 |
2891
|
2254 static octave_user_function * |
|
2255 finish_function (tree_parameter_list *ret_list, octave_user_function *fcn) |
1623
|
2256 { |
|
2257 ret_list->mark_as_formal_parameters (); |
|
2258 |
|
2259 return fcn->define_ret_list (ret_list); |
|
2260 } |
|
2261 |
2883
|
2262 static void |
|
2263 recover_from_parsing_function (void) |
|
2264 { |
|
2265 curr_sym_tab = top_level_sym_tab; |
|
2266 |
|
2267 lexer_flags.defining_func = false; |
|
2268 lexer_flags.beginning_of_function = false; |
|
2269 lexer_flags.parsed_function_name = false; |
|
2270 lexer_flags.looking_at_return_list = false; |
|
2271 lexer_flags.looking_at_parameter_list = false; |
|
2272 } |
|
2273 |
2846
|
2274 // Make an index expression. |
|
2275 |
751
|
2276 static tree_index_expression * |
|
2277 make_index_expression (tree_indirect_ref *indir, tree_argument_list *args) |
|
2278 { |
|
2279 tree_index_expression *retval = 0; |
|
2280 |
|
2281 int l = indir->line (); |
|
2282 int c = indir->column (); |
|
2283 |
|
2284 if (indir->is_identifier_only ()) |
|
2285 { |
|
2286 indir->preserve_identifier (); |
|
2287 retval = new tree_index_expression (indir->ident (), args, l, c); |
|
2288 delete indir; |
|
2289 } |
|
2290 else |
|
2291 retval = new tree_index_expression (indir, args, l, c); |
|
2292 |
|
2293 return retval; |
|
2294 } |
1511
|
2295 |
2846
|
2296 // Make a declaration command. |
|
2297 |
|
2298 static tree_decl_command * |
|
2299 make_decl_command (int tok, token *tok_val, tree_decl_init_list *lst) |
|
2300 { |
|
2301 tree_decl_command *retval = 0; |
|
2302 |
|
2303 int l = tok_val->line (); |
|
2304 int c = tok_val->column (); |
|
2305 |
|
2306 switch (tok) |
|
2307 { |
|
2308 case GLOBAL: |
|
2309 retval = new tree_global_command (lst, l, c); |
|
2310 break; |
|
2311 |
|
2312 case STATIC: |
|
2313 if (lexer_flags.defining_func) |
|
2314 retval = new tree_static_command (lst, l, c); |
|
2315 else |
|
2316 { |
|
2317 if (reading_script_file) |
|
2318 warning ("ignoring static declaration near line %d of file `%s'", |
|
2319 l, curr_fcn_file_full_name.c_str ()); |
|
2320 else |
|
2321 warning ("ignoring static declaration near line %d", l); |
|
2322 } |
|
2323 break; |
|
2324 |
|
2325 default: |
|
2326 panic_impossible (); |
|
2327 break; |
|
2328 } |
|
2329 |
|
2330 return retval; |
|
2331 } |
|
2332 |
1623
|
2333 // Finish building a matrix list. |
|
2334 |
|
2335 static tree_expression * |
1829
|
2336 finish_matrix (tree_matrix *m) |
1623
|
2337 { |
|
2338 tree_expression *retval = 0; |
|
2339 |
1826
|
2340 lexer_flags.maybe_screwed_again--; |
1623
|
2341 |
2533
|
2342 if (m->all_elements_are_constant ()) |
1829
|
2343 { |
2859
|
2344 octave_value tmp = m->eval (); |
1623
|
2345 |
2533
|
2346 if (! error_state) |
|
2347 { |
|
2348 tree_constant *tc_retval = new tree_constant (tmp); |
|
2349 |
|
2350 ostrstream buf; |
|
2351 |
|
2352 tree_print_code tpc (buf); |
|
2353 |
|
2354 m->accept (tpc); |
|
2355 |
|
2356 buf << ends; |
1623
|
2357 |
2533
|
2358 char *s = buf.str (); |
|
2359 |
|
2360 tc_retval->stash_original_text (s); |
|
2361 |
|
2362 delete [] s; |
|
2363 |
|
2364 delete m; |
|
2365 |
|
2366 retval = tc_retval; |
|
2367 } |
|
2368 else |
|
2369 delete m; |
1623
|
2370 } |
|
2371 else |
1829
|
2372 retval = m; |
1623
|
2373 |
|
2374 return retval; |
|
2375 } |
|
2376 |
1511
|
2377 static void |
|
2378 maybe_warn_missing_semi (tree_statement_list *t) |
|
2379 { |
2166
|
2380 if (lexer_flags.defining_func && Vwarn_missing_semicolon) |
1511
|
2381 { |
|
2382 tree_statement *tmp = t->rear(); |
1607
|
2383 |
1511
|
2384 if (tmp->is_expression ()) |
1607
|
2385 warning ("missing semicolon near line %d, column %d in file `%s'", |
1755
|
2386 tmp->line (), tmp->column (), |
|
2387 curr_fcn_file_full_name.c_str ()); |
1511
|
2388 } |
|
2389 } |
1994
|
2390 |
2525
|
2391 static void |
|
2392 set_stmt_print_flag (tree_statement_list *list, char sep, |
|
2393 bool warn_missing_semi) |
|
2394 { |
|
2395 switch (sep) |
|
2396 { |
|
2397 case ';': |
|
2398 { |
|
2399 tree_statement *tmp = list->rear (); |
|
2400 tmp->set_print_flag (0); |
|
2401 } |
|
2402 break; |
|
2403 |
|
2404 case 0: |
|
2405 case ',': |
|
2406 case '\n': |
|
2407 if (warn_missing_semi) |
|
2408 maybe_warn_missing_semi (list); |
|
2409 break; |
|
2410 |
|
2411 default: |
|
2412 warning ("unrecognized separator type!"); |
|
2413 break; |
|
2414 } |
|
2415 } |
|
2416 |
2166
|
2417 static int |
|
2418 warn_assign_as_truth_value (void) |
|
2419 { |
|
2420 Vwarn_assign_as_truth_value |
|
2421 = check_preference ("warn_assign_as_truth_value"); |
|
2422 |
|
2423 return 0; |
|
2424 } |
|
2425 |
|
2426 static int |
|
2427 warn_function_name_clash (void) |
|
2428 { |
|
2429 Vwarn_function_name_clash = check_preference ("warn_function_name_clash"); |
|
2430 |
|
2431 return 0; |
|
2432 } |
|
2433 |
|
2434 static int |
|
2435 warn_missing_semicolon (void) |
|
2436 { |
|
2437 Vwarn_missing_semicolon = check_preference ("warn_missing_semicolon"); |
|
2438 |
|
2439 return 0; |
|
2440 } |
|
2441 |
2764
|
2442 static int |
|
2443 warn_variable_switch_label (void) |
|
2444 { |
|
2445 Vwarn_variable_switch_label |
|
2446 = check_preference ("warn_variable_switch_label"); |
|
2447 |
|
2448 return 0; |
|
2449 } |
|
2450 |
2166
|
2451 void |
|
2452 symbols_of_parse (void) |
|
2453 { |
|
2454 DEFVAR (warn_assign_as_truth_value, 1.0, 0, warn_assign_as_truth_value, |
|
2455 "produce warning for assignments used as truth values"); |
|
2456 |
|
2457 DEFVAR (warn_function_name_clash, 1.0, 0, warn_function_name_clash, |
|
2458 "produce warning if function name conflicts with file name"); |
|
2459 |
|
2460 DEFVAR (warn_missing_semicolon, 0.0, 0, warn_missing_semicolon, |
2764
|
2461 "produce a warning if a statement in a function file is not\n\ |
2166
|
2462 terminated with a semicolon"); |
2764
|
2463 |
|
2464 DEFVAR (warn_variable_switch_label, 0.0, 0, warn_variable_switch_label, |
|
2465 "produce warning for variables used as switch labels"); |
2166
|
2466 } |
|
2467 |
1994
|
2468 /* |
|
2469 ;;; Local Variables: *** |
|
2470 ;;; mode: text *** |
|
2471 ;;; End: *** |
|
2472 */ |