tan  0.0.1
source_traceable.h
1 #ifndef __TAN_SRC_AST_SOURCE_TRACEABLE_H__
2 #define __TAN_SRC_AST_SOURCE_TRACEABLE_H__
3 #include "base.h"
4 #include "source_file/tokenized_source_file.h"
5 
6 namespace tanlang {
7 
8 /**
9  * \brief Different from SourceSpan, TokenSpan operates on the token level.
10  */
11 class TokenSpan {
12 public:
13  TokenSpan() = delete;
14  TokenSpan(uint32_t start, uint32_t end);
15 
16  uint32_t _start = 0;
17  uint32_t _end = 0;
18 };
19 
20 /**
21  * \brief Represents the nodes that can be traced back to tokens in the source file.
22  */
24 public:
25  SourceTraceable() = delete;
27  [[nodiscard]] uint32_t start() const;
28  [[nodiscard]] uint32_t end() const;
29  void set_start(uint32_t val);
30  void set_end(uint32_t val);
31  TokenizedSourceFile *src() const;
32 
33 private:
34  TokenSpan _span;
35  TokenizedSourceFile *_src;
36 };
37 
38 } // namespace tanlang
39 
40 #endif //__TAN_SRC_AST_SOURCE_TRACEABLE_H__
Represents the nodes that can be traced back to tokens in the source file.
Different from SourceSpan, TokenSpan operates on the token level.
Different from SourceFile, TokenizedSourceFile manages the tokenized text of a source file.