Merge pull request #101 from AndrejMitrovic/FixTokenIdIndex

TokenId should take tokens length + 1 when determining integral type to make room for tok!""
This commit is contained in:
Hackerpilot 2014-02-11 09:59:50 -08:00
commit 4ec32b5772
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);