aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tokenize.c
diff options
authorLinus Torvalds <torvalds@home.osdl.org>2003-08-02 15:52:22 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:00:59 -0700
commit69fc106c8ef3d655e2bcb8be64cccefbd0383dc2 (patch)
tree448c3aa7201d663320ef1b5ef827ce9921fd0bc7 /tokenize.c
parent7da90b157ff1d292de6fb5361f60fb80752ce466 (diff)
downloadsparse-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.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/tokenize.c b/tokenize.c
index 7b8e01b3..4b80bc2f 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -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);