blob: 7eaa9f9d0ab70e906a1f0f3ae5f45aa4e0a93d40 [file] [log] [blame]
Chris Lattner8e3a8e02007-11-18 08:46:26 +00001//===- LLLexer.h - Lexer for LLVM Assembly Files ----------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattner8e3a8e02007-11-18 08:46:26 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This class represents the Lexer for .ll files.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LIB_ASMPARSER_LLLEXER_H
15#define LIB_ASMPARSER_LLLEXER_H
16
17#include <vector>
18#include <string>
19#include <iosfwd>
20
21namespace llvm {
22 class MemoryBuffer;
23
24 class LLLexer {
25 const char *CurPtr;
26 unsigned CurLineNo;
27 MemoryBuffer *CurBuf;
28
29 const char *TokStart;
30
31 std::string TheError;
32 public:
33 LLLexer(MemoryBuffer *StartBuf);
34 ~LLLexer() {}
35
36 const char *getTokStart() const { return TokStart; }
37 unsigned getTokLength() const { return CurPtr-TokStart; }
38 unsigned getLineNo() const { return CurLineNo; }
39 std::string getFilename() const;
40 int LexToken();
41
42 const std::string getError() const { return TheError; }
43
44 private:
45 int getNextChar();
46 void SkipLineComment();
47 int LexIdentifier();
48 int LexDigitOrNegative();
49 int LexPositive();
50 int LexAt();
51 int LexPercent();
52 int LexQuote();
53 int Lex0x();
54 };
55} // end namespace llvm
56
57#endif