diff options
| author | Sean Callanan <scallanan@apple.com> | 2010-01-22 22:35:01 +0000 |
|---|---|---|
| committer | Sean Callanan <scallanan@apple.com> | 2010-01-22 22:35:01 +0000 |
| commit | 5c84cd9c388004b62370b44e6f65353064084386 (patch) | |
| tree | 578f5d6809d001e8f4d58909be4dd33e5c71e6cf /llvm | |
| parent | 60794cfa2795a1696b55ca08ec5dafcc252f7d59 (diff) | |
| download | bcm5719-llvm-5c84cd9c388004b62370b44e6f65353064084386.tar.gz bcm5719-llvm-5c84cd9c388004b62370b44e6f65353064084386.zip | |
Filled out the skeleton of the TargetAsmLexer to behave
exactly like an MCAsmLexer. (The difference is that the
TargetAsmLexer knows how to handle target-specific stuff
like registers, whereas the MCAsmLexer is fully generic.)
llvm-svn: 94237
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/Target/TargetAsmLexer.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/llvm/include/llvm/Target/TargetAsmLexer.h b/llvm/include/llvm/Target/TargetAsmLexer.h index 998f5babcb3..daba1ba88b9 100644 --- a/llvm/include/llvm/Target/TargetAsmLexer.h +++ b/llvm/include/llvm/Target/TargetAsmLexer.h @@ -10,16 +10,32 @@ #ifndef LLVM_TARGET_TARGETASMLEXER_H #define LLVM_TARGET_TARGETASMLEXER_H +#include "llvm/MC/MCParser/MCAsmLexer.h" + namespace llvm { class Target; /// TargetAsmLexer - Generic interface to target specific assembly lexers. class TargetAsmLexer { + /// The current token + AsmToken CurTok; + + /// The location and description of the current error + SMLoc ErrLoc; + std::string Err; + TargetAsmLexer(const TargetAsmLexer &); // DO NOT IMPLEMENT void operator=(const TargetAsmLexer &); // DO NOT IMPLEMENT protected: // Can only create subclasses. TargetAsmLexer(const Target &); + virtual AsmToken LexToken() = 0; + + void SetError(const SMLoc &errLoc, const std::string &err) { + ErrLoc = errLoc; + Err = err; + } + /// TheTarget - The Target that this machine was created for. const Target &TheTarget; @@ -28,7 +44,34 @@ public: const Target &getTarget() const { return TheTarget; } + /// Lex - Consume the next token from the input stream and return it. + const AsmToken &Lex() { + return CurTok = LexToken(); + } + + /// getTok - Get the current (last) lexed token. + const AsmToken &getTok() { + return CurTok; + } + + /// getErrLoc - Get the current error location + const SMLoc &getErrLoc() { + return ErrLoc; + } + + /// getErr - Get the current error string + const std::string &getErr() { + return Err; + } + + /// getKind - Get the kind of current token. + AsmToken::TokenKind getKind() const { return CurTok.getKind(); } + + /// is - Check if the current token has kind \arg K. + bool is(AsmToken::TokenKind K) const { return CurTok.is(K); } + /// isNot - Check if the current token has kind \arg K. + bool isNot(AsmToken::TokenKind K) const { return CurTok.isNot(K); } }; } // End llvm namespace |

