summaryrefslogtreecommitdiff
path: root/lib/AsmParser/LLLexer.h
blob: 7eaa9f9d0ab70e906a1f0f3ae5f45aa4e0a93d40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//===- LLLexer.h - Lexer for LLVM 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 represents the Lexer for .ll files.
//
//===----------------------------------------------------------------------===//

#ifndef LIB_ASMPARSER_LLLEXER_H
#define LIB_ASMPARSER_LLLEXER_H

#include <vector>
#include <string>
#include <iosfwd>

namespace llvm {
  class MemoryBuffer;
  
  class LLLexer {
    const char *CurPtr;
    unsigned CurLineNo;
    MemoryBuffer *CurBuf;
    
    const char *TokStart;
    
    std::string TheError;
  public:
    LLLexer(MemoryBuffer *StartBuf);
    ~LLLexer() {}

    const char *getTokStart() const { return TokStart; }
    unsigned getTokLength() const { return CurPtr-TokStart; }
    unsigned getLineNo() const { return CurLineNo; }
    std::string getFilename() const;
    int LexToken();
    
    const std::string getError() const { return TheError; }
    
  private:
    int getNextChar();
    void SkipLineComment();
    int LexIdentifier();
    int LexDigitOrNegative();
    int LexPositive();
    int LexAt();
    int LexPercent();
    int LexQuote();
    int Lex0x();
  };
} // end namespace llvm

#endif