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