diff options
author | brolley <brolley@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-02-04 11:36:54 +0000 |
---|---|---|
committer | brolley <brolley@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-02-04 11:36:54 +0000 |
commit | a852e3b162de7b5da4e3f556e6c0ef2a6be585b8 (patch) | |
tree | f83be6cdafbc1c89d47e5f3cafe7b3c98fd2c0fc /gcc/cppinit.c | |
parent | d6d3f0aad9f9435da7c01ddcb5f1ff878ec78d55 (diff) | |
download | gcc-a852e3b162de7b5da4e3f556e6c0ef2a6be585b8.tar.gz |
1999-02-04 14:33 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.c (initialize_char_syntax): Move to cppinit.c.
(cpp_define): Remove redundant syntax checks.
(make_assertion): Rename cpp_assert, remove redundant syntax
checks, export.
(cpp_options_init): Don't init things to zero twice.
(cpp_expand_to_buffer): Use memcpy, not a char-by-char loop.
(do_include): Kill excessively verbose import warning that
snuck back in in the gcc2 merge.
(convert_string): Removed.
(do_line): Rewrite with simple last-name-used cache instead of
private hashtable.
(cpp_start_read): Call initialize_char_syntax here, not...
(cpp_reader_init): ...here.
(cpp_handle_options): Support the -std switch.
* cpplib.h (cpp_buffer): Add last_nominal_fname member.
(cpp_options): Add c9x flag.
Declare all the is_* tables and trigraph table here, as const.
Prototype cpp_assert and initialize_char_syntax.
* cppinit.c: New file.
* cppfiles.c (read_and_prescan): Optimize.
* Makefile.in (LIBCPP_OBJS): Add cppinit.o.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@25024 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r-- | gcc/cppinit.c | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c new file mode 100644 index 00000000000..da7030f5b1b --- /dev/null +++ b/gcc/cppinit.c @@ -0,0 +1,129 @@ +/* CPP Library. + Copyright (C) 1986, 87, 89, 92-98, 1999 Free Software Foundation, Inc. + Contributed by Per Bothner, 1994-95. + Based on CCCP program by Paul Rubin, June 1986 + Adapted to ANSI C, Richard Stallman, Jan 1987 + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* This file will have more stuff in it eventually, but right now + we just have one hack: we move all the is_* table initialization + in here, and we can declare them const in cpplib.h, which improves + code a bit. */ + +#include "config.h" +#include "system.h" + +typedef unsigned char U_CHAR; + +/* table to tell if char can be part of a C identifier. */ +U_CHAR is_idchar[256] = { 0 }; +/* table to tell if char can be first char of a c identifier. */ +U_CHAR is_idstart[256] = { 0 }; +/* table to tell if c is horizontal space. */ +U_CHAR is_hor_space[256] = { 0 }; +/* table to tell if c is horizontal or vertical space. */ +U_CHAR is_space[256] = { 0 }; +/* Table to handle trigraph conversion, which occurs before all other + processing, everywhere in the file. (This is necessary since one + of the trigraphs encodes backslash.) Note it's off by default. + + from to from to from to + ?? = # ?? ) ] ?? ! | + ?? ( [ ?? ' ^ ?? > } + ?? / \ ?? < { ?? - ~ + + There is not a space between the ?? and the third char. I put spaces + there to avoid warnings when compiling this file. */ +U_CHAR trigraph_table[256] = { 0 }; + +/* Initialize syntactic classifications of characters. */ +void +initialize_char_syntax (int dollar_in_ident) +{ + is_idstart['a'] = 1; is_idstart['b'] = 1; is_idstart['c'] = 1; + is_idstart['d'] = 1; is_idstart['e'] = 1; is_idstart['f'] = 1; + is_idstart['g'] = 1; is_idstart['h'] = 1; is_idstart['i'] = 1; + is_idstart['j'] = 1; is_idstart['k'] = 1; is_idstart['l'] = 1; + is_idstart['m'] = 1; is_idstart['n'] = 1; is_idstart['o'] = 1; + is_idstart['p'] = 1; is_idstart['q'] = 1; is_idstart['r'] = 1; + is_idstart['s'] = 1; is_idstart['t'] = 1; is_idstart['u'] = 1; + is_idstart['v'] = 1; is_idstart['w'] = 1; is_idstart['x'] = 1; + is_idstart['y'] = 1; is_idstart['z'] = 1; + + is_idstart['A'] = 1; is_idstart['B'] = 1; is_idstart['C'] = 1; + is_idstart['D'] = 1; is_idstart['E'] = 1; is_idstart['F'] = 1; + is_idstart['G'] = 1; is_idstart['H'] = 1; is_idstart['I'] = 1; + is_idstart['J'] = 1; is_idstart['K'] = 1; is_idstart['L'] = 1; + is_idstart['M'] = 1; is_idstart['N'] = 1; is_idstart['O'] = 1; + is_idstart['P'] = 1; is_idstart['Q'] = 1; is_idstart['R'] = 1; + is_idstart['S'] = 1; is_idstart['T'] = 1; is_idstart['U'] = 1; + is_idstart['V'] = 1; is_idstart['W'] = 1; is_idstart['X'] = 1; + is_idstart['Y'] = 1; is_idstart['Z'] = 1; + + is_idstart['_'] = 1; + + is_idchar['a'] = 1; is_idchar['b'] = 1; is_idchar['c'] = 1; + is_idchar['d'] = 1; is_idchar['e'] = 1; is_idchar['f'] = 1; + is_idchar['g'] = 1; is_idchar['h'] = 1; is_idchar['i'] = 1; + is_idchar['j'] = 1; is_idchar['k'] = 1; is_idchar['l'] = 1; + is_idchar['m'] = 1; is_idchar['n'] = 1; is_idchar['o'] = 1; + is_idchar['p'] = 1; is_idchar['q'] = 1; is_idchar['r'] = 1; + is_idchar['s'] = 1; is_idchar['t'] = 1; is_idchar['u'] = 1; + is_idchar['v'] = 1; is_idchar['w'] = 1; is_idchar['x'] = 1; + is_idchar['y'] = 1; is_idchar['z'] = 1; + + is_idchar['A'] = 1; is_idchar['B'] = 1; is_idchar['C'] = 1; + is_idchar['D'] = 1; is_idchar['E'] = 1; is_idchar['F'] = 1; + is_idchar['G'] = 1; is_idchar['H'] = 1; is_idchar['I'] = 1; + is_idchar['J'] = 1; is_idchar['K'] = 1; is_idchar['L'] = 1; + is_idchar['M'] = 1; is_idchar['N'] = 1; is_idchar['O'] = 1; + is_idchar['P'] = 1; is_idchar['Q'] = 1; is_idchar['R'] = 1; + is_idchar['S'] = 1; is_idchar['T'] = 1; is_idchar['U'] = 1; + is_idchar['V'] = 1; is_idchar['W'] = 1; is_idchar['X'] = 1; + is_idchar['Y'] = 1; is_idchar['Z'] = 1; + + is_idchar['1'] = 1; is_idchar['2'] = 1; is_idchar['3'] = 1; + is_idchar['4'] = 1; is_idchar['5'] = 1; is_idchar['6'] = 1; + is_idchar['7'] = 1; is_idchar['8'] = 1; is_idchar['9'] = 1; + is_idchar['0'] = 1; + + is_idchar['_'] = 1; + + /* These will be reset later if -$ is in effect. */ + is_idchar['$'] = dollar_in_ident; + is_idstart['$'] = dollar_in_ident; + + /* horizontal space table */ + is_hor_space[' '] = 1; + is_hor_space['\t'] = 1; + is_hor_space['\v'] = 1; + is_hor_space['\f'] = 1; + is_hor_space['\r'] = 1; + + is_space[' '] = 1; + is_space['\t'] = 1; + is_space['\v'] = 1; + is_space['\f'] = 1; + is_space['\n'] = 1; + is_space['\r'] = 1; + + /* trigraph conversion */ + trigraph_table['='] = '#'; trigraph_table[')'] = ']'; + trigraph_table['!'] = '|'; trigraph_table['('] = '['; + trigraph_table['\''] = '^'; trigraph_table['>'] = '}'; + trigraph_table['/'] = '\\'; trigraph_table['<'] = '{'; + trigraph_table['-'] = '~'; +} |