2009-06-21 07:19:10 +00:00
|
|
|
//===- AsmLexer.h - Lexer for Assembly Files --------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This class declares the lexer for assembly files.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef ASMLEXER_H
|
|
|
|
#define ASMLEXER_H
|
|
|
|
|
2009-07-27 21:49:56 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2009-07-20 20:01:54 +00:00
|
|
|
#include "llvm/MC/MCAsmLexer.h"
|
2009-06-21 07:19:10 +00:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
|
|
|
#include <string>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class MemoryBuffer;
|
|
|
|
class SourceMgr;
|
|
|
|
class SMLoc;
|
|
|
|
|
|
|
|
/// AsmLexer - Lexer class for assembly files.
|
2009-07-20 20:01:54 +00:00
|
|
|
class AsmLexer : public MCAsmLexer {
|
2009-06-21 07:19:10 +00:00
|
|
|
SourceMgr &SrcMgr;
|
|
|
|
|
|
|
|
const char *CurPtr;
|
|
|
|
const MemoryBuffer *CurBuf;
|
|
|
|
|
|
|
|
const char *TokStart;
|
2009-07-28 03:00:54 +00:00
|
|
|
|
|
|
|
/// This is the current buffer index we're lexing from as managed by the
|
|
|
|
/// SourceMgr object.
|
2009-06-21 07:19:10 +00:00
|
|
|
int CurBuffer;
|
|
|
|
|
2009-06-24 00:33:19 +00:00
|
|
|
void operator=(const AsmLexer&); // DO NOT IMPLEMENT
|
|
|
|
AsmLexer(const AsmLexer&); // DO NOT IMPLEMENT
|
2009-07-28 17:58:44 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/// LexToken - Read the next token and return its code.
|
|
|
|
virtual AsmToken LexToken();
|
|
|
|
|
2009-06-21 07:19:10 +00:00
|
|
|
public:
|
|
|
|
AsmLexer(SourceMgr &SrcMgr);
|
2009-06-24 00:33:19 +00:00
|
|
|
~AsmLexer();
|
2009-06-21 07:19:10 +00:00
|
|
|
|
|
|
|
SMLoc getLoc() const;
|
2009-08-10 01:39:42 +00:00
|
|
|
|
|
|
|
StringRef LexUntilEndOfStatement();
|
|
|
|
|
2009-07-28 17:58:44 +00:00
|
|
|
|
2009-07-16 06:14:39 +00:00
|
|
|
/// EnterIncludeFile - Enter the specified file. This returns true on failure.
|
|
|
|
bool EnterIncludeFile(const std::string &Filename);
|
|
|
|
|
2009-06-30 00:49:23 +00:00
|
|
|
void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type) const;
|
2009-06-21 07:19:10 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
int getNextChar();
|
2009-07-28 03:00:54 +00:00
|
|
|
AsmToken ReturnError(const char *Loc, const std::string &Msg);
|
2009-06-21 07:19:10 +00:00
|
|
|
|
2009-07-28 03:00:54 +00:00
|
|
|
AsmToken LexIdentifier();
|
|
|
|
AsmToken LexPercent();
|
|
|
|
AsmToken LexSlash();
|
|
|
|
AsmToken LexLineComment();
|
|
|
|
AsmToken LexDigit();
|
|
|
|
AsmToken LexQuote();
|
2009-06-21 07:19:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|