Mercurial > hg > octave-lyh
comparison libinterp/parse-tree/lex.ll @ 16212:d2b268936783 classdef
maint: periodic merge of default to classdef
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 07 Mar 2013 10:25:39 -0500 |
parents | 3449bf257514 e7ff32e7cf82 |
children | d8c0f46efaf0 |
comparison
equal
deleted
inserted
replaced
16211:3449bf257514 | 16212:d2b268936783 |
---|---|
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 ('{'); |
1337 looping = 0; | 1337 looping = 0; |
1338 defining_func = 0; | 1338 defining_func = 0; |
1339 looking_at_function_handle = 0; | 1339 looking_at_function_handle = 0; |
1340 block_comment_nesting_level = 0; | 1340 block_comment_nesting_level = 0; |
1341 token_count = 0; | 1341 token_count = 0; |
1342 current_input_line = ""; | |
1342 help_text = ""; | 1343 help_text = ""; |
1343 fcn_file_name = ""; | 1344 fcn_file_name = ""; |
1344 fcn_file_full_name = ""; | 1345 fcn_file_full_name = ""; |
1345 looking_at_object_index.clear (); | 1346 looking_at_object_index.clear (); |
1346 looking_at_object_index.push_front (false); | 1347 looking_at_object_index.push_front (false); |
1445 BEGIN (INITIAL); | 1446 BEGIN (INITIAL); |
1446 | 1447 |
1447 parser_symtab_context.clear (); | 1448 parser_symtab_context.clear (); |
1448 | 1449 |
1449 // We do want a prompt by default. | 1450 // We do want a prompt by default. |
1450 promptflag = 1; | 1451 promptflag (1); |
1451 | 1452 |
1452 // Only ask for input from stdin if we are expecting interactive | 1453 // Only ask for input from stdin if we are expecting interactive |
1453 // input. | 1454 // input. |
1454 | 1455 |
1455 if (! quitting_gracefully | 1456 if (! quitting_gracefully |
1458 || reading_classdef_file | 1459 || reading_classdef_file |
1459 || reading_script_file | 1460 || reading_script_file |
1460 || input_from_eval_string ())) | 1461 || input_from_eval_string ())) |
1461 yyrestart (stdin, scanner); | 1462 yyrestart (stdin, scanner); |
1462 | 1463 |
1464 input_reader.reset (); | |
1465 | |
1463 lexical_feedback::reset (); | 1466 lexical_feedback::reset (); |
1464 } | 1467 } |
1465 | 1468 |
1466 void | 1469 void |
1467 octave_lexer::prep_for_file (void) | 1470 octave_lexer::prep_for_file (void) |
1477 int status = 0; | 1480 int status = 0; |
1478 | 1481 |
1479 if (input_buf.empty ()) | 1482 if (input_buf.empty ()) |
1480 { | 1483 { |
1481 bool eof = false; | 1484 bool eof = false; |
1482 std::string input = input_reader.get_input (eof); | 1485 current_input_line = input_reader.get_input (eof); |
1483 input_buf.fill (input, eof); | 1486 input_buf.fill (current_input_line, eof); |
1484 } | 1487 } |
1485 | 1488 |
1486 if (! input_buf.empty ()) | 1489 if (! input_buf.empty ()) |
1487 status = input_buf.copy_chunk (buf, max_size); | 1490 status = input_buf.copy_chunk (buf, max_size); |
1488 else | 1491 else |
1783 | 1786 |
1784 | 1787 |
1785 case for_kw: | 1788 case for_kw: |
1786 case parfor_kw: | 1789 case parfor_kw: |
1787 case while_kw: | 1790 case while_kw: |
1788 promptflag--; | 1791 decrement_promptflag (); |
1789 looping++; | 1792 looping++; |
1790 break; | 1793 break; |
1791 | 1794 |
1792 case do_kw: | 1795 case do_kw: |
1793 at_beginning_of_statement = true; | 1796 at_beginning_of_statement = true; |
1794 promptflag--; | 1797 decrement_promptflag (); |
1795 looping++; | 1798 looping++; |
1796 break; | 1799 break; |
1797 | 1800 |
1798 case try_kw: | 1801 case try_kw: |
1799 case unwind_protect_kw: | 1802 case unwind_protect_kw: |
1800 at_beginning_of_statement = true; | 1803 at_beginning_of_statement = true; |
1801 promptflag--; | 1804 decrement_promptflag (); |
1802 break; | 1805 break; |
1803 | 1806 |
1804 case if_kw: | 1807 case if_kw: |
1805 case switch_kw: | 1808 case switch_kw: |
1806 promptflag--; | 1809 decrement_promptflag (); |
1807 break; | 1810 break; |
1808 | 1811 |
1809 case get_kw: | 1812 case get_kw: |
1810 case set_kw: | 1813 case set_kw: |
1811 // 'get' and 'set' are keywords in classdef method | 1814 // 'get' and 'set' are keywords in classdef method |
1824 return 0; | 1827 return 0; |
1825 // fall through ... | 1828 // fall through ... |
1826 | 1829 |
1827 case classdef_kw: | 1830 case classdef_kw: |
1828 // 'classdef' is always a keyword. | 1831 // 'classdef' is always a keyword. |
1829 promptflag--; | 1832 decrement_promptflag (); |
1830 | 1833 |
1831 if (! force_script && token_count == 0 && input_from_file ()) | 1834 if (! force_script && token_count == 0 && input_from_file ()) |
1832 { | 1835 { |
1833 reading_classdef_file = true; | 1836 reading_classdef_file = true; |
1834 reading_script_file = false; | 1837 reading_script_file = false; |
1835 } | 1838 } |
1836 break; | 1839 break; |
1837 | 1840 |
1838 case function_kw: | 1841 case function_kw: |
1839 promptflag--; | 1842 decrement_promptflag (); |
1840 | 1843 |
1841 defining_func++; | 1844 defining_func++; |
1842 parsed_function_name.push (false); | 1845 parsed_function_name.push (false); |
1843 | 1846 |
1844 if (! force_script && token_count == 0 && input_from_file ()) | 1847 if (! force_script && token_count == 0 && input_from_file ()) |
1937 done = true; | 1940 done = true; |
1938 | 1941 |
1939 if (type == '{') | 1942 if (type == '{') |
1940 { | 1943 { |
1941 block_comment_nesting_level++; | 1944 block_comment_nesting_level++; |
1942 promptflag--; | 1945 decrement_promptflag (); |
1943 } | 1946 } |
1944 else | 1947 else |
1945 { | 1948 { |
1946 block_comment_nesting_level--; | 1949 block_comment_nesting_level--; |
1947 promptflag++; | 1950 increment_promptflag (); |
1948 | 1951 |
1949 if (block_comment_nesting_level == 0) | 1952 if (block_comment_nesting_level == 0) |
1950 { | 1953 { |
1951 buf += grab_comment_block (reader, true, eof); | 1954 buf += grab_comment_block (reader, true, eof); |
1952 | 1955 |
2045 current_input_column = 0; | 2048 current_input_column = 0; |
2046 at_bol = true; | 2049 at_bol = true; |
2047 done = true; | 2050 done = true; |
2048 | 2051 |
2049 block_comment_nesting_level++; | 2052 block_comment_nesting_level++; |
2050 promptflag--; | 2053 decrement_promptflag (); |
2051 | 2054 |
2052 buf += grab_block_comment (reader, eof); | 2055 buf += grab_block_comment (reader, eof); |
2053 | 2056 |
2054 in_comment = false; | 2057 in_comment = false; |
2055 | 2058 |
2645 { | 2648 { |
2646 comment_buf += static_cast<char> (c); | 2649 comment_buf += static_cast<char> (c); |
2647 octave_comment_buffer::append (comment_buf); | 2650 octave_comment_buffer::append (comment_buf); |
2648 } | 2651 } |
2649 current_input_column = 0; | 2652 current_input_column = 0; |
2650 promptflag--; | 2653 decrement_promptflag (); |
2651 gripe_matlab_incompatible_continuation (); | 2654 gripe_matlab_incompatible_continuation (); |
2652 return true; | 2655 return true; |
2653 | 2656 |
2654 default: | 2657 default: |
2655 if (in_comment) | 2658 if (in_comment) |