summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-token.cpp
blob: a8238eb6c682526d43893f62c4d9e501b91b047b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// slang-token.cpp
#include "slang-token.h"

#include <assert.h>

namespace Slang {


Name* Token::getName() const
{
    return getNameOrNull();
}

Name* Token::getNameOrNull() const
{
    switch (type)
    {
    default:
        return nullptr;

    case TokenType::Identifier:
        return (Name*) ptrValue;
    }
}

char const* TokenTypeToString(TokenType type)
{
    switch( type )
    {
    default:
        SLANG_ASSERT(!"unexpected");
        return "<uknown>";

#define TOKEN(NAME, DESC) case TokenType::NAME: return DESC;
#include "slang-token-defs.h"
    }
}

} // namespace Slang