Mercurial > hg > octave-nkf
comparison libinterp/parse-tree/lex.ll @ 16105:b7de58feb2d3
move block_comment_nesting_level to lexical_feedback_class
* lex.h, lex.ll (block_comment_nesting_level): Move global
variable to lexical_feedback class. Change all uses.
(reset_parser): Don't reset block_comment_nesting_level.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 25 Feb 2013 21:59:40 -0500 |
parents | c8974e28da59 |
children | 031117f4db7c |
comparison
equal
deleted
inserted
replaced
16104:c8974e28da59 | 16105:b7de58feb2d3 |
---|---|
232 const yum_yum ATE_NEWLINE = 2; | 232 const yum_yum ATE_NEWLINE = 2; |
233 | 233 |
234 static bool Vdisplay_tokens = false; | 234 static bool Vdisplay_tokens = false; |
235 | 235 |
236 static unsigned int Vtoken_count = 0; | 236 static unsigned int Vtoken_count = 0; |
237 | |
238 // The start state that was in effect when the beginning of a block | |
239 // comment was noticed. | |
240 static int block_comment_nesting_level = 0; | |
241 | 237 |
242 // Internal variable for lexer debugging state. | 238 // Internal variable for lexer debugging state. |
243 static bool lexer_debug_flag = false; | 239 static bool lexer_debug_flag = false; |
244 | 240 |
245 // Forward declarations for functions defined at the bottom of this | 241 // Forward declarations for functions defined at the bottom of this |
659 %} | 655 %} |
660 | 656 |
661 <<EOF>> { | 657 <<EOF>> { |
662 LEXER_DEBUG ("<<EOF>>"); | 658 LEXER_DEBUG ("<<EOF>>"); |
663 | 659 |
664 if (block_comment_nesting_level != 0) | 660 if (lexer_flags.block_comment_nesting_level != 0) |
665 { | 661 { |
666 warning ("block comment open at end of input"); | 662 warning ("block comment open at end of input"); |
667 | 663 |
668 if ((reading_fcn_file || reading_script_file || reading_classdef_file) | 664 if ((reading_fcn_file || reading_script_file || reading_classdef_file) |
669 && ! curr_fcn_file_name.empty ()) | 665 && ! curr_fcn_file_name.empty ()) |
837 | 833 |
838 lexer_flags.looking_for_object_index = false; | 834 lexer_flags.looking_for_object_index = false; |
839 | 835 |
840 lexer_flags.input_line_number++; | 836 lexer_flags.input_line_number++; |
841 lexer_flags.current_input_column = 1; | 837 lexer_flags.current_input_column = 1; |
842 block_comment_nesting_level++; | 838 lexer_flags.block_comment_nesting_level++; |
843 promptflag--; | 839 promptflag--; |
844 | 840 |
845 bool eof = false; | 841 bool eof = false; |
846 process_comment (true, eof); | 842 process_comment (true, eof); |
847 } | 843 } |
1061 parser_symtab_context.clear (); | 1057 parser_symtab_context.clear (); |
1062 | 1058 |
1063 // We do want a prompt by default. | 1059 // We do want a prompt by default. |
1064 promptflag = 1; | 1060 promptflag = 1; |
1065 | 1061 |
1066 // We are not in a block comment. | |
1067 block_comment_nesting_level = 0; | |
1068 | |
1069 // Clear out the stack of token info used to track line and column | 1062 // Clear out the stack of token info used to track line and column |
1070 // numbers. | 1063 // numbers. |
1071 while (! token_stack.empty ()) | 1064 while (! token_stack.empty ()) |
1072 { | 1065 { |
1073 delete token_stack.top (); | 1066 delete token_stack.top (); |
1678 at_bol = true; | 1671 at_bol = true; |
1679 done = true; | 1672 done = true; |
1680 | 1673 |
1681 if (type == '{') | 1674 if (type == '{') |
1682 { | 1675 { |
1683 block_comment_nesting_level++; | 1676 lexer_flags.block_comment_nesting_level++; |
1684 promptflag--; | 1677 promptflag--; |
1685 } | 1678 } |
1686 else | 1679 else |
1687 { | 1680 { |
1688 block_comment_nesting_level--; | 1681 lexer_flags.block_comment_nesting_level--; |
1689 promptflag++; | 1682 promptflag++; |
1690 | 1683 |
1691 if (block_comment_nesting_level == 0) | 1684 if (lexer_flags.block_comment_nesting_level == 0) |
1692 { | 1685 { |
1693 buf += grab_comment_block (reader, true, eof); | 1686 buf += grab_comment_block (reader, true, eof); |
1694 | 1687 |
1695 return buf; | 1688 return buf; |
1696 } | 1689 } |
1786 { | 1779 { |
1787 lexer_flags.current_input_column = 0; | 1780 lexer_flags.current_input_column = 0; |
1788 at_bol = true; | 1781 at_bol = true; |
1789 done = true; | 1782 done = true; |
1790 | 1783 |
1791 block_comment_nesting_level++; | 1784 lexer_flags.block_comment_nesting_level++; |
1792 promptflag--; | 1785 promptflag--; |
1793 | 1786 |
1794 buf += grab_block_comment (reader, eof); | 1787 buf += grab_block_comment (reader, eof); |
1795 | 1788 |
1796 in_comment = false; | 1789 in_comment = false; |