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"
|
2010-01-22 01:44:57 +00:00
|
|
|
#include "llvm/MC/MCParser/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 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-09-27 19:38:39 +00:00
|
|
|
const MCAsmInfo &MAI;
|
2009-06-21 07:19:10 +00:00
|
|
|
|
|
|
|
const char *CurPtr;
|
|
|
|
const MemoryBuffer *CurBuf;
|
|
|
|
|
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:
|
2010-01-21 00:19:58 +00:00
|
|
|
AsmLexer(const MCAsmInfo &MAI);
|
2009-06-24 00:33:19 +00:00
|
|
|
~AsmLexer();
|
2009-06-21 07:19:10 +00:00
|
|
|
|
2010-01-21 00:19:58 +00:00
|
|
|
void setBuffer(const MemoryBuffer *buf, const char *ptr = NULL);
|
|
|
|
|
2010-07-12 20:32:33 +00:00
|
|
|
virtual StringRef LexUntilEndOfStatement();
|
2009-09-16 18:08:00 +00:00
|
|
|
|
|
|
|
bool isAtStartOfComment(char Char);
|
2009-07-16 06:14:39 +00:00
|
|
|
|
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();
|
2010-09-27 20:12:52 +00:00
|
|
|
AsmToken LexFloatLiteral();
|
2009-06-21 07:19:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|