summaryrefslogtreecommitdiff
path: root/parse/tok.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-01-22 18:22:47 -0500
committerOri Bernstein <ori@eigenstate.org>2014-01-22 18:22:47 -0500
commitdef799e175eb9cd20b9cab16dcdca22e1d0bbc29 (patch)
treed9c3524c4e5ea9cbbe8eafd8ba5170a9da510b6e /parse/tok.c
parentf5da3fe38642020090709cd8f76d54d399d7d3b2 (diff)
downloadmc-def799e175eb9cd20b9cab16dcdca22e1d0bbc29.tar.gz
Add single digit division, and make bigint output use it.
Diffstat (limited to 'parse/tok.c')
-rw-r--r--parse/tok.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/parse/tok.c b/parse/tok.c
index b1a0f05..c36eeec 100644
--- a/parse/tok.c
+++ b/parse/tok.c
@@ -623,6 +623,7 @@ static Tok *number(int base)
int start;
int c;
int isfloat;
+ int unsignedval;
t = NULL;
isfloat = 0;
@@ -646,6 +647,55 @@ static Tok *number(int base)
t = mktok(Tintlit);
t->str = strdupn(&fbuf[start], fidx - start);
t->intval = strtol(t->str, NULL, base);
+ /* check suffixes:
+ * u -> unsigned
+ * l -> 64 bit
+ * i -> 32 bit
+ * w -> 16 bit
+ * b -> 8 bit
+ */
+ unsignedval = 0;
+nextsuffix:
+ switch (peek()) {
+ case 'u':
+ if (unsignedval == 1)
+ fatal(line, "Duplicate 'u' integer specifier");
+ next();
+ unsignedval = 1;
+ goto nextsuffix;
+ case 'l':
+ next();
+ if (unsignedval)
+ t->inttype = Tyuint64;
+ else
+ t->inttype = Tyint64;
+ break;
+ case 'i':
+ next();
+ if (unsignedval)
+ t->inttype = Tyuint32;
+ else
+ t->inttype = Tyint32;
+ break;
+ case 's':
+ next();
+ if (unsignedval)
+ t->inttype = Tyuint16;
+ else
+ t->inttype = Tyint16;
+ break;
+ case 'b':
+ next();
+ if (unsignedval)
+ t->inttype = Tyuint8;
+ else
+ t->inttype = Tyint8;
+ break;
+ default:
+ if (unsignedval)
+ fatal(line, "Unrecognized character int type specifier after 'u'");
+ break;
+ }
}
return t;