Mercurial > octave
comparison src/parse.y @ 3165:e4bbfc196e53
[project @ 1998-04-16 03:01:47 by jwe]
author | jwe |
---|---|
date | Thu, 16 Apr 1998 03:05:03 +0000 |
parents | 7c96e85c76db |
children | 09a3064a3a17 |
comparison
equal
deleted
inserted
replaced
3164:45490c020e47 | 3165:e4bbfc196e53 |
---|---|
322 subplot_list *subplot_list_type; | 322 subplot_list *subplot_list_type; |
323 plot_limits *plot_limits_type; | 323 plot_limits *plot_limits_type; |
324 plot_range *plot_range_type; | 324 plot_range *plot_range_type; |
325 subplot_using *subplot_using_type; | 325 subplot_using *subplot_using_type; |
326 subplot_style *subplot_style_type; | 326 subplot_style *subplot_style_type; |
327 subplot_axes *subplot_axes_type; | |
327 octave_user_function *octave_user_function_type; | 328 octave_user_function *octave_user_function_type; |
328 } | 329 } |
329 | 330 |
330 // Tokens with line and column information. | 331 // Tokens with line and column information. |
331 %token <tok_val> '=' ':' '-' '+' '*' '/' | 332 %token <tok_val> '=' ':' '-' '+' '*' '/' |
340 %token <tok_val> NUM IMAG_NUM | 341 %token <tok_val> NUM IMAG_NUM |
341 %token <tok_val> STRUCT_ELT | 342 %token <tok_val> STRUCT_ELT |
342 %token <tok_val> NAME | 343 %token <tok_val> NAME |
343 %token <tok_val> END | 344 %token <tok_val> END |
344 %token <tok_val> PLOT | 345 %token <tok_val> PLOT |
345 %token <tok_val> TEXT STYLE | 346 %token <tok_val> TEXT STYLE AXES_TAG |
346 %token <tok_val> FOR WHILE | 347 %token <tok_val> FOR WHILE |
347 %token <tok_val> IF ELSEIF ELSE | 348 %token <tok_val> IF ELSEIF ELSE |
348 %token <tok_val> SWITCH CASE OTHERWISE | 349 %token <tok_val> SWITCH CASE OTHERWISE |
349 %token <tok_val> BREAK CONTINUE FUNC_RET | 350 %token <tok_val> BREAK CONTINUE FUNC_RET |
350 %token <tok_val> UNWIND CLEANUP | 351 %token <tok_val> UNWIND CLEANUP |
352 %token <tok_val> GLOBAL STATIC | 353 %token <tok_val> GLOBAL STATIC |
353 | 354 |
354 // Other tokens. | 355 // Other tokens. |
355 %token END_OF_INPUT LEXICAL_ERROR | 356 %token END_OF_INPUT LEXICAL_ERROR |
356 %token FCN ELLIPSIS ALL_VA_ARGS | 357 %token FCN ELLIPSIS ALL_VA_ARGS |
357 %token USING TITLE WITH COLON OPEN_BRACE CLOSE_BRACE CLEAR | 358 %token USING TITLE WITH AXES COLON OPEN_BRACE CLOSE_BRACE CLEAR |
358 | 359 |
359 // Nonterminals we construct. | 360 // Nonterminals we construct. |
360 %type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep | 361 %type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep |
361 %type <tree_type> input | 362 %type <tree_type> input |
362 %type <tree_constant_type> constant magic_colon | 363 %type <tree_constant_type> constant magic_colon |
390 %type <subplot_list_type> plot_command1 | 391 %type <subplot_list_type> plot_command1 |
391 %type <plot_limits_type> ranges | 392 %type <plot_limits_type> ranges |
392 %type <plot_range_type> ranges1 | 393 %type <plot_range_type> ranges1 |
393 %type <subplot_using_type> using using1 | 394 %type <subplot_using_type> using using1 |
394 %type <subplot_style_type> style | 395 %type <subplot_style_type> style |
396 %type <subplot_axes_type> axes | |
395 | 397 |
396 // Precedence and associativity. | 398 // Precedence and associativity. |
397 %left ';' ',' '\n' | 399 %left ';' ',' '\n' |
398 %right '=' ADD_EQ SUB_EQ MUL_EQ DIV_EQ EMUL_EQ EDIV_EQ OR_EQ AND_EQ LSHIFT_EQ RSHIFT_EQ | 400 %right '=' ADD_EQ SUB_EQ MUL_EQ DIV_EQ EMUL_EQ EDIV_EQ OR_EQ AND_EQ LSHIFT_EQ RSHIFT_EQ |
399 %left EXPR_AND_AND EXPR_OR_OR | 401 %left EXPR_AND_AND EXPR_OR_OR |
1175 ; | 1177 ; |
1176 | 1178 |
1177 plot_command2 : expression | 1179 plot_command2 : expression |
1178 { $$ = new subplot ($1); } | 1180 { $$ = new subplot ($1); } |
1179 | expression plot_options | 1181 | expression plot_options |
1180 { $$ = $2->set_data ($1); } | 1182 { $$ = $2->add_data ($1); } |
1181 ; | 1183 ; |
1182 | 1184 |
1183 plot_options : using | 1185 plot_options : using |
1184 { $$ = new subplot ($1, 0, 0); } | 1186 { |
1187 subplot *tmp = new subplot (); | |
1188 $$ = tmp->add_clause ($1); | |
1189 } | |
1185 | title | 1190 | title |
1186 { $$ = new subplot (0, $1, 0); } | 1191 { |
1192 subplot *tmp = new subplot (); | |
1193 $$ = tmp->add_clause ($1); | |
1194 } | |
1187 | style | 1195 | style |
1188 { $$ = new subplot (0, 0, $1); } | 1196 { |
1189 | using title | 1197 subplot *tmp = new subplot (); |
1190 { $$ = new subplot ($1, $2, 0); } | 1198 $$ = tmp->add_clause ($1); |
1191 | title using | 1199 } |
1192 { $$ = new subplot ($2, $1, 0); } | 1200 | axes |
1193 | using style | 1201 { |
1194 { $$ = new subplot ($1, 0, $2); } | 1202 subplot *tmp = new subplot (); |
1195 | style using | 1203 $$ = tmp->add_clause ($1); |
1196 { $$ = new subplot ($2, 0, $1); } | 1204 } |
1197 | title style | 1205 | plot_options using |
1198 { $$ = new subplot (0, $1, $2); } | 1206 { |
1199 | style title | 1207 if (! ($$ = $1->add_clause ($2))) |
1200 { $$ = new subplot (0, $2, $1); } | 1208 { |
1201 | using title style | 1209 yyerror ("only one using option may be specified"); |
1202 { $$ = new subplot ($1, $2, $3); } | 1210 ABORT_PARSE; |
1203 | using style title | 1211 } |
1204 { $$ = new subplot ($1, $3, $2); } | 1212 } |
1205 | title using style | 1213 | plot_options title |
1206 { $$ = new subplot ($2, $1, $3); } | 1214 { |
1207 | title style using | 1215 if (! ($$ = $1->add_clause ($2))) |
1208 { $$ = new subplot ($3, $1, $2); } | 1216 { |
1209 | style using title | 1217 yyerror ("only one title option my be specified"); |
1210 { $$ = new subplot ($2, $3, $1); } | 1218 ABORT_PARSE; |
1211 | style title using | 1219 } |
1212 { $$ = new subplot ($3, $2, $1); } | 1220 } |
1221 | plot_options style | |
1222 { | |
1223 if (! ($$ = $1->add_clause ($2))) | |
1224 { | |
1225 yyerror ("only one style option my be specified"); | |
1226 ABORT_PARSE; | |
1227 } | |
1228 } | |
1229 | plot_options axes | |
1230 { | |
1231 if (! ($$ = $1->add_clause ($2))) | |
1232 { | |
1233 yyerror ("only one axes option may be specified"); | |
1234 ABORT_PARSE; | |
1235 } | |
1236 } | |
1237 ; | |
1238 | |
1239 axes : AXES AXES_TAG | |
1240 { | |
1241 lexer_flags.in_plot_axes = false; | |
1242 $$ = new subplot_axes ($2->text ()); | |
1243 } | |
1213 ; | 1244 ; |
1214 | 1245 |
1215 using : using1 | 1246 using : using1 |
1216 { | 1247 { |
1217 lexer_flags.in_plot_using = false; | 1248 lexer_flags.in_plot_using = false; |
2748 { | 2779 { |
2749 command_editor::set_input_stream (static_cast<FILE *> (f)); | 2780 command_editor::set_input_stream (static_cast<FILE *> (f)); |
2750 } | 2781 } |
2751 | 2782 |
2752 static bool | 2783 static bool |
2753 parse_fcn_file (bool exec_script, const string& ff) | 2784 parse_fcn_file (const string& ff, bool exec_script, bool force_script = false) |
2754 { | 2785 { |
2755 unwind_protect::begin_frame ("parse_fcn_file"); | 2786 unwind_protect::begin_frame ("parse_fcn_file"); |
2756 | 2787 |
2757 int script_file_executed = false; | 2788 int script_file_executed = false; |
2758 | 2789 |
2783 if (ffile) | 2814 if (ffile) |
2784 { | 2815 { |
2785 // Check to see if this file defines a function or is just a | 2816 // Check to see if this file defines a function or is just a |
2786 // list of commands. | 2817 // list of commands. |
2787 | 2818 |
2788 if (is_function_file (ffile)) | 2819 if (! force_script && is_function_file (ffile)) |
2789 { | 2820 { |
2790 // XXX FIXME XXX -- we shouldn't need both the | 2821 // XXX FIXME XXX -- we shouldn't need both the |
2791 // command_history object and the | 2822 // command_history object and the |
2792 // Vsaving_history variable... | 2823 // Vsaving_history variable... |
2793 command_history::ignore_entries (); | 2824 command_history::ignore_entries (); |
2884 | 2915 |
2885 curr_fcn_file_name = nm; | 2916 curr_fcn_file_name = nm; |
2886 curr_fcn_file_full_name = ff; | 2917 curr_fcn_file_full_name = ff; |
2887 | 2918 |
2888 if (ff.length () > 0) | 2919 if (ff.length () > 0) |
2889 script_file_executed = parse_fcn_file (exec_script, ff); | 2920 script_file_executed = parse_fcn_file (ff, exec_script); |
2890 | 2921 |
2891 if (! (error_state || script_file_executed)) | 2922 if (! (error_state || script_file_executed)) |
2892 force_link_to_function (nm); | 2923 force_link_to_function (nm); |
2893 | 2924 |
2894 unwind_protect::run_frame ("load_fcn_from_file"); | 2925 unwind_protect::run_frame ("load_fcn_from_file"); |
2913 | 2944 |
2914 if (! error_state) | 2945 if (! error_state) |
2915 { | 2946 { |
2916 file = file_ops::tilde_expand (file); | 2947 file = file_ops::tilde_expand (file); |
2917 | 2948 |
2918 parse_fcn_file (true, file); | 2949 parse_fcn_file (file, true, true); |
2919 | 2950 |
2920 if (error_state) | 2951 if (error_state) |
2921 error ("source: error sourcing file `%s'", file.c_str ()); | 2952 error ("source: error sourcing file `%s'", file.c_str ()); |
2922 } | 2953 } |
2923 else | 2954 else |