diff options
| author | Linus Torvalds <torvalds@home.osdl.org> | 2003-08-02 15:52:22 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:00:59 -0700 |
| commit | 69fc106c8ef3d655e2bcb8be64cccefbd0383dc2 (patch) | |
| tree | 448c3aa7201d663320ef1b5ef827ce9921fd0bc7 /tokenize.c | |
| parent | 7da90b157ff1d292de6fb5361f60fb80752ce466 (diff) | |
| download | sparse-dev-69fc106c8ef3d655e2bcb8be64cccefbd0383dc2.tar.gz | |
Make the tokenizer recognize FP tokens, even if we don't
actually handle them correctly later on yet.
Diffstat (limited to 'tokenize.c')
| -rw-r--r-- | tokenize.c | 45 |
1 files changed, 44 insertions, 1 deletions
@@ -280,11 +280,54 @@ static int get_base_number(unsigned int base, char **p, int next, stream_t *stre return next; } +static int do_fp(char *buffer, int len, int next, stream_t *stream) +{ + struct token *token = stream->token; + void *buf; + + /* Get the decimal part */ + if (next == '.') { + buffer[len++] = next; + next = nextchar(stream); + while (next >= '0' && next <= '9') { + buffer[len++] = next; + next = nextchar(stream); + } + } + + /* Get the exponential part */ + if (next == 'e' || next == 'E') { + buffer[len++] = next; + next = nextchar(stream); + while (next >= '0' && next <= '9') { + buffer[len++] = next; + next = nextchar(stream); + } + } + + /* Get the 'lf' type specifiers */ + while (next == 'f' || next == 'F' || next == 'l' || next == 'L') { + buffer[len++] = next; + next = nextchar(stream); + } + + buffer[len++] = '\0'; + buf = __alloc_bytes(len); + memcpy(buf, buffer, len); + token_type(token) = TOKEN_FP; + token->fp = buf; + add_token(stream); + return next; +} + static int do_integer(char *buffer, int len, int next, stream_t *stream) { struct token *token = stream->token; void *buf; - + + if (next == '.' || next == 'e' || next == 'E') + return do_fp(buffer, len, next, stream); + while (next == 'u' || next == 'U' || next == 'l' || next == 'L') { buffer[len++] = next; next = nextchar(stream); |
