comparison libinterp/parse-tree/lex.ll @ 16209:e7ff32e7cf82

move global promptflag variable to octave_reader class * input.h, input.cc (promptflag): Declare as member of octave_base_reader and rename to pflag. (octave_base_reader::reset, octave_base_reader::promptflag, octave_base_reader::increment_promptflag, octave_reader::decrement_promptflag, octave_reader::promptflag, octave_reader::increment_promptflag, octave_reader::decrement_promptflag): New functions. * lex.ll (octave_lexer::decrement_promptflag, octave_lexer::promptflag, octave_lexer::increment_promptflag, octave_lexer::decrement_promptflag): New functions. Use them instead of global promptflag variable. (octave_lexer::reset): Call input_reader.reset. * oct-parse.in.yy (input): Don't reset promptflag here.
author John W. Eaton <jwe@octave.org>
date Wed, 06 Mar 2013 20:20:35 -0500
parents 0467d68ca891
children d2b268936783 4a848eb52de2
comparison
equal deleted inserted replaced
16208:ed91ab4d4515 16209:e7ff32e7cf82
536 && ! curr_lexer->parsed_function_name.top ()) 536 && ! curr_lexer->parsed_function_name.top ())
537 curr_lexer->looking_at_return_list = true; 537 curr_lexer->looking_at_return_list = true;
538 else 538 else
539 curr_lexer->looking_at_matrix_or_assign_lhs = true; 539 curr_lexer->looking_at_matrix_or_assign_lhs = true;
540 540
541 promptflag--; 541 curr_lexer->decrement_promptflag ();
542 curr_lexer->eat_whitespace (); 542 curr_lexer->eat_whitespace ();
543 543
544 curr_lexer->bracketflag++; 544 curr_lexer->bracketflag++;
545 BEGIN (MATRIX_START); 545 BEGIN (MATRIX_START);
546 COUNT_TOK_AND_RETURN ('['); 546 COUNT_TOK_AND_RETURN ('[');
600 LEXER_DEBUG ("{CONT}{S}*{NL}|{CONT}{S}*{COMMENT}"); 600 LEXER_DEBUG ("{CONT}{S}*{NL}|{CONT}{S}*{COMMENT}");
601 601
602 if (yytext[0] == '\\') 602 if (yytext[0] == '\\')
603 curr_lexer->gripe_matlab_incompatible_continuation (); 603 curr_lexer->gripe_matlab_incompatible_continuation ();
604 curr_lexer->scan_for_comments (yytext); 604 curr_lexer->scan_for_comments (yytext);
605 promptflag--; 605 curr_lexer->decrement_promptflag ();
606 curr_lexer->input_line_number++; 606 curr_lexer->input_line_number++;
607 curr_lexer->current_input_column = 1; 607 curr_lexer->current_input_column = 1;
608 } 608 }
609 609
610 %{ 610 %{
779 curr_lexer->looking_for_object_index = false; 779 curr_lexer->looking_for_object_index = false;
780 780
781 curr_lexer->input_line_number++; 781 curr_lexer->input_line_number++;
782 curr_lexer->current_input_column = 1; 782 curr_lexer->current_input_column = 1;
783 curr_lexer->block_comment_nesting_level++; 783 curr_lexer->block_comment_nesting_level++;
784 promptflag--; 784 curr_lexer->decrement_promptflag ();
785 785
786 bool eof = false; 786 bool eof = false;
787 curr_lexer->process_comment (true, eof); 787 curr_lexer->process_comment (true, eof);
788 } 788 }
789 789
850 curr_lexer->looking_at_indirect_ref = false; 850 curr_lexer->looking_at_indirect_ref = false;
851 curr_lexer->looking_for_object_index = false; 851 curr_lexer->looking_for_object_index = false;
852 curr_lexer->at_beginning_of_statement = false; 852 curr_lexer->at_beginning_of_statement = false;
853 853
854 curr_lexer->nesting_level.paren (); 854 curr_lexer->nesting_level.paren ();
855 promptflag--; 855 curr_lexer->decrement_promptflag ();
856 856
857 TOK_RETURN ('('); 857 TOK_RETURN ('(');
858 } 858 }
859 859
860 ")" { 860 ")" {
918 curr_lexer->quote_is_transpose = false; 918 curr_lexer->quote_is_transpose = false;
919 curr_lexer->convert_spaces_to_comma = true; 919 curr_lexer->convert_spaces_to_comma = true;
920 curr_lexer->looking_for_object_index = false; 920 curr_lexer->looking_for_object_index = false;
921 curr_lexer->at_beginning_of_statement = false; 921 curr_lexer->at_beginning_of_statement = false;
922 922
923 promptflag--; 923 curr_lexer->decrement_promptflag ();
924 curr_lexer->eat_whitespace (); 924 curr_lexer->eat_whitespace ();
925 925
926 curr_lexer->braceflag++; 926 curr_lexer->braceflag++;
927 BEGIN (MATRIX_START); 927 BEGIN (MATRIX_START);
928 COUNT_TOK_AND_RETURN ('{'); 928 COUNT_TOK_AND_RETURN ('{');
1444 BEGIN (INITIAL); 1444 BEGIN (INITIAL);
1445 1445
1446 parser_symtab_context.clear (); 1446 parser_symtab_context.clear ();
1447 1447
1448 // We do want a prompt by default. 1448 // We do want a prompt by default.
1449 promptflag = 1; 1449 promptflag (1);
1450 1450
1451 // Only ask for input from stdin if we are expecting interactive 1451 // Only ask for input from stdin if we are expecting interactive
1452 // input. 1452 // input.
1453 1453
1454 if (! quitting_gracefully 1454 if (! quitting_gracefully
1456 && ! (reading_fcn_file 1456 && ! (reading_fcn_file
1457 || reading_classdef_file 1457 || reading_classdef_file
1458 || reading_script_file 1458 || reading_script_file
1459 || input_from_eval_string ())) 1459 || input_from_eval_string ()))
1460 yyrestart (stdin, scanner); 1460 yyrestart (stdin, scanner);
1461
1462 input_reader.reset ();
1461 1463
1462 lexical_feedback::reset (); 1464 lexical_feedback::reset ();
1463 } 1465 }
1464 1466
1465 void 1467 void
1784 1786
1785 1787
1786 case for_kw: 1788 case for_kw:
1787 case parfor_kw: 1789 case parfor_kw:
1788 case while_kw: 1790 case while_kw:
1789 promptflag--; 1791 decrement_promptflag ();
1790 looping++; 1792 looping++;
1791 break; 1793 break;
1792 1794
1793 case do_kw: 1795 case do_kw:
1794 at_beginning_of_statement = true; 1796 at_beginning_of_statement = true;
1795 promptflag--; 1797 decrement_promptflag ();
1796 looping++; 1798 looping++;
1797 break; 1799 break;
1798 1800
1799 case try_kw: 1801 case try_kw:
1800 case unwind_protect_kw: 1802 case unwind_protect_kw:
1801 at_beginning_of_statement = true; 1803 at_beginning_of_statement = true;
1802 promptflag--; 1804 decrement_promptflag ();
1803 break; 1805 break;
1804 1806
1805 case if_kw: 1807 case if_kw:
1806 case switch_kw: 1808 case switch_kw:
1807 promptflag--; 1809 decrement_promptflag ();
1808 break; 1810 break;
1809 1811
1810 case get_kw: 1812 case get_kw:
1811 case set_kw: 1813 case set_kw:
1812 // 'get' and 'set' are keywords in classdef method 1814 // 'get' and 'set' are keywords in classdef method
1825 return 0; 1827 return 0;
1826 // fall through ... 1828 // fall through ...
1827 1829
1828 case classdef_kw: 1830 case classdef_kw:
1829 // 'classdef' is always a keyword. 1831 // 'classdef' is always a keyword.
1830 promptflag--; 1832 decrement_promptflag ();
1831 1833
1832 if (! force_script && token_count == 0 && input_from_file ()) 1834 if (! force_script && token_count == 0 && input_from_file ())
1833 { 1835 {
1834 reading_classdef_file = true; 1836 reading_classdef_file = true;
1835 reading_script_file = false; 1837 reading_script_file = false;
1836 } 1838 }
1837 break; 1839 break;
1838 1840
1839 case function_kw: 1841 case function_kw:
1840 promptflag--; 1842 decrement_promptflag ();
1841 1843
1842 defining_func++; 1844 defining_func++;
1843 parsed_function_name.push (false); 1845 parsed_function_name.push (false);
1844 1846
1845 if (! force_script && token_count == 0 && input_from_file ()) 1847 if (! force_script && token_count == 0 && input_from_file ())
1938 done = true; 1940 done = true;
1939 1941
1940 if (type == '{') 1942 if (type == '{')
1941 { 1943 {
1942 block_comment_nesting_level++; 1944 block_comment_nesting_level++;
1943 promptflag--; 1945 decrement_promptflag ();
1944 } 1946 }
1945 else 1947 else
1946 { 1948 {
1947 block_comment_nesting_level--; 1949 block_comment_nesting_level--;
1948 promptflag++; 1950 increment_promptflag ();
1949 1951
1950 if (block_comment_nesting_level == 0) 1952 if (block_comment_nesting_level == 0)
1951 { 1953 {
1952 buf += grab_comment_block (reader, true, eof); 1954 buf += grab_comment_block (reader, true, eof);
1953 1955
2046 current_input_column = 0; 2048 current_input_column = 0;
2047 at_bol = true; 2049 at_bol = true;
2048 done = true; 2050 done = true;
2049 2051
2050 block_comment_nesting_level++; 2052 block_comment_nesting_level++;
2051 promptflag--; 2053 decrement_promptflag ();
2052 2054
2053 buf += grab_block_comment (reader, eof); 2055 buf += grab_block_comment (reader, eof);
2054 2056
2055 in_comment = false; 2057 in_comment = false;
2056 2058
2646 { 2648 {
2647 comment_buf += static_cast<char> (c); 2649 comment_buf += static_cast<char> (c);
2648 octave_comment_buffer::append (comment_buf); 2650 octave_comment_buffer::append (comment_buf);
2649 } 2651 }
2650 current_input_column = 0; 2652 current_input_column = 0;
2651 promptflag--; 2653 decrement_promptflag ();
2652 gripe_matlab_incompatible_continuation (); 2654 gripe_matlab_incompatible_continuation ();
2653 return true; 2655 return true;
2654 2656
2655 default: 2657 default:
2656 if (in_comment) 2658 if (in_comment)