aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Li <sparse@chrisli.org>2010-06-17 17:08:09 -0700
committerChristopher Li <sparse@chrisli.org>2010-06-17 17:21:10 -0700
commit49adf11b99cfce04ddcae7be0a272cc2df31436d (patch)
treeb2cf5af2e39f0162f555a943819875528834cfc1 /tokenize.c
parentAllow parsing L'\0' (diff)
downloadsparse-49adf11b99cfce04ddcae7be0a272cc2df31436d.tar.gz
sparse-49adf11b99cfce04ddcae7be0a272cc2df31436d.tar.bz2
sparse-49adf11b99cfce04ddcae7be0a272cc2df31436d.zip
Parsing wide char string
A follow up change to parse the wide char string. It currently only parse and store it like normal strings. Need more change to reflect the base type and size etc. Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'tokenize.c')
-rw-r--r--tokenize.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/tokenize.c b/tokenize.c
index cf05826..4c97517 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -137,6 +137,7 @@ const char *show_token(const struct token *token)
return show_ident(token->ident);
case TOKEN_STRING:
+ case TOKEN_WIDE_STRING:
return show_string(token->string);
case TOKEN_NUMBER:
@@ -146,7 +147,7 @@ const char *show_token(const struct token *token)
return show_special(token->special);
case TOKEN_CHAR:
- case TOKEN_LONG_CHAR: {
+ case TOKEN_WIDE_CHAR: {
char *ptr = buffer;
int c = token->character;
*ptr++ = '\'';
@@ -548,7 +549,7 @@ static int get_char_token(int next, stream_t *stream, enum token_type type)
return nextchar(stream);
}
-static int get_string_token(int next, stream_t *stream)
+static int get_string_token(int next, stream_t *stream, enum token_type type)
{
static char buffer[MAX_STRING];
struct string *string;
@@ -581,7 +582,7 @@ static int get_string_token(int next, stream_t *stream)
/* Pass it on.. */
token = stream->token;
- token_type(token) = TOKEN_STRING;
+ token_type(token) = type;
token->string = string;
add_token(stream);
@@ -701,7 +702,7 @@ static int get_one_special(int c, stream_t *stream)
return get_one_number(c, next, stream);
break;
case '"':
- return get_string_token(next, stream);
+ return get_string_token(next, stream, TOKEN_STRING);
case '\'':
return get_char_token(next, stream, TOKEN_CHAR);
case '/':
@@ -881,8 +882,12 @@ static int get_one_identifier(int c, stream_t *stream)
ident = create_hashed_ident(buf, len, hash);
- if (ident == &L_ident && next == '\'')
- return get_char_token(nextchar(stream), stream, TOKEN_LONG_CHAR);
+ if (ident == &L_ident) {
+ if (next == '\'')
+ return get_char_token(nextchar(stream), stream, TOKEN_WIDE_CHAR);
+ if (next == '\"')
+ return get_string_token(nextchar(stream), stream, TOKEN_WIDE_STRING);
+ }
/* Pass it on.. */
token = stream->token;