comparison libinterp/parse-tree/oct-parse.yy @ 16110:7302f8a4df83

use pointer for global lexical_feedback structure * lex.h, lex.ll (curr_lexer): Rename from lexer_flags. Declare as pointer. Change all uses. * lex.h (lexical_feedback): Make copy constructor and operator= private. * toplev.cc (main_loop): Protect existing and initialize new curr_lexer. * input.cc (get_debug_input): Likewise.
author John W. Eaton <jwe@octave.org>
date Tue, 26 Feb 2013 01:10:08 -0500
parents 229eb14653fd
children ea5d92f574e0
comparison
equal deleted inserted replaced
16109:229eb14653fd 16110:7302f8a4df83
554 554
555 input1 : '\n' 555 input1 : '\n'
556 { $$ = 0; } 556 { $$ = 0; }
557 | END_OF_INPUT 557 | END_OF_INPUT
558 { 558 {
559 lexer_flags.parser_end_of_input = 1; 559 curr_lexer->parser_end_of_input = 1;
560 $$ = 0; 560 $$ = 0;
561 } 561 }
562 | simple_list 562 | simple_list
563 { $$ = $1; } 563 { $$ = $1; }
564 | simple_list '\n' 564 | simple_list '\n'
657 ; 657 ;
658 658
659 matrix : '[' ']' 659 matrix : '[' ']'
660 { 660 {
661 $$ = new tree_constant (octave_null_matrix::instance); 661 $$ = new tree_constant (octave_null_matrix::instance);
662 lexer_flags.looking_at_matrix_or_assign_lhs = false; 662 curr_lexer->looking_at_matrix_or_assign_lhs = false;
663 lexer_flags.pending_local_variables.clear (); 663 curr_lexer->pending_local_variables.clear ();
664 } 664 }
665 | '[' ';' ']' 665 | '[' ';' ']'
666 { 666 {
667 $$ = new tree_constant (octave_null_matrix::instance); 667 $$ = new tree_constant (octave_null_matrix::instance);
668 lexer_flags.looking_at_matrix_or_assign_lhs = false; 668 curr_lexer->looking_at_matrix_or_assign_lhs = false;
669 lexer_flags.pending_local_variables.clear (); 669 curr_lexer->pending_local_variables.clear ();
670 } 670 }
671 | '[' ',' ']' 671 | '[' ',' ']'
672 { 672 {
673 $$ = new tree_constant (octave_null_matrix::instance); 673 $$ = new tree_constant (octave_null_matrix::instance);
674 lexer_flags.looking_at_matrix_or_assign_lhs = false; 674 curr_lexer->looking_at_matrix_or_assign_lhs = false;
675 lexer_flags.pending_local_variables.clear (); 675 curr_lexer->pending_local_variables.clear ();
676 } 676 }
677 | '[' matrix_rows ']' 677 | '[' matrix_rows ']'
678 { 678 {
679 $$ = finish_matrix ($2); 679 $$ = finish_matrix ($2);
680 lexer_flags.looking_at_matrix_or_assign_lhs = false; 680 curr_lexer->looking_at_matrix_or_assign_lhs = false;
681 lexer_flags.pending_local_variables.clear (); 681 curr_lexer->pending_local_variables.clear ();
682 } 682 }
683 ; 683 ;
684 684
685 matrix_rows : matrix_rows1 685 matrix_rows : matrix_rows1
686 { $$ = $1; } 686 { $$ = $1; }
728 ; 728 ;
729 729
730 fcn_handle : '@' FCN_HANDLE 730 fcn_handle : '@' FCN_HANDLE
731 { 731 {
732 $$ = make_fcn_handle ($2); 732 $$ = make_fcn_handle ($2);
733 lexer_flags.looking_at_function_handle--; 733 curr_lexer->looking_at_function_handle--;
734 } 734 }
735 ; 735 ;
736 736
737 anon_fcn_handle : '@' param_list statement 737 anon_fcn_handle : '@' param_list statement
738 { 738 {
739 lexer_flags.quote_is_transpose = false; 739 curr_lexer->quote_is_transpose = false;
740 $$ = make_anon_fcn_handle ($2, $3); 740 $$ = make_anon_fcn_handle ($2, $3);
741 } 741 }
742 ; 742 ;
743 743
744 primary_expr : identifier 744 primary_expr : identifier
794 $$ = $1; 794 $$ = $1;
795 } 795 }
796 ; 796 ;
797 797
798 indirect_ref_op : '.' 798 indirect_ref_op : '.'
799 { lexer_flags.looking_at_indirect_ref = true; } 799 { curr_lexer->looking_at_indirect_ref = true; }
800 ; 800 ;
801 801
802 oper_expr : primary_expr 802 oper_expr : primary_expr
803 { $$ = $1; } 803 { $$ = $1; }
804 | oper_expr PLUS_PLUS 804 | oper_expr PLUS_PLUS
907 $$->mark_as_simple_assign_lhs (); 907 $$->mark_as_simple_assign_lhs ();
908 } 908 }
909 | '[' arg_list opt_comma CLOSE_BRACE 909 | '[' arg_list opt_comma CLOSE_BRACE
910 { 910 {
911 $$ = $2; 911 $$ = $2;
912 lexer_flags.looking_at_matrix_or_assign_lhs = false; 912 curr_lexer->looking_at_matrix_or_assign_lhs = false;
913 for (std::set<std::string>::const_iterator p = lexer_flags.pending_local_variables.begin (); 913 for (std::set<std::string>::const_iterator p = curr_lexer->pending_local_variables.begin ();
914 p != lexer_flags.pending_local_variables.end (); 914 p != curr_lexer->pending_local_variables.end ();
915 p++) 915 p++)
916 { 916 {
917 symbol_table::force_variable (*p); 917 symbol_table::force_variable (*p);
918 } 918 }
919 lexer_flags.pending_local_variables.clear (); 919 curr_lexer->pending_local_variables.clear ();
920 } 920 }
921 ; 921 ;
922 922
923 assign_expr : assign_lhs '=' expression 923 assign_expr : assign_lhs '=' expression
924 { $$ = make_assign_op ('=', $1, $2, $3); } 924 { $$ = make_assign_op ('=', $1, $2, $3); }
986 // Declaration statemnts 986 // Declaration statemnts
987 // ===================== 987 // =====================
988 988
989 parsing_decl_list 989 parsing_decl_list
990 : // empty 990 : // empty
991 { lexer_flags.looking_at_decl_list = true; } 991 { curr_lexer->looking_at_decl_list = true; }
992 992
993 declaration : GLOBAL parsing_decl_list decl1 993 declaration : GLOBAL parsing_decl_list decl1
994 { 994 {
995 $$ = make_decl_command (GLOBAL, $1, $3); 995 $$ = make_decl_command (GLOBAL, $1, $3);
996 lexer_flags.looking_at_decl_list = false; 996 curr_lexer->looking_at_decl_list = false;
997 } 997 }
998 | PERSISTENT parsing_decl_list decl1 998 | PERSISTENT parsing_decl_list decl1
999 { 999 {
1000 $$ = make_decl_command (PERSISTENT, $1, $3); 1000 $$ = make_decl_command (PERSISTENT, $1, $3);
1001 lexer_flags.looking_at_decl_list = false; 1001 curr_lexer->looking_at_decl_list = false;
1002 } 1002 }
1003 ; 1003 ;
1004 1004
1005 decl1 : decl2 1005 decl1 : decl2
1006 { $$ = new tree_decl_init_list ($1); } 1006 { $$ = new tree_decl_init_list ($1); }
1010 $$ = $1; 1010 $$ = $1;
1011 } 1011 }
1012 ; 1012 ;
1013 1013
1014 decl_param_init : // empty 1014 decl_param_init : // empty
1015 { lexer_flags.looking_at_initializer_expression = true; } 1015 { curr_lexer->looking_at_initializer_expression = true; }
1016 1016
1017 decl2 : identifier 1017 decl2 : identifier
1018 { $$ = new tree_decl_elt ($1); } 1018 { $$ = new tree_decl_elt ($1); }
1019 | identifier '=' decl_param_init expression 1019 | identifier '=' decl_param_init expression
1020 { 1020 {
1021 lexer_flags.looking_at_initializer_expression = false; 1021 curr_lexer->looking_at_initializer_expression = false;
1022 $$ = new tree_decl_elt ($1, $4); 1022 $$ = new tree_decl_elt ($1, $4);
1023 } 1023 }
1024 | magic_tilde 1024 | magic_tilde
1025 { 1025 {
1026 $$ = new tree_decl_elt ($1); 1026 $$ = new tree_decl_elt ($1);
1241 // List of function parameters 1241 // List of function parameters
1242 // =========================== 1242 // ===========================
1243 1243
1244 param_list_beg : '(' 1244 param_list_beg : '('
1245 { 1245 {
1246 lexer_flags.looking_at_parameter_list = true; 1246 curr_lexer->looking_at_parameter_list = true;
1247 1247
1248 if (lexer_flags.looking_at_function_handle) 1248 if (curr_lexer->looking_at_function_handle)
1249 { 1249 {
1250 parser_symtab_context.push (); 1250 parser_symtab_context.push ();
1251 symbol_table::set_scope (symbol_table::alloc_scope ()); 1251 symbol_table::set_scope (symbol_table::alloc_scope ());
1252 lexer_flags.looking_at_function_handle--; 1252 curr_lexer->looking_at_function_handle--;
1253 lexer_flags.looking_at_anon_fcn_args = true; 1253 curr_lexer->looking_at_anon_fcn_args = true;
1254 } 1254 }
1255 } 1255 }
1256 ; 1256 ;
1257 1257
1258 param_list_end : ')' 1258 param_list_end : ')'
1259 { 1259 {
1260 lexer_flags.looking_at_parameter_list = false; 1260 curr_lexer->looking_at_parameter_list = false;
1261 lexer_flags.looking_for_object_index = false; 1261 curr_lexer->looking_for_object_index = false;
1262 } 1262 }
1263 ; 1263 ;
1264 1264
1265 param_list : param_list_beg param_list1 param_list_end 1265 param_list : param_list_beg param_list1 param_list_end
1266 { 1266 {
1267 lexer_flags.quote_is_transpose = false; 1267 curr_lexer->quote_is_transpose = false;
1268 $$ = $2; 1268 $$ = $2;
1269 } 1269 }
1270 | param_list_beg error 1270 | param_list_beg error
1271 { 1271 {
1272 yyerror ("invalid parameter list"); 1272 yyerror ("invalid parameter list");
1300 // List of function return value names 1300 // List of function return value names
1301 // =================================== 1301 // ===================================
1302 1302
1303 return_list : '[' ']' 1303 return_list : '[' ']'
1304 { 1304 {
1305 lexer_flags.looking_at_return_list = false; 1305 curr_lexer->looking_at_return_list = false;
1306 $$ = new tree_parameter_list (); 1306 $$ = new tree_parameter_list ();
1307 } 1307 }
1308 | return_list1 1308 | return_list1
1309 { 1309 {
1310 lexer_flags.looking_at_return_list = false; 1310 curr_lexer->looking_at_return_list = false;
1311 if ($1->validate (tree_parameter_list::out)) 1311 if ($1->validate (tree_parameter_list::out))
1312 $$ = $1; 1312 $$ = $1;
1313 else 1313 else
1314 ABORT_PARSE; 1314 ABORT_PARSE;
1315 } 1315 }
1316 | '[' return_list1 ']' 1316 | '[' return_list1 ']'
1317 { 1317 {
1318 lexer_flags.looking_at_return_list = false; 1318 curr_lexer->looking_at_return_list = false;
1319 if ($2->validate (tree_parameter_list::out)) 1319 if ($2->validate (tree_parameter_list::out))
1320 $$ = $2; 1320 $$ = $2;
1321 else 1321 else
1322 ABORT_PARSE; 1322 ABORT_PARSE;
1323 } 1323 }
1337 // =========== 1337 // ===========
1338 1338
1339 script_file : SCRIPT_FILE opt_list END_OF_INPUT 1339 script_file : SCRIPT_FILE opt_list END_OF_INPUT
1340 { 1340 {
1341 tree_statement *end_of_script 1341 tree_statement *end_of_script
1342 = make_end ("endscript", lexer_flags.input_line_number, 1342 = make_end ("endscript", curr_lexer->input_line_number,
1343 lexer_flags.current_input_column); 1343 curr_lexer->current_input_column);
1344 1344
1345 make_script ($2, end_of_script); 1345 make_script ($2, end_of_script);
1346 1346
1347 $$ = 0; 1347 $$ = 0;
1348 } 1348 }
1366 1366
1367 function_beg : push_fcn_symtab FCN stash_comment 1367 function_beg : push_fcn_symtab FCN stash_comment
1368 { 1368 {
1369 $$ = $3; 1369 $$ = $3;
1370 1370
1371 if (reading_classdef_file || lexer_flags.parsing_classdef) 1371 if (reading_classdef_file || curr_lexer->parsing_classdef)
1372 lexer_flags.maybe_classdef_get_set_method = true; 1372 curr_lexer->maybe_classdef_get_set_method = true;
1373 } 1373 }
1374 ; 1374 ;
1375 1375
1376 function : function_beg function1 1376 function : function_beg function1
1377 { 1377 {
1387 1387
1388 fcn_name : identifier 1388 fcn_name : identifier
1389 { 1389 {
1390 std::string id_name = $1->name (); 1390 std::string id_name = $1->name ();
1391 1391
1392 lexer_flags.parsed_function_name.top () = true; 1392 curr_lexer->parsed_function_name.top () = true;
1393 lexer_flags.maybe_classdef_get_set_method = false; 1393 curr_lexer->maybe_classdef_get_set_method = false;
1394 1394
1395 $$ = $1; 1395 $$ = $1;
1396 } 1396 }
1397 | GET '.' identifier 1397 | GET '.' identifier
1398 { 1398 {
1399 lexer_flags.parsed_function_name.top () = true; 1399 curr_lexer->parsed_function_name.top () = true;
1400 lexer_flags.maybe_classdef_get_set_method = false; 1400 curr_lexer->maybe_classdef_get_set_method = false;
1401 $$ = $3; 1401 $$ = $3;
1402 } 1402 }
1403 | SET '.' identifier 1403 | SET '.' identifier
1404 { 1404 {
1405 lexer_flags.parsed_function_name.top () = true; 1405 curr_lexer->parsed_function_name.top () = true;
1406 lexer_flags.maybe_classdef_get_set_method = false; 1406 curr_lexer->maybe_classdef_get_set_method = false;
1407 $$ = $3; 1407 $$ = $3;
1408 } 1408 }
1409 ; 1409 ;
1410 1410
1411 function1 : fcn_name function2 1411 function1 : fcn_name function2
1461 { 1461 {
1462 yyerror ("classdef body open at end of input"); 1462 yyerror ("classdef body open at end of input");
1463 YYABORT; 1463 YYABORT;
1464 } 1464 }
1465 1465
1466 $$ = make_end ("endfunction", lexer_flags.input_line_number, 1466 $$ = make_end ("endfunction", curr_lexer->input_line_number,
1467 lexer_flags.current_input_column); 1467 curr_lexer->current_input_column);
1468 } 1468 }
1469 ; 1469 ;
1470 1470
1471 // ======== 1471 // ========
1472 // Classdef 1472 // Classdef
1473 // ======== 1473 // ========
1474 1474
1475 classdef_beg : CLASSDEF stash_comment 1475 classdef_beg : CLASSDEF stash_comment
1476 { 1476 {
1477 $$ = 0; 1477 $$ = 0;
1478 lexer_flags.parsing_classdef = true; 1478 curr_lexer->parsing_classdef = true;
1479 } 1479 }
1480 ; 1480 ;
1481 1481
1482 classdef_end : END 1482 classdef_end : END
1483 { 1483 {
1484 lexer_flags.parsing_classdef = false; 1484 curr_lexer->parsing_classdef = false;
1485 1485
1486 if (end_token_ok ($1, token::classdef_end)) 1486 if (end_token_ok ($1, token::classdef_end))
1487 $$ = make_end ("endclassdef", $1->line (), $1->column ()); 1487 $$ = make_end ("endclassdef", $1->line (), $1->column ());
1488 else 1488 else
1489 ABORT_PARSE; 1489 ABORT_PARSE;
1685 // Generic error messages. 1685 // Generic error messages.
1686 1686
1687 static void 1687 static void
1688 yyerror (const char *s) 1688 yyerror (const char *s)
1689 { 1689 {
1690 int err_col = lexer_flags.current_input_column - 1; 1690 int err_col = curr_lexer->current_input_column - 1;
1691 1691
1692 std::ostringstream output_buf; 1692 std::ostringstream output_buf;
1693 1693
1694 if (reading_fcn_file || reading_script_file || reading_classdef_file) 1694 if (reading_fcn_file || reading_script_file || reading_classdef_file)
1695 output_buf << "parse error near line " << lexer_flags.input_line_number 1695 output_buf << "parse error near line " << curr_lexer->input_line_number
1696 << " of file " << curr_fcn_file_full_name; 1696 << " of file " << curr_fcn_file_full_name;
1697 else 1697 else
1698 output_buf << "parse error:"; 1698 output_buf << "parse error:";
1699 1699
1700 if (s && strcmp (s, "parse error") != 0) 1700 if (s && strcmp (s, "parse error") != 0)
2122 2122
2123 static tree_anon_fcn_handle * 2123 static tree_anon_fcn_handle *
2124 make_anon_fcn_handle (tree_parameter_list *param_list, tree_statement *stmt) 2124 make_anon_fcn_handle (tree_parameter_list *param_list, tree_statement *stmt)
2125 { 2125 {
2126 // FIXME -- need to get these from the location of the @ symbol. 2126 // FIXME -- need to get these from the location of the @ symbol.
2127 int l = lexer_flags.input_line_number; 2127 int l = curr_lexer->input_line_number;
2128 int c = lexer_flags.current_input_column; 2128 int c = curr_lexer->current_input_column;
2129 2129
2130 tree_parameter_list *ret_list = 0; 2130 tree_parameter_list *ret_list = 0;
2131 2131
2132 symbol_table::scope_id fcn_scope = symbol_table::current_scope (); 2132 symbol_table::scope_id fcn_scope = symbol_table::current_scope ();
2133 2133
2428 2428
2429 if (end_token_ok (end_tok, token::while_end)) 2429 if (end_token_ok (end_tok, token::while_end))
2430 { 2430 {
2431 octave_comment_list *tc = octave_comment_buffer::get_comment (); 2431 octave_comment_list *tc = octave_comment_buffer::get_comment ();
2432 2432
2433 lexer_flags.looping--; 2433 curr_lexer->looping--;
2434 2434
2435 int l = while_tok->line (); 2435 int l = while_tok->line ();
2436 int c = while_tok->column (); 2436 int c = while_tok->column ();
2437 2437
2438 retval = new tree_while_command (expr, body, lc, tc, l, c); 2438 retval = new tree_while_command (expr, body, lc, tc, l, c);
2451 2451
2452 maybe_warn_assign_as_truth_value (expr); 2452 maybe_warn_assign_as_truth_value (expr);
2453 2453
2454 octave_comment_list *tc = octave_comment_buffer::get_comment (); 2454 octave_comment_list *tc = octave_comment_buffer::get_comment ();
2455 2455
2456 lexer_flags.looping--; 2456 curr_lexer->looping--;
2457 2457
2458 int l = until_tok->line (); 2458 int l = until_tok->line ();
2459 int c = until_tok->column (); 2459 int c = until_tok->column ();
2460 2460
2461 retval = new tree_do_until_command (expr, body, lc, tc, l, c); 2461 retval = new tree_do_until_command (expr, body, lc, tc, l, c);
2477 2477
2478 if (end_token_ok (end_tok, parfor ? token::parfor_end : token::for_end)) 2478 if (end_token_ok (end_tok, parfor ? token::parfor_end : token::for_end))
2479 { 2479 {
2480 octave_comment_list *tc = octave_comment_buffer::get_comment (); 2480 octave_comment_list *tc = octave_comment_buffer::get_comment ();
2481 2481
2482 lexer_flags.looping--; 2482 curr_lexer->looping--;
2483 2483
2484 int l = for_tok->line (); 2484 int l = for_tok->line ();
2485 int c = for_tok->column (); 2485 int c = for_tok->column ();
2486 2486
2487 if (lhs->length () == 1) 2487 if (lhs->length () == 1)
2874 fcn->stash_parent_fcn_scope (function_scopes[function_scopes.size ()-2]); 2874 fcn->stash_parent_fcn_scope (function_scopes[function_scopes.size ()-2]);
2875 else 2875 else
2876 fcn->stash_parent_fcn_scope (primary_fcn_scope); 2876 fcn->stash_parent_fcn_scope (primary_fcn_scope);
2877 } 2877 }
2878 2878
2879 if (lexer_flags.parsing_class_method) 2879 if (curr_lexer->parsing_class_method)
2880 { 2880 {
2881 if (current_class_name == id_name) 2881 if (current_class_name == id_name)
2882 fcn->mark_as_class_constructor (); 2882 fcn->mark_as_class_constructor ();
2883 else 2883 else
2884 fcn->mark_as_class_method (); 2884 fcn->mark_as_class_method ();
2901 warning ("function '%s' defined within script file '%s'", 2901 warning ("function '%s' defined within script file '%s'",
2902 id_name.c_str (), curr_fcn_file_full_name.c_str ()); 2902 id_name.c_str (), curr_fcn_file_full_name.c_str ());
2903 } 2903 }
2904 2904
2905 fcn->stash_function_name (id_name); 2905 fcn->stash_function_name (id_name);
2906 fcn->stash_fcn_location (lexer_flags.input_line_number, 2906 fcn->stash_fcn_location (curr_lexer->input_line_number,
2907 lexer_flags.current_input_column); 2907 curr_lexer->current_input_column);
2908 2908
2909 if (! help_buf.empty () && current_function_depth == 1 2909 if (! help_buf.empty () && current_function_depth == 1
2910 && ! parsing_subfunctions) 2910 && ! parsing_subfunctions)
2911 { 2911 {
2912 fcn->document (help_buf.top ()); 2912 fcn->document (help_buf.top ());
3004 parsing_subfunctions = true; 3004 parsing_subfunctions = true;
3005 3005
3006 current_function_depth--; 3006 current_function_depth--;
3007 function_scopes.pop_back (); 3007 function_scopes.pop_back ();
3008 3008
3009 lexer_flags.defining_func--; 3009 curr_lexer->defining_func--;
3010 lexer_flags.parsed_function_name.pop (); 3010 curr_lexer->parsed_function_name.pop ();
3011 lexer_flags.looking_at_return_list = false; 3011 curr_lexer->looking_at_return_list = false;
3012 lexer_flags.looking_at_parameter_list = false; 3012 curr_lexer->looking_at_parameter_list = false;
3013 } 3013 }
3014 3014
3015 // Make an index expression. 3015 // Make an index expression.
3016 3016
3017 static tree_index_expression * 3017 static tree_index_expression *
3064 retval = tmp; 3064 retval = tmp;
3065 } 3065 }
3066 else 3066 else
3067 retval = new tree_index_expression (expr, elt, l, c); 3067 retval = new tree_index_expression (expr, elt, l, c);
3068 3068
3069 lexer_flags.looking_at_indirect_ref = false; 3069 curr_lexer->looking_at_indirect_ref = false;
3070 3070
3071 return retval; 3071 return retval;
3072 } 3072 }
3073 3073
3074 // Make an indirect reference expression with dynamic field name. 3074 // Make an indirect reference expression with dynamic field name.
3090 retval = tmp; 3090 retval = tmp;
3091 } 3091 }
3092 else 3092 else
3093 retval = new tree_index_expression (expr, elt, l, c); 3093 retval = new tree_index_expression (expr, elt, l, c);
3094 3094
3095 lexer_flags.looking_at_indirect_ref = false; 3095 curr_lexer->looking_at_indirect_ref = false;
3096 3096
3097 return retval; 3097 return retval;
3098 } 3098 }
3099 3099
3100 // Make a declaration command. 3100 // Make a declaration command.
3311 c = '\n'; 3311 c = '\n';
3312 } 3312 }
3313 } 3313 }
3314 3314
3315 if (c == '\n') 3315 if (c == '\n')
3316 lexer_flags.input_line_number++; 3316 curr_lexer->input_line_number++;
3317 3317
3318 return c; 3318 return c;
3319 } 3319 }
3320 3320
3321 class 3321 class
3326 3326
3327 int getc (void) { return ::text_getc (f); } 3327 int getc (void) { return ::text_getc (f); }
3328 int ungetc (int c) 3328 int ungetc (int c)
3329 { 3329 {
3330 if (c == '\n') 3330 if (c == '\n')
3331 lexer_flags.input_line_number--; 3331 curr_lexer->input_line_number--;
3332 3332
3333 return ::ungetc (c, f); 3333 return ::ungetc (c, f);
3334 } 3334 }
3335 3335
3336 private: 3336 private:
3352 { 3352 {
3353 switch (c) 3353 switch (c)
3354 { 3354 {
3355 case ' ': 3355 case ' ':
3356 case '\t': 3356 case '\t':
3357 lexer_flags.current_input_column++; 3357 curr_lexer->current_input_column++;
3358 break; 3358 break;
3359 3359
3360 case '\n': 3360 case '\n':
3361 lexer_flags.current_input_column = 1; 3361 curr_lexer->current_input_column = 1;
3362 break; 3362 break;
3363 3363
3364 default: 3364 default:
3365 reader.ungetc (c); 3365 reader.ungetc (c);
3366 goto done; 3366 goto done;
3497 3497
3498 if (ffile) 3498 if (ffile)
3499 { 3499 {
3500 bool eof; 3500 bool eof;
3501 3501
3502 frame.protect_var (lexer_flags); 3502 frame.protect_var (curr_lexer);
3503 3503
3504 // Also resets lexer_flags. 3504 curr_lexer = new lexical_feedback ();
3505
3505 reset_parser (); 3506 reset_parser ();
3506 3507
3507 std::string help_txt = gobble_leading_white_space (ffile, eof); 3508 std::string help_txt = gobble_leading_white_space (ffile, eof);
3508 3509
3509 if (! help_txt.empty ()) 3510 if (! help_txt.empty ())
3579 if (reading_script_file) 3580 if (reading_script_file)
3580 prep_lexer_for_script_file (); 3581 prep_lexer_for_script_file ();
3581 else 3582 else
3582 prep_lexer_for_function_file (); 3583 prep_lexer_for_function_file ();
3583 3584
3584 lexer_flags.parsing_class_method = ! dispatch_type.empty (); 3585 curr_lexer->parsing_class_method = ! dispatch_type.empty ();
3585 3586
3586 frame.protect_var (global_command); 3587 frame.protect_var (global_command);
3587 3588
3588 global_command = 0; 3589 global_command = 0;
3589 3590
3602 file_type.c_str (), ff.c_str ()); 3603 file_type.c_str (), ff.c_str ());
3603 } 3604 }
3604 else 3605 else
3605 { 3606 {
3606 tree_statement *end_of_script 3607 tree_statement *end_of_script
3607 = make_end ("endscript", lexer_flags.input_line_number, 3608 = make_end ("endscript", curr_lexer->input_line_number,
3608 lexer_flags.current_input_column); 3609 curr_lexer->current_input_column);
3609 3610
3610 make_script (0, end_of_script); 3611 make_script (0, end_of_script);
3611 3612
3612 fcn_ptr = primary_fcn_ptr; 3613 fcn_ptr = primary_fcn_ptr;
3613 } 3614 }
4302 { 4303 {
4303 octave_value_list retval; 4304 octave_value_list retval;
4304 4305
4305 unwind_protect frame; 4306 unwind_protect frame;
4306 4307
4307 frame.protect_var (lexer_flags); 4308 frame.protect_var (curr_lexer);
4308 4309
4309 frame.protect_var (get_input_from_eval_string); 4310 frame.protect_var (get_input_from_eval_string);
4310 frame.protect_var (line_editing); 4311 frame.protect_var (line_editing);
4311 frame.protect_var (current_eval_string); 4312 frame.protect_var (current_eval_string);
4312 frame.protect_var (current_function_depth); 4313 frame.protect_var (current_function_depth);
4316 frame.protect_var (endfunction_found); 4317 frame.protect_var (endfunction_found);
4317 frame.protect_var (reading_fcn_file); 4318 frame.protect_var (reading_fcn_file);
4318 frame.protect_var (reading_script_file); 4319 frame.protect_var (reading_script_file);
4319 frame.protect_var (reading_classdef_file); 4320 frame.protect_var (reading_classdef_file);
4320 4321
4321 lexer_flags = lexical_feedback (); 4322 curr_lexer = new lexical_feedback ();
4322 4323
4323 get_input_from_eval_string = true; 4324 get_input_from_eval_string = true;
4324 line_editing = false; 4325 line_editing = false;
4325 current_function_depth = 0; 4326 current_function_depth = 0;
4326 function_scopes.clear (); 4327 function_scopes.clear ();
4415 || tree_return_command::returning 4416 || tree_return_command::returning
4416 || tree_break_command::breaking 4417 || tree_break_command::breaking
4417 || tree_continue_command::continuing) 4418 || tree_continue_command::continuing)
4418 break; 4419 break;
4419 } 4420 }
4420 else if (lexer_flags.parser_end_of_input) 4421 else if (curr_lexer->parser_end_of_input)
4421 break; 4422 break;
4422 } 4423 }
4423 } 4424 }
4424 while (parse_status == 0); 4425 while (parse_status == 0);
4425 4426