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