diff options
author | Neil Booth <neilb@earthling.net> | 2000-09-18 18:43:05 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2000-09-18 18:43:05 +0000 |
commit | 0d9f234d9317f291eb49dab50277efeee85e5b91 (patch) | |
tree | 46f9c8a95640d0cd590d2e287982ab8e1099e35e /gcc/cpplib.h | |
parent | 9f8e169eb7a21b2f374df31dd32beef667676a13 (diff) | |
download | gcc-0d9f234d9317f291eb49dab50277efeee85e5b91.zip gcc-0d9f234d9317f291eb49dab50277efeee85e5b91.tar.gz gcc-0d9f234d9317f291eb49dab50277efeee85e5b91.tar.bz2 |
cpphash.h (HASHSTEP): Take character rather than pointer to character.
* cpphash.h (HASHSTEP): Take character rather than pointer
to character.
(_cpp_check_directive, _cpp_check_linemarker): Update prototypes.
* cpphash.c (cpp_loookup): Update for new HASHSTEP.
* cpplex.c (auto_expand_name_space, trigraph_replace,
backslash_start, handle_newline, parse_name, INIT_TOKEN_STR,
IMMED_TOKEN, PREV_TOKEN_TYPE, PUSH_TOKEN, REVISE_TOKEN,
BACKUP_TOKEN, BACKUP_TRIGRAPH, MIGHT_BE_DIRECTIVE,
KNOWN_DIRECTIVE): Delete.
(handle_newline, check_long_token, skip_escaped_newlines,
unterminated): New functions.
(ACCEPT_CHAR, SAVE_STATE, RESTORE_STATE): New macros.
(parse_identifier): Was parse_name, new implementation.
(skip_line_comment, skip_block_comment, skip_whitespace,
parse_number, parse_string, trigraph_ok, save_comment,
adjust_column, _cpp_get_line): New implementations.
(lex_token): New function. Lexes a token at a time, looking
forwards. Contains most of the guts of the old lex_line.
(lex_line): New implementation, using lex_token to obtain
individual tokens.
(cpp_scan_buffer): Use the token's line, not the list's line.
* cpplib.c (_cpp_check_directive, _cpp_check_linemarker):
New implementations.
(do_assert): Don't bother setting the answer's list's line.
(cpp_push_buffer): Initialise new pfile and read_ahead members
of struct cpp_buffer.
* cpplib.h (cppchar_t): New typedef.
(struct cpp_buffer): read_ahead, pfile and col_adjust are
new members.
(struct lexer_state): New structure that determines the state
and behaviour of the lexer.
(IN_DIRECTIVE, KNOWN_DIRECTIVE): New macros.
(struct cpp_reader): New member "state". Rename
multiline_string_line and multiline_string_column. Delete
col_adjust, in_lex_line members.
(CPP_BUF_COLUMN): Update.
* gcc.dg/cpp/cmdlne-C.c: Remove bogus warning test.
From-SVN: r36509
Diffstat (limited to 'gcc/cpplib.h')
-rw-r--r-- | gcc/cpplib.h | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/gcc/cpplib.h b/gcc/cpplib.h index 9793bc0..7511537 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -215,15 +215,22 @@ struct cpp_toklist unsigned short flags; }; +/* A standalone character. We may want to make it unsigned for the + same reason we use unsigned char - to avoid signedness issues. */ +typedef int cppchar_t; + struct cpp_buffer { const unsigned char *cur; /* current position */ const unsigned char *rlimit; /* end of valid data */ - const unsigned char *buf; /* entire buffer */ const unsigned char *line_base; /* start of current line */ + cppchar_t read_ahead; /* read ahead character */ + struct cpp_reader *pfile; /* Owns this buffer. */ struct cpp_buffer *prev; + const unsigned char *buf; /* entire buffer */ + /* Filename specified with #line command. */ const char *nominal_fname; @@ -238,6 +245,9 @@ struct cpp_buffer Used to prohibit unmatched #endif (etc) in an include file. */ struct if_stack *if_stack; + /* Token column position adjustment owing to tabs in whitespace. */ + unsigned int col_adjust; + /* Line number at line_base (above). */ unsigned int lineno; @@ -431,6 +441,31 @@ struct cpp_options unsigned char show_column; }; +struct lexer_state +{ + /* Nonzero if first token on line is CPP_HASH. */ + unsigned char in_directive; + + /* Nonzero if the directive's # was not in the first column. Used + by -Wtraditional. */ + unsigned char indented; + + /* Nonzero if in a directive that takes angle-bracketed headers. */ + unsigned char angled_headers; + + /* Nonzero to save comments. Turned off if discard_comments, and in + all directives apart from #define. */ + unsigned char save_comments; + + /* Nonzero to get force the lexer to skip newlines. */ + unsigned char skip_newlines; + + /* If we're in the subroutine lex_line. */ + unsigned char in_lex_line; +}; +#define IN_DIRECTIVE(pfile) (pfile->state.in_directive) +#define KNOWN_DIRECTIVE(list) (list->directive != 0) + /* A cpp_reader encapsulates the "state" of a pre-processor run. Applying cpp_get_token repeatedly yields a stream of pre-processor tokens. Usually, there is only one cpp_reader object active. */ @@ -440,12 +475,16 @@ struct cpp_reader /* Top of buffer stack. */ cpp_buffer *buffer; + /* Lexer state. */ + struct lexer_state state; + /* Error counter for exit code */ unsigned int errors; - /* Line and column where a newline was first seen in a string constant. */ - unsigned int multiline_string_line; - unsigned int multiline_string_column; + /* Line and column where a newline was first seen in a string + constant (multi-line strings). */ + unsigned int mls_line; + unsigned int mls_column; /* Current depth in #include directives that use <...>. */ unsigned int system_include_depth; @@ -475,9 +514,6 @@ struct cpp_reader be one at a time, so it is per-reader not per-buffer. */ const cpp_hashnode *potential_control_macro; - /* Token column position adjustment owing to tabs in whitespace. */ - unsigned int col_adjust; - /* Token list used to store logical lines with new lexer. */ cpp_toklist token_list; @@ -557,9 +593,6 @@ struct cpp_reader or we might need to write out definitions. */ unsigned char save_parameter_spellings; - /* If we're in lex_line. */ - unsigned char in_lex_line; - /* True if output_line_command needs to output a newline. */ unsigned char need_newline; @@ -586,7 +619,7 @@ struct cpp_printer #define CPP_OPTION(PFILE, OPTION) ((PFILE)->opts.OPTION) #define CPP_BUFFER(PFILE) ((PFILE)->buffer) #define CPP_BUF_LINE(BUF) ((BUF)->lineno) -#define CPP_BUF_COLUMN(BUF, CUR) ((CUR) - (BUF)->line_base + pfile->col_adjust) +#define CPP_BUF_COLUMN(BUF, CUR) ((CUR) - (BUF)->line_base + (BUF)->col_adjust) #define CPP_BUF_COL(BUF) CPP_BUF_COLUMN(BUF, (BUF)->cur) /* Name under which this program was invoked. */ |