LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MCAsmParser.cpp
Go to the documentation of this file.
1 //===-- MCAsmParser.cpp - Abstract Asm Parser Interface -------------------===//
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 
11 #include "llvm/ADT/Twine.h"
15 #include "llvm/Support/Debug.h"
16 #include "llvm/Support/SourceMgr.h"
18 using namespace llvm;
19 
20 MCAsmParser::MCAsmParser() : TargetParser(0), ShowParsedOperands(0) {
21 }
22 
24 }
25 
27  assert(!TargetParser && "Target parser is already initialized!");
28  TargetParser = &P;
29  TargetParser->Initialize(*this);
30 }
31 
33  return getLexer().getTok();
34 }
35 
36 bool MCAsmParser::TokError(const Twine &Msg, ArrayRef<SMRange> Ranges) {
37  Error(getLexer().getLoc(), Msg, Ranges);
38  return true;
39 }
40 
42  SMLoc L;
43  return parseExpression(Res, L);
44 }
45 
47 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
48  dbgs() << " " << *this;
49 #endif
50 }
virtual void Initialize(MCAsmParser &Parser)
Initialize the extension for parsing using the given Parser. The extension should use the AsmParser i...
MCTargetAsmParser - Generic interface to target specific assembly parsers.
const AsmToken & getTok()
getTok - Get the current (last) lexed token.
Definition: MCAsmLexer.h:148
bool TokError(const Twine &Msg, ArrayRef< SMRange > Ranges=None)
Report an error at the current lexer location.
Definition: MCAsmParser.cpp:36
AsmToken - Target independent representation for an assembler token.
Definition: MCAsmLexer.h:21
virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc)=0
const AsmToken & getTok()
getTok - Get the current AsmToken from the stream.
Definition: MCAsmParser.cpp:32
#define P(N)
virtual ~MCAsmParser()
Definition: MCAsmParser.cpp:23
virtual MCAsmLexer & getLexer()=0
virtual bool Error(SMLoc L, const Twine &Msg, ArrayRef< SMRange > Ranges=None)=0
virtual void dump() const
dump - Print to the debug stream.
Definition: MCAsmParser.cpp:46
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
Definition: Debug.cpp:101
void setTargetParser(MCTargetAsmParser &P)
Definition: MCAsmParser.cpp:26
Represents a location in source code.
Definition: SMLoc.h:23