LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AsmLexer.h
Go to the documentation of this file.
1 //===- AsmLexer.h - Lexer for Assembly Files --------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This class declares the lexer for assembly files.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_MC_MCPARSER_ASMLEXER_H
15 #define LLVM_MC_MCPARSER_ASMLEXER_H
16 
17 #include "llvm/ADT/StringRef.h"
19 #include "llvm/Support/DataTypes.h"
20 #include <string>
21 
22 namespace llvm {
23 class MemoryBuffer;
24 class MCAsmInfo;
25 
26 /// AsmLexer - Lexer class for assembly files.
27 class AsmLexer : public MCAsmLexer {
28  const MCAsmInfo &MAI;
29 
30  const char *CurPtr;
31  const MemoryBuffer *CurBuf;
32  bool isAtStartOfLine;
33 
34  void operator=(const AsmLexer&) LLVM_DELETED_FUNCTION;
36 
37 protected:
38  /// LexToken - Read the next token and return its code.
39  virtual AsmToken LexToken();
40 
41 public:
42  AsmLexer(const MCAsmInfo &MAI);
43  ~AsmLexer();
44 
45  void setBuffer(const MemoryBuffer *buf, const char *ptr = NULL);
46 
49 
50  bool isAtStartOfComment(char Char);
51  bool isAtStatementSeparator(const char *Ptr);
52 
53  const MCAsmInfo &getMAI() const { return MAI; }
54 
55 private:
56  int getNextChar();
57  AsmToken ReturnError(const char *Loc, const std::string &Msg);
58 
59  AsmToken LexIdentifier();
60  AsmToken LexSlash();
61  AsmToken LexLineComment();
62  AsmToken LexDigit();
63  AsmToken LexSingleQuote();
64  AsmToken LexQuote();
65  AsmToken LexFloatLiteral();
66  AsmToken LexHexFloatLiteral(bool NoIntDigits);
67 };
68 
69 } // end namespace llvm
70 
71 #endif
virtual AsmToken LexToken()
LexToken - Read the next token and return its code.
Definition: AsmLexer.cpp:449
virtual StringRef LexUntilEndOfStatement()
Definition: AsmLexer.cpp:415
AsmLexer - Lexer class for assembly files.
Definition: AsmLexer.h:27
AsmToken - Target independent representation for an assembler token.
Definition: MCAsmLexer.h:21
StringRef LexUntilEndOfLine()
Definition: AsmLexer.cpp:428
bool isAtStatementSeparator(const char *Ptr)
Definition: AsmLexer.cpp:444
#define LLVM_DELETED_FUNCTION
Definition: Compiler.h:137
void setBuffer(const MemoryBuffer *buf, const char *ptr=NULL)
Definition: AsmLexer.cpp:33
const MCAsmInfo & getMAI() const
Definition: AsmLexer.h:53
bool isAtStartOfComment(char Char)
Definition: AsmLexer.cpp:439