Commit 5fddcffc by Neil Booth Committed by Neil Booth

cpphash.h (struct tokenrun): New.

	* cpphash.h (struct tokenrun): New.
	(struct cpp_context): New member bol.
	(struct cpp_reader): New members.
	(_cpp_init_tokenrun): New.
	* cppinit.c (cpp_create_reader): Set up the token runs.
	* cpplex.c (lex_directive, lex_token, next_tokenrun): New.
	(lex_token): New internalised version of _cpp_lex_token.  Don't
	handle directives or the multiple include opimisation here any
	more.  Simply lex a token.
	* cpplib.c (run_directive): Clear bol.
	(_cpp_pop_buffer): Set bol.
	* cppmacro.c (funlike_invocation_p): Keep tokens whilst parsing
	arguments.

From-SVN: r45534
parent 75dcd8fe
2001-09-11 Neil Booth <neil@daikokuya.demon.co.uk>
* cpphash.h (struct tokenrun): New.
(struct cpp_context): New member bol.
(struct cpp_reader): New members.
(_cpp_init_tokenrun): New.
* cppinit.c (cpp_create_reader): Set up the token runs.
* cpplex.c (lex_directive, lex_token, next_tokenrun): New.
(lex_token): New internalised version of _cpp_lex_token. Don't
handle directives or the multiple include opimisation here any
more. Simply lex a token.
* cpplib.c (run_directive): Clear bol.
(_cpp_pop_buffer): Set bol.
* cppmacro.c (funlike_invocation_p): Keep tokens whilst parsing
arguments.
2001-09-11 Michael Meissner <meissner@redhat.com>
* config/mips/mips.h (CC1_SPEC): If -mgp32 default to -mfp32, and
......
......@@ -102,6 +102,13 @@ struct toklist
cpp_token *limit;
};
typedef struct tokenrun tokenrun;
struct tokenrun
{
tokenrun *next;
cpp_token *base, *limit;
};
typedef struct cpp_context cpp_context;
struct cpp_context
{
......@@ -124,6 +131,9 @@ struct lexer_state
/* True if we are skipping a failed conditional group. */
unsigned char skipping;
/* Nonzero if next token is the start of a line. */
unsigned char bol;
/* Nonzero if in a directive that takes angle-bracketed headers. */
unsigned char angled_headers;
......@@ -258,6 +268,13 @@ struct cpp_reader
const cpp_hashnode *mi_ind_cmacro;
bool mi_valid;
/* Lexing. */
cpp_token *cur_token;
tokenrun base_run, *cur_run;
/* Non-zero prevents the lexer from re-using the token runs. */
unsigned int keep_tokens;
/* Token lookahead. */
struct cpp_lookahead *la_read; /* Read from this lookahead. */
struct cpp_lookahead *la_write; /* Write to this lookahead. */
......@@ -397,6 +414,7 @@ extern int _cpp_parse_expr PARAMS ((cpp_reader *));
extern void _cpp_lex_token PARAMS ((cpp_reader *, cpp_token *));
extern int _cpp_equiv_tokens PARAMS ((const cpp_token *,
const cpp_token *));
extern void _cpp_init_tokenrun PARAMS ((tokenrun *, unsigned int));
extern void _cpp_init_pool PARAMS ((cpp_pool *, unsigned int,
unsigned int, unsigned int));
extern void _cpp_free_pool PARAMS ((cpp_pool *));
......
......@@ -511,6 +511,12 @@ cpp_create_reader (table, lang)
/* Indicate date and time not yet calculated. */
pfile->date.type = CPP_EOF;
/* Create a token buffer for the lexer. */
_cpp_init_tokenrun (&pfile->base_run, 250);
pfile->cur_run = &pfile->base_run;
pfile->cur_token = pfile->base_run.base;
pfile->state.bol = 1;
/* Initialise the base context. */
pfile->context = &pfile->base_context;
pfile->base_context.macro = 0;
......
......@@ -402,6 +402,7 @@ run_directive (pfile, dir_no, buf, count)
cpp_push_buffer (pfile, (const U_CHAR *) buf, count,
/* from_stage3 */ true, 1);
start_directive (pfile);
pfile->state.bol = 0;
pfile->state.prevent_expansion++;
pfile->directive = &dtable[dir_no];
(void) (*pfile->directive->handler) (pfile);
......@@ -1782,6 +1783,7 @@ _cpp_pop_buffer (pfile)
case of a missing #endif. */
pfile->lexer_pos.output_line = pfile->line;
pfile->state.skipping = 0;
pfile->state.bol = 1;
/* Update the reader's buffer before _cpp_do_file_change. */
pfile->buffer = buffer->prev;
......
......@@ -599,6 +599,7 @@ funlike_invocation_p (pfile, node, list)
pfile->state.parsing_args = 1;
pfile->state.prevent_expansion++;
pfile->keep_tokens++;
cpp_start_lookahead (pfile);
cpp_get_token (pfile, &maybe_paren);
cpp_stop_lookahead (pfile, maybe_paren.type == CPP_OPEN_PAREN);
......@@ -613,6 +614,7 @@ funlike_invocation_p (pfile, node, list)
pfile->state.prevent_expansion--;
pfile->state.parsing_args = 0;
pfile->keep_tokens--;
/* Reset the position in case of failure. If success, the macro's
expansion appears where the name would have. */
......
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