9 #ifndef Sawyer_Clexer_H
10 #define Sawyer_Clexer_H
12 #include <Sawyer/Sawyer.h>
14 #include <Sawyer/Assert.h>
15 #include <Sawyer/Buffer.h>
16 #include <Sawyer/LineVector.h>
47 Token(): type_(TOK_EOF), begin_(0), end_(0) {}
49 Token(TokenType type,
size_t begin,
size_t end)
50 : type_(type), begin_(begin), end_(end) {
51 ASSERT_require(end >= begin);
54 TokenType type()
const {
60 std::string fileName_;
63 std::vector<Token> tokens_;
64 bool skipPreprocessorTokens_;
67 : fileName_(fileName), content_(fileName), at_(0), skipPreprocessorTokens_(
true) {}
70 : fileName_(fileName), content_(buffer), at_(0), skipPreprocessorTokens_(
true) {}
72 const std::string fileName()
const {
return fileName_; }
74 bool skipPreprocessorTokens()
const {
return skipPreprocessorTokens_; }
75 void skipPreprocessorTokens(
bool b) { skipPreprocessorTokens_ = b; }
77 const Token& operator[](
size_t lookahead);
79 void consume(
size_t n = 1);
81 std::string lexeme(
const Token &t)
const;
83 std::string toString(
const Token &t)
const;
86 std::string line(
const Token &t)
const;
88 bool matches(
const Token &token,
const char *s2)
const;
90 void emit(std::ostream &out,
const std::string &fileName,
const Token &token,
const std::string &message)
const;
92 void emit(std::ostream &out,
const std::string &fileName,
const Token &begin,
const Token &locus,
const Token &end,
93 const std::string &message)
const;
95 std::pair<size_t, size_t> location(
const Token &token)
const;
A buffer of characters indexed by line number.
ROSE_DLL_API std::string toString(const Attributes &)
Convert attributes to GraphViz language string.
Reference-counting intrusive smart pointer.
Name space for the entire library.
const char * Language(int64_t)
Convert ClangToDotTranslator::Language enum constant to a string.