1
//===-- llvm/Target/TargetAsmLexer.h - Target Assembly Lexer ----*- C++ -*-===//
3
// The LLVM Compiler Infrastructure
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
8
//===----------------------------------------------------------------------===//
10
#ifndef LLVM_TARGET_TARGETASMLEXER_H
11
#define LLVM_TARGET_TARGETASMLEXER_H
13
#include "llvm/MC/MCParser/MCAsmLexer.h"
18
/// TargetAsmLexer - Generic interface to target specific assembly lexers.
19
class TargetAsmLexer {
23
/// The location and description of the current error
27
TargetAsmLexer(const TargetAsmLexer &); // DO NOT IMPLEMENT
28
void operator=(const TargetAsmLexer &); // DO NOT IMPLEMENT
29
protected: // Can only create subclasses.
30
TargetAsmLexer(const Target &);
32
virtual AsmToken LexToken() = 0;
34
void SetError(const SMLoc &errLoc, const std::string &err) {
39
/// TheTarget - The Target that this machine was created for.
40
const Target &TheTarget;
44
virtual ~TargetAsmLexer();
46
const Target &getTarget() const { return TheTarget; }
48
/// InstallLexer - Set the lexer to get tokens from lower-level lexer \arg L.
49
void InstallLexer(MCAsmLexer &L) {
53
MCAsmLexer *getLexer() {
57
/// Lex - Consume the next token from the input stream and return it.
58
const AsmToken &Lex() {
59
return CurTok = LexToken();
62
/// getTok - Get the current (last) lexed token.
63
const AsmToken &getTok() {
67
/// getErrLoc - Get the current error location
68
const SMLoc &getErrLoc() {
72
/// getErr - Get the current error string
73
const std::string &getErr() {
77
/// getKind - Get the kind of current token.
78
AsmToken::TokenKind getKind() const { return CurTok.getKind(); }
80
/// is - Check if the current token has kind \arg K.
81
bool is(AsmToken::TokenKind K) const { return CurTok.is(K); }
83
/// isNot - Check if the current token has kind \arg K.
84
bool isNot(AsmToken::TokenKind K) const { return CurTok.isNot(K); }
87
} // End llvm namespace