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-09-04 21:45:34 +00:00
|
|
|
#include "llvm/MC/MCAsmInfo.h"
|
2009-10-26 01:35:46 +00:00
|
|
|
#include "llvm/System/DataTypes.h"
|
2009-06-21 07:19:10 +00:00
|
|
|
#include <string>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class MemoryBuffer;
|
|
|
|
class SourceMgr;
|
|
|
|
class SMLoc;
|
2009-09-04 21:45:34 +00:00
|
|
|
class MCAsmInfo;
|
2009-06-21 07:19:10 +00:00
|
|
|
|
|
|
|
/// 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;
|
2009-09-27 19:38:39 +00:00
|
|
|
const MCAsmInfo &MAI;
|
2009-06-21 07:19:10 +00:00
|
|
|
|
|
|
|
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:
|
2009-09-04 21:45:34 +00:00
|
|
|
AsmLexer(SourceMgr &SrcMgr, const MCAsmInfo &MAI);
|
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-09-16 18:08:00 +00:00
|
|
|
|
|
|
|
bool isAtStartOfComment(char Char);
|
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);
|
|
|
|
|
2010-01-19 06:22:22 +00:00
|
|
|
const MCAsmInfo &getMAI() const { return MAI; }
|
|
|
|
|
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 LexSlash();
|
|
|
|
AsmToken LexLineComment();
|
|
|
|
AsmToken LexDigit();
|
|
|
|
AsmToken LexQuote();
|
2009-06-21 07:19:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|