tan  0.0.1
tokenized_source_file.h
1 #ifndef __TAN_SRC_AST_SOURCE_MANAGER_H__
2 #define __TAN_SRC_AST_SOURCE_MANAGER_H__
3 #include "base.h"
4 
5 namespace tanlang {
6 
7 /**
8  * \brief Different from SourceFile, TokenizedSourceFile manages the tokenized text of a source file.
9  */
11 public:
12  TokenizedSourceFile() = delete;
13  TokenizedSourceFile(str filename, vector<Token *> tokens);
14  Token *get_token(uint32_t loc) const;
15  uint32_t get_line(uint32_t loc) const;
16  uint32_t get_col(uint32_t loc) const;
17  str get_token_str(uint32_t loc) const;
18  Token *get_last_token() const;
19  bool is_eof(uint32_t loc) const;
20  str get_filename() const;
21  str get_src_location_str(uint32_t loc) const;
22  SourceFile *src() const;
23 
24  str get_source_code(uint32_t start, uint32_t end) const;
25 
26 private:
27  str _filename;
28  vector<Token *> _tokens;
29 };
30 
31 } // namespace tanlang
32 
33 #endif //__TAN_SRC_AST_SOURCE_MANAGER_H__
Different from SourceFile, TokenizedSourceFile manages the tokenized text of a source file.