Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TracySourceTokenizer.hpp « server - github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 038f1f126e1780006790786ca65fb63ba7715f17 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef __TRACYSOURCETOKENIZER_HPP__
#define __TRACYSOURCETOKENIZER_HPP__

#include <stdint.h>
#include <vector>

namespace tracy
{

class Tokenizer
{
public:
    enum class TokenColor : uint8_t
    {
        Default,
        Comment,
        Preprocessor,
        String,
        CharacterLiteral,
        Keyword,
        Number,
        Punctuation,
        Type,
        Special
    };

    struct Token
    {
        const char* begin;
        const char* end;
        TokenColor color;
    };

    struct Line
    {
        const char* begin;
        const char* end;
        std::vector<Token> tokens;
    };

    enum class AsmTokenColor : uint8_t
    {
        Label,          // no-op, padding
        Default,        // '+', '[', '*', etc
        SizeDirective,  // byte, word, dword, etc
        Register,       // rax, rip, etc
        Literal,        // 0x04, etc
    };

    struct AsmToken
    {
        const char* begin;
        const char* end;
        AsmTokenColor color;
    };

    Tokenizer();

    std::vector<Token> Tokenize( const char* begin, const char* end );
    std::vector<AsmToken> TokenizeAsm( const char* begin, const char* end );

private:
    TokenColor IdentifyToken( const char*& begin, const char* end );
    AsmTokenColor IdentifyAsmToken( const char*& begin, const char* end );

    bool m_isInComment;
    bool m_isInPreprocessor;
};

}

#endif