You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1009 B

11 years ago
#ifndef TOKEN_H_
#define TOKEN_H_
#include <clang-c/Index.h>
11 years ago
#include "SourceLocation.h"
#include "SourceRange.h"
#include "Cursor.h"
#include <string>
11 years ago
namespace clang {
enum TokenKind {
Token_Punctuation,
Token_Keyword,
Token_Identifier,
Token_Literal,
Token_Comment
};
11 years ago
class Token {
friend class Tokens;
Token(CXTranslationUnit &cx_tu, CXToken &cx_token, CXCursor &cx_cursor):
11 years ago
cx_tu(cx_tu), cx_token(cx_token), cx_cursor(cx_cursor), offsets(get_source_range().get_offsets()) {};
public:
const TokenKind get_kind();
std::string get_spelling();
SourceLocation get_source_location();
11 years ago
SourceRange get_source_range();
clang::Cursor get_cursor() {return clang::Cursor(cx_cursor);}
bool has_type();
std::string get_type();
std::string get_brief_comments();
CXTranslationUnit &cx_tu;
CXToken& cx_token;
CXCursor& cx_cursor;
std::pair<clang::Offset, clang::Offset> offsets;
11 years ago
};
} // namespace clang
#endif // TOKEN_H_