#define TGLEXER_H
#include "llvm/Support/DataTypes.h"
-#include <vector>
#include <string>
-#include <iosfwd>
+#include <vector>
#include <cassert>
namespace llvm {
class MemoryBuffer;
-class TGSourceMgr;
-class TGLoc;
-
+class SourceMgr;
+class SMLoc;
+class Twine;
+
namespace tgtok {
enum TokKind {
// Markers
l_brace, r_brace, // { }
l_paren, r_paren, // ( )
less, greater, // < >
- colon, semi, // ; :
+ colon, semi, // : ;
comma, period, // , .
equal, question, // = ?
MultiClass, String,
// !keywords.
- XConcat, XSRA, XSRL, XSHL, XStrConcat, XNameConcat, XCast, XSubst,
- XForEach,
+ XConcat, XSRA, XSRL, XSHL, XStrConcat, XCast, XSubst,
+ XForEach, XHead, XTail, XEmpty, XIf, XEq,
// Integer value.
IntVal,
/// TGLexer - TableGen Lexer class.
class TGLexer {
- TGSourceMgr &SrcMgr;
+ SourceMgr &SrcMgr;
const char *CurPtr;
const MemoryBuffer *CurBuf;
/// CurBuffer - This is the current buffer index we're lexing from as managed
/// by the SourceMgr object.
int CurBuffer;
+ /// Dependencies - This is the list of all included files.
+ std::vector<std::string> Dependencies;
- // IncludeDirectories - This is the list of directories we should search for
- // include files in.
- std::vector<std::string> IncludeDirectories;
public:
- TGLexer(TGSourceMgr &SrcMgr);
+ TGLexer(SourceMgr &SrcMgr);
~TGLexer() {}
- void setIncludeDirs(const std::vector<std::string> &Dirs) {
- IncludeDirectories = Dirs;
- }
-
tgtok::TokKind Lex() {
return CurCode = LexToken();
}
+
+ const std::vector<std::string> &getDependencies() const {
+ return Dependencies;
+ }
tgtok::TokKind getCode() const { return CurCode; }
return CurIntVal;
}
- TGLoc getLoc() const;
-
- void PrintError(const char *Loc, const std::string &Msg) const;
- void PrintError(TGLoc Loc, const std::string &Msg) const;
+ SMLoc getLoc() const;
private:
/// LexToken - Read the next token and return its code.
tgtok::TokKind LexToken();
- tgtok::TokKind ReturnError(const char *Loc, const std::string &Msg);
+ tgtok::TokKind ReturnError(const char *Loc, const Twine &Msg);
int getNextChar();
void SkipBCPLComment();