1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Add C++ tokenizer.

This commit is contained in:
Bartosz Taudul
2020-04-24 23:48:18 +02:00
parent c87c464f23
commit 3e583b1373
2 changed files with 290 additions and 1 deletions
+37
View File
@@ -17,10 +17,30 @@ class Worker;
class SourceView
{
enum class TokenColor : uint8_t
{
Default,
Comment,
Preprocessor,
String,
CharacterLiteral,
Keyword,
Number,
Punctuation
};
struct Token
{
const char* begin;
const char* end;
TokenColor color;
};
struct Line
{
const char* begin;
const char* end;
std::vector<Token> tokens;
};
struct AsmLine
@@ -76,6 +96,21 @@ private:
void GatherIpStats( uint64_t addr, uint32_t& iptotalSrc, uint32_t& iptotalAsm, unordered_flat_map<uint64_t, uint32_t>& ipcountSrc, unordered_flat_map<uint64_t, uint32_t>& ipcountAsm, uint32_t& ipmaxSrc, uint32_t& ipmaxAsm, const Worker& worker );
TokenColor IdentifyToken( const char*& begin, const char* end );
std::vector<Token> Tokenize( const char* begin, const char* end );
struct TokenizerState
{
void Reset()
{
isInComment = false;
isInPreprocessor = false;
}
bool isInComment;
bool isInPreprocessor;
};
ImFont* m_font;
const char* m_file;
uint32_t m_fileStringIdx;
@@ -112,6 +147,8 @@ private:
uint32_t m_maxLine;
int m_maxMnemonicLen;
TokenizerState m_tokenizer;
};
}