Mercurial > hg > octave-nkf
diff libinterp/parse-tree/lex.h @ 16228:e19b1632d7c1
revamp most comment handling
* comment-list.h (octave_comment_elt::comment_type): New value,
full_line.
* lex.h (lexical_feedback::comment_text): New member variable.
(lexical_feedback::finish_comment): New function.
(octave_lexer::grab_block_comment, octave_lexer::grab_comment_block,
octave_lexer::process_comment): Delete.
* lex.ll (BLOCK_COMMENT_START, LINE_COMMENT_START): New exclusive
start states.
(ANY_INCLUDING_NL): New pattern.
(<INPUT_FILE_START>{ANY_INCLUDING_NL}): Use it instead of ".".
(^{S}*{CCHAR}\{{S}*{NL}, <BLOCK_COMMENT_START>^{S}*{CCHAR}\{{S}*{NL},
<BLOCK_COMMENT_START>^{S}*{CCHAR}\}{S}*{NL},
<BLOCK_COMMENT_START>.*{NL}, {S}*{CCHAR}.*{NL},
<LINE_COMMENT_START>{S}*{CCHAR}.*{NL},
<LINE_COMMENT_START>{ANY_INCLUDING_NL}):
New patterns and rules for handling comments.
({CCHAR}, ^{S}*{CCHAR}\{{S}*{NL}): Delete old rules for comments.
(display_start_state): Also handle BLOCK_COMMENT_START and
LINE_COMMENT_START.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 08 Mar 2013 17:13:54 -0500 |
parents | 4a848eb52de2 |
children | 7b7b1e4968e8 |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.h +++ b/libinterp/parse-tree/lex.h @@ -27,6 +27,7 @@ #include <set> #include <stack> +#include "comment-list.h" #include "input.h" extern OCTINTERP_API void cleanup_parser (void); @@ -177,8 +178,8 @@ bracketflag (0), braceflag (0), looping (0), defining_func (0), looking_at_function_handle (0), block_comment_nesting_level (0), token_count (0), - current_input_line (), help_text (), fcn_file_name (), - fcn_file_full_name (), looking_at_object_index (), + current_input_line (), comment_text (), help_text (), + fcn_file_name (), fcn_file_full_name (), looking_at_object_index (), parsed_function_name (), pending_local_variables (), nesting_level (), token_stack () { @@ -191,6 +192,8 @@ void reset (void); + int finish_comment (octave_comment_elt::comment_type typ); + // true means that we have encountered eof on the input stream. bool end_of_input; @@ -291,6 +294,9 @@ // The current line of input. std::string current_input_line; + // The current comment text. + std::string comment_text; + // The current help text. std::string help_text; @@ -421,13 +427,6 @@ bool is_variable (const std::string& name); - std::string grab_block_comment (stream_reader& reader, bool& eof); - - std::string grab_comment_block (stream_reader& reader, bool at_bol, - bool& eof); - - int process_comment (bool start_in_block, bool& eof); - bool next_token_is_sep_op (void); bool next_token_is_postfix_unary_op (bool spc_prev);