Commit f7b5ecd9 by Mark Mitchell Committed by Mark Mitchell

parser.c (cp_lexer_next_token_is): Declare it inline.

	* parser.c (cp_lexer_next_token_is): Declare it inline.
	(cp_lexer_set_source_position_from_token): Likewise.
	(cp_lexer_debugging_p): Likewise.
	(cp_parser_parsing_tentatively): Likewise.
	(cp_parser_nested_name_specifier_opt): Reduce the number of calls
	to the cp_lexer_peek_token.

From-SVN: r60797
parent f349fb24
2003-01-02 Mark Mitchell <mark@codesourcery.com> 2003-01-02 Mark Mitchell <mark@codesourcery.com>
* parser.c (cp_lexer_next_token_is): Declare it inline.
(cp_lexer_set_source_position_from_token): Likewise.
(cp_lexer_debugging_p): Likewise.
(cp_parser_parsing_tentatively): Likewise.
(cp_parser_nested_name_specifier_opt): Reduce the number of calls
to the cp_lexer_peek_token.
* parser.c (cp_parser_sizeof_operand): Do not evaluate the * parser.c (cp_parser_sizeof_operand): Do not evaluate the
expression. expression.
......
...@@ -233,7 +233,7 @@ static cp_token *cp_lexer_peek_token ...@@ -233,7 +233,7 @@ static cp_token *cp_lexer_peek_token
PARAMS ((cp_lexer *)); PARAMS ((cp_lexer *));
static cp_token *cp_lexer_peek_nth_token static cp_token *cp_lexer_peek_nth_token
PARAMS ((cp_lexer *, size_t)); PARAMS ((cp_lexer *, size_t));
static bool cp_lexer_next_token_is static inline bool cp_lexer_next_token_is
PARAMS ((cp_lexer *, enum cpp_ttype)); PARAMS ((cp_lexer *, enum cpp_ttype));
static bool cp_lexer_next_token_is_not static bool cp_lexer_next_token_is_not
PARAMS ((cp_lexer *, enum cpp_ttype)); PARAMS ((cp_lexer *, enum cpp_ttype));
...@@ -251,11 +251,11 @@ static void cp_lexer_commit_tokens ...@@ -251,11 +251,11 @@ static void cp_lexer_commit_tokens
PARAMS ((cp_lexer *)); PARAMS ((cp_lexer *));
static void cp_lexer_rollback_tokens static void cp_lexer_rollback_tokens
PARAMS ((cp_lexer *)); PARAMS ((cp_lexer *));
static void cp_lexer_set_source_position_from_token static inline void cp_lexer_set_source_position_from_token
PARAMS ((cp_lexer *, const cp_token *)); PARAMS ((cp_lexer *, const cp_token *));
static void cp_lexer_print_token static void cp_lexer_print_token
PARAMS ((FILE *, cp_token *)); PARAMS ((FILE *, cp_token *));
static bool cp_lexer_debugging_p static inline bool cp_lexer_debugging_p
PARAMS ((cp_lexer *)); PARAMS ((cp_lexer *));
static void cp_lexer_start_debugging static void cp_lexer_start_debugging
PARAMS ((cp_lexer *)) ATTRIBUTE_UNUSED; PARAMS ((cp_lexer *)) ATTRIBUTE_UNUSED;
...@@ -368,19 +368,37 @@ cp_lexer_new_from_tokens (cp_token_cache *tokens) ...@@ -368,19 +368,37 @@ cp_lexer_new_from_tokens (cp_token_cache *tokens)
return lexer; return lexer;
} }
/* Non-zero if we are presently saving tokens. */ /* Returns non-zero if debugging information should be output. */
static int static inline bool
cp_lexer_saving_tokens (lexer) cp_lexer_debugging_p (cp_lexer *lexer)
const cp_lexer *lexer;
{ {
return VARRAY_ACTIVE_SIZE (lexer->saved_tokens) != 0; return lexer->debugging_p;
}
/* Set the current source position from the information stored in
TOKEN. */
static inline void
cp_lexer_set_source_position_from_token (lexer, token)
cp_lexer *lexer ATTRIBUTE_UNUSED;
const cp_token *token;
{
/* Ideally, the source position information would not be a global
variable, but it is. */
/* Update the line number. */
if (token->type != CPP_EOF)
{
lineno = token->line_number;
input_filename = token->file_name;
}
} }
/* TOKEN points into the circular token buffer. Return a pointer to /* TOKEN points into the circular token buffer. Return a pointer to
the next token in the buffer. */ the next token in the buffer. */
static cp_token * static inline cp_token *
cp_lexer_next_token (lexer, token) cp_lexer_next_token (lexer, token)
cp_lexer *lexer; cp_lexer *lexer;
cp_token *token; cp_token *token;
...@@ -391,6 +409,15 @@ cp_lexer_next_token (lexer, token) ...@@ -391,6 +409,15 @@ cp_lexer_next_token (lexer, token)
return token; return token;
} }
/* Non-zero if we are presently saving tokens. */
static int
cp_lexer_saving_tokens (lexer)
const cp_lexer *lexer;
{
return VARRAY_ACTIVE_SIZE (lexer->saved_tokens) != 0;
}
/* Return a pointer to the token that is N tokens beyond TOKEN in the /* Return a pointer to the token that is N tokens beyond TOKEN in the
buffer. */ buffer. */
...@@ -916,25 +943,6 @@ cp_lexer_rollback_tokens (lexer) ...@@ -916,25 +943,6 @@ cp_lexer_rollback_tokens (lexer)
VARRAY_POP (lexer->saved_tokens); VARRAY_POP (lexer->saved_tokens);
} }
/* Set the current source position from the information stored in
TOKEN. */
static void
cp_lexer_set_source_position_from_token (lexer, token)
cp_lexer *lexer ATTRIBUTE_UNUSED;
const cp_token *token;
{
/* Ideally, the source position information would not be a global
variable, but it is. */
/* Update the line number. */
if (token->type != CPP_EOF)
{
lineno = token->line_number;
input_filename = token->file_name;
}
}
/* Print a representation of the TOKEN on the STREAM. */ /* Print a representation of the TOKEN on the STREAM. */
static void static void
...@@ -1007,15 +1015,6 @@ cp_lexer_print_token (stream, token) ...@@ -1007,15 +1015,6 @@ cp_lexer_print_token (stream, token)
fprintf (stream, " %s", IDENTIFIER_POINTER (token->value)); fprintf (stream, " %s", IDENTIFIER_POINTER (token->value));
} }
/* Returns non-zero if debugging information should be output. */
static bool
cp_lexer_debugging_p (lexer)
cp_lexer *lexer;
{
return lexer->debugging_p;
}
/* Start emitting debugging information. */ /* Start emitting debugging information. */
static void static void
...@@ -1747,7 +1746,7 @@ static void cp_parser_abort_tentative_parse ...@@ -1747,7 +1746,7 @@ static void cp_parser_abort_tentative_parse
PARAMS ((cp_parser *)); PARAMS ((cp_parser *));
static bool cp_parser_parse_definitely static bool cp_parser_parse_definitely
PARAMS ((cp_parser *)); PARAMS ((cp_parser *));
static bool cp_parser_parsing_tentatively static inline bool cp_parser_parsing_tentatively
PARAMS ((cp_parser *)); PARAMS ((cp_parser *));
static bool cp_parser_committed_to_tentative_parse static bool cp_parser_committed_to_tentative_parse
PARAMS ((cp_parser *)); PARAMS ((cp_parser *));
...@@ -1800,6 +1799,15 @@ static void cp_parser_perform_deferred_access_checks ...@@ -1800,6 +1799,15 @@ static void cp_parser_perform_deferred_access_checks
static tree cp_parser_scope_through_which_access_occurs static tree cp_parser_scope_through_which_access_occurs
(tree, tree, tree); (tree, tree, tree);
/* Returns non-zero if we are parsing tentatively. */
static inline bool
cp_parser_parsing_tentatively (parser)
cp_parser *parser;
{
return parser->context->next != NULL;
}
/* Returns non-zero if TOKEN is a string literal. */ /* Returns non-zero if TOKEN is a string literal. */
static bool static bool
...@@ -3467,18 +3475,17 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, ...@@ -3467,18 +3475,17 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser,
/* Spot cases that cannot be the beginning of a /* Spot cases that cannot be the beginning of a
nested-name-specifier. On the second and subsequent times nested-name-specifier. On the second and subsequent times
through the loop, we look for the `template' keyword. */ through the loop, we look for the `template' keyword. */
if (success token = cp_lexer_peek_token (parser->lexer);
&& cp_lexer_next_token_is_keyword (parser->lexer, if (success && token->keyword == RID_TEMPLATE)
RID_TEMPLATE))
; ;
/* A template-id can start a nested-name-specifier. */ /* A template-id can start a nested-name-specifier. */
else if (cp_lexer_next_token_is (parser->lexer, CPP_TEMPLATE_ID)) else if (token->type == CPP_TEMPLATE_ID)
; ;
else else
{ {
/* If the next token is not an identifier, then it is /* If the next token is not an identifier, then it is
definitely not a class-or-namespace-name. */ definitely not a class-or-namespace-name. */
if (cp_lexer_next_token_is_not (parser->lexer, CPP_NAME)) if (token->type != CPP_NAME)
break; break;
/* If the following token is neither a `<' (to begin a /* If the following token is neither a `<' (to begin a
template-id), nor a `::', then we are not looking at a template-id), nor a `::', then we are not looking at a
...@@ -14846,15 +14853,6 @@ cp_parser_parse_definitely (parser) ...@@ -14846,15 +14853,6 @@ cp_parser_parse_definitely (parser)
return !error_occurred; return !error_occurred;
} }
/* Returns non-zero if we are parsing tentatively. */
static bool
cp_parser_parsing_tentatively (parser)
cp_parser *parser;
{
return parser->context->next != NULL;
}
/* Returns true if we are parsing tentatively -- but have decided that /* Returns true if we are parsing tentatively -- but have decided that
we will stick with this tentative parse, even if errors occur. */ we will stick with this tentative parse, even if errors occur. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment