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