c-lex.c (c_lex): Handle CPP_OTHER differently.

* c-lex.c (c_lex): Handle CPP_OTHER differently.
	* cppexp.c (_cpp_parse_expr): Similarly.
	* cpplex.c (SPELL_CHAR): Remove.
	(_cpp_lex_direct): Stray chars are saved as byte strings.
	(cpp_spell_token, cpp_output_token, _cpp_equiv_token): Don't
	handle SPELL_CHAR.
	(cpp_avoid_paste): Update handling of CPP_OTHER.
	* cpplib.h: Spell CPP_OTHER like a number.
	(struct cpp_token): Remove member c.
	* cppmacro.c (stringify_arg): Update handling of CPP_OTHER.

From-SVN: r65951
This commit is contained in:
Neil Booth 2003-04-22 19:28:00 +00:00 committed by Neil Booth
parent 45aca21f40
commit 1067694a52
6 changed files with 28 additions and 29 deletions

View File

@ -1,3 +1,16 @@
2003-04-22 Neil Booth <neil@daikokuya.co.uk>
* c-lex.c (c_lex): Handle CPP_OTHER differently.
* cppexp.c (_cpp_parse_expr): Similarly.
* cpplex.c (SPELL_CHAR): Remove.
(_cpp_lex_direct): Stray chars are saved as byte strings.
(cpp_spell_token, cpp_output_token, _cpp_equiv_token): Don't
handle SPELL_CHAR.
(cpp_avoid_paste): Update handling of CPP_OTHER.
* cpplib.h: Spell CPP_OTHER like a number.
(struct cpp_token): Remove member c.
* cppmacro.c (stringify_arg): Update handling of CPP_OTHER.
2003-04-22 David Turner <novalis@gnu.org>
* gbl-ctors.h: Add special license exception.

View File

@ -344,12 +344,9 @@ c_lex (value)
*value = NULL_TREE;
switch (tok->type)
{
/* Issue this error here, where we can get at tok->val.c. */
case CPP_OTHER:
if (ISGRAPH (tok->val.c))
error ("stray '%c' in program", tok->val.c);
else
error ("stray '\\%o' in program", tok->val.c);
error ("stray token \"%s\" in program",
cpp_token_as_text (parse_in, tok));
goto retry;
case CPP_NAME:

View File

@ -746,12 +746,6 @@ _cpp_parse_expr (pfile)
if (want_value)
op.op = CPP_UMINUS;
break;
case CPP_OTHER:
if (ISGRAPH (op.token->val.c))
SYNTAX_ERROR2 ("invalid character '%c' in #if", op.token->val.c);
else
SYNTAX_ERROR2 ("invalid character '\\%03o' in #if",
op.token->val.c);
default:
if ((int) op.op <= (int) CPP_EQ || (int) op.op >= (int) CPP_PLUS_EQ)

View File

@ -31,7 +31,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
enum spell_type
{
SPELL_OPERATOR = 0,
SPELL_CHAR,
SPELL_IDENT,
SPELL_NUMBER,
SPELL_STRING,
@ -1076,10 +1075,16 @@ _cpp_lex_direct (pfile)
break;
}
buffer->cur++;
}
default:
default:
{
uchar *dest = _cpp_unaligned_alloc (pfile, 1 + 1);
dest[0] = c;
dest[1] = '\0';
result->type = CPP_OTHER;
result->val.c = c;
result->val.str.len = 1;
result->val.str.text = dest;
break;
}
}
@ -1136,10 +1141,6 @@ cpp_spell_token (pfile, token, buffer)
}
break;
case SPELL_CHAR:
*buffer++ = token->val.c;
break;
spell_ident:
case SPELL_IDENT:
memcpy (buffer, NODE_NAME (token->val.node), NODE_LEN (token->val.node));
@ -1237,10 +1238,6 @@ cpp_output_token (token, fp)
}
break;
case SPELL_CHAR:
putc (token->val.c, fp);
break;
spell_ident:
case SPELL_IDENT:
fwrite (NODE_NAME (token->val.node), 1, NODE_LEN (token->val.node), fp);
@ -1288,8 +1285,6 @@ _cpp_equiv_tokens (a, b)
default: /* Keep compiler happy. */
case SPELL_OPERATOR:
return 1;
case SPELL_CHAR:
return a->val.c == b->val.c; /* Character. */
case SPELL_NONE:
return (a->type != CPP_MACRO_ARG || a->val.arg_no == b->val.arg_no);
case SPELL_IDENT:
@ -1352,9 +1347,10 @@ cpp_avoid_paste (pfile, token1, token2)
case CPP_NUMBER: return (b == CPP_NUMBER || b == CPP_NAME
|| c == '.' || c == '+' || c == '-');
/* UCNs */
case CPP_OTHER: return ((token1->val.c == '\\' && b == CPP_NAME)
case CPP_OTHER: return ((token1->val.str.text[0] == '\\'
&& b == CPP_NAME)
|| (CPP_OPTION (pfile, objc)
&& token1->val.c == '@'
&& token1->val.str.text[0] == '@'
&& (b == CPP_NAME || b == CPP_STRING)));
default: break;
}

View File

@ -128,7 +128,7 @@ struct file_name_map_list;
\
TK(CPP_CHAR, SPELL_STRING) /* 'char' */ \
TK(CPP_WCHAR, SPELL_STRING) /* L'char' */ \
TK(CPP_OTHER, SPELL_CHAR) /* stray punctuation */ \
TK(CPP_OTHER, SPELL_NUMBER) /* stray punctuation */ \
\
TK(CPP_STRING, SPELL_STRING) /* "string" */ \
TK(CPP_WSTRING, SPELL_STRING) /* L"string" */ \
@ -184,7 +184,6 @@ struct cpp_token
const cpp_token *source; /* Inherit padding from this token. */
struct cpp_string str; /* A string, or number. */
unsigned int arg_no; /* Argument no. for a CPP_MACRO_ARG. */
unsigned char c; /* Character represented by CPP_OTHER. */
} val;
};

View File

@ -395,7 +395,7 @@ stringify_arg (pfile, arg)
else
dest = cpp_spell_token (pfile, token, dest);
if (token->type == CPP_OTHER && token->val.c == '\\')
if (token->type == CPP_OTHER && token->val.str.text[0] == '\\')
backslash_count++;
else
backslash_count = 0;