TokenId should take tokens length + 1 when determining integral type to make room for tok!""

This commit is contained in:
Andrej Mitrovic 2014-02-11 11:53:28 +01:00
parent 2293c33420
commit e6109eebdc
1 changed files with 3 additions and 3 deletions

View File

@ -118,11 +118,11 @@ module stdx.lexer;
template TokenIdType(alias staticTokens, alias dynamicTokens,
alias possibleDefaultTokens)
{
static if ((staticTokens.length + dynamicTokens.length + possibleDefaultTokens.length) <= ubyte.max)
static if ((staticTokens.length + dynamicTokens.length + possibleDefaultTokens.length + 1) <= ubyte.max)
alias TokenIdType = ubyte;
else static if ((staticTokens.length + dynamicTokens.length + possibleDefaultTokens.length) <= ushort.max)
else static if ((staticTokens.length + dynamicTokens.length + possibleDefaultTokens.length + 1) <= ushort.max)
alias TokenIdType = ushort;
else static if ((staticTokens.length + dynamicTokens.length + possibleDefaultTokens.length) <= uint.max)
else static if ((staticTokens.length + dynamicTokens.length + possibleDefaultTokens.length + 1) <= uint.max)
alias TokenIdType = uint;
else
static assert (false);