Mercurial > hg > octave-lyh
diff libinterp/parse-tree/lex.ll @ 16106:031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
* lex.ll, lex.h (lexical_feedback::whitespace_type): New enum.
(yum_yum): Delete typedef.
(ATE_NOTHING, ATE_SPACE_OR_TAB, ATE_NEWLINE): Replace with
NO_WHITESPACE, SPACE_OR_TAB, NEWLINE values from
lexical_feedback::whitespace_type enum.
When result of eat_continuation is used as a logical test for
whitespace or no whitespace, compare to
lexical_feedback::NO_WHITESPACE to produce bool value.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 25 Feb 2013 23:48:32 -0500 |
parents | b7de58feb2d3 |
children | 7302f8a4df83 |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -223,14 +223,6 @@ // problems on some systems. std::stack <token*> token_stack; -// Did eat_whitespace() eat a space or tab, or a newline, or both? - -typedef int yum_yum; - -const yum_yum ATE_NOTHING = 0; -const yum_yum ATE_SPACE_OR_TAB = 1; -const yum_yum ATE_NEWLINE = 2; - static bool Vdisplay_tokens = false; static unsigned int Vtoken_count = 0; @@ -261,8 +253,8 @@ static bool have_continuation (bool trailing_comments_ok = true); static bool have_ellipsis_continuation (bool trailing_comments_ok = true); static void scan_for_comments (const char *); -static yum_yum eat_whitespace (void); -static yum_yum eat_continuation (void); +static int eat_whitespace (void); +static int eat_continuation (void); static int octave_read (char *buf, unsigned int max_size); static void maybe_warn_separator_insert (char sep); static void gripe_single_quote_string (void); @@ -396,7 +388,7 @@ lexer_flags.at_beginning_of_statement = false; int c = yytext[yyleng-1]; - int cont_is_spc = eat_continuation (); + bool cont_is_spc = (eat_continuation () != lexical_feedback::NO_WHITESPACE); bool spc_gobbled = (cont_is_spc || c == ' ' || c == '\t'); int tok_to_return = handle_close_bracket (spc_gobbled, ']'); @@ -422,7 +414,7 @@ lexer_flags.at_beginning_of_statement = false; int c = yytext[yyleng-1]; - int cont_is_spc = eat_continuation (); + bool cont_is_spc = (eat_continuation () != lexical_feedback::NO_WHITESPACE); bool spc_gobbled = (cont_is_spc || c == ' ' || c == '\t'); int tok_to_return = handle_close_bracket (spc_gobbled, '}'); @@ -452,7 +444,7 @@ if (! lexer_flags.looking_at_object_index.front ()) { - if ((tmp & ATE_NEWLINE) == ATE_NEWLINE) + if ((tmp & lexical_feedback::NEWLINE) == lexical_feedback::NEWLINE) { maybe_warn_separator_insert (';'); @@ -489,7 +481,7 @@ && lexer_flags.nesting_level.is_bracket_or_brace () && lexer_flags.convert_spaces_to_comma) { - if ((tmp & ATE_NEWLINE) == ATE_NEWLINE) + if ((tmp & lexical_feedback::NEWLINE) == lexical_feedback::NEWLINE) { maybe_warn_separator_insert (';'); @@ -1031,7 +1023,7 @@ void do_comma_insert_check (void) { - int spc_gobbled = eat_continuation (); + bool spc_gobbled = (eat_continuation () != lexical_feedback::NO_WHITESPACE); int c = text_yyinput (); @@ -2211,19 +2203,13 @@ } // Discard whitespace, including comments and continuations. -// -// Return value is logical OR of the following values: -// -// ATE_NOTHING : no spaces to eat -// ATE_SPACE_OR_TAB : space or tab in input -// ATE_NEWLINE : bare new line in input // FIXME -- we need to handle block comments here. -static yum_yum +static int eat_whitespace (void) { - yum_yum retval = ATE_NOTHING; + int retval = lexical_feedback::NO_WHITESPACE; std::string comment_buf; @@ -2245,11 +2231,11 @@ comment_buf += static_cast<char> (c); beginning_of_comment = false; } - retval |= ATE_SPACE_OR_TAB; + retval |= lexical_feedback::SPACE_OR_TAB; break; case '\n': - retval |= ATE_NEWLINE; + retval |= lexical_feedback::NEWLINE; if (in_comment) { comment_buf += static_cast<char> (c); @@ -2502,13 +2488,11 @@ // See if we have a continuation line. If so, eat it and the leading // whitespace on the next line. -// -// Return value is the same as described for eat_whitespace(). - -static yum_yum + +static int eat_continuation (void) { - int retval = ATE_NOTHING; + int retval = lexical_feedback::NO_WHITESPACE; int c = text_yyinput (); @@ -3165,7 +3149,7 @@ int c = yytext[yyleng-1]; - int cont_is_spc = eat_continuation (); + bool cont_is_spc = (eat_continuation () != lexical_feedback::NO_WHITESPACE); int spc_gobbled = (cont_is_spc || c == ' ' || c == '\t');