MLIR: lib/Tools/PDLL/Parser/Lexer.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9 #ifndef LIB_TOOLS_PDLL_PARSER_LEXER_H_

10 #define LIB_TOOLS_PDLL_PARSER_LEXER_H_

11

13 #include "llvm/ADT/StringRef.h"

14 #include "llvm/Support/SMLoc.h"

15

16 namespace llvm {

17 class SourceMgr;

18 }

19

20 namespace mlir {

21 namespace pdll {

22 class CodeCompleteContext;

23

24 namespace ast {

25 class DiagnosticEngine;

26 }

27

28

29

30

31

33 public:

35

38

40

42

43

45

46

52

53

72

73

81

91

92

97 string

100

101

102

104

105

107

108

111 }

112

113

114

115

118 }

119

120

122

123

125

126

128 template <typename... T>

130 return is(k1) || isAny(k2, k3, others...);

131 }

132

133

134 bool isNot(Kind k) const { return k != kind; }

135 template <typename... T>

137 return isAny(k1, k2, others...);

138 }

139

140

141 bool is(Kind k) const { return kind == k; }

142

143

144 SMLoc getStartLoc() const { return SMLoc::getFromPointer(spelling.data()); }

145

147 return SMLoc::getFromPointer(spelling.data() + spelling.size());

148 }

149

151

152 private:

153

155

156

157

158 StringRef spelling;

159 };

160

161

162

163

164

166 public:

170

171

173

174

176

177

178

179

180 LogicalResult pushInclude(StringRef filename, SMRange includeLoc);

181

182

184

185

186

187 void resetPointer(const char *newPointer) { curPtr = newPointer; }

188

189

193 const Twine &note);

194

195 private:

197 return Token(kind, StringRef(tokStart, curPtr - tokStart));

198 }

199

200

201 int getNextChar();

202

203

204 void lexComment();

205 Token lexDirective(const char *tokStart);

206 Token lexIdentifier(const char *tokStart);

207 Token lexNumber(const char *tokStart);

208 Token lexString(const char *tokStart, bool isStringBlock);

209

210 llvm::SourceMgr &srcMgr;

211 int curBufferID;

212 StringRef curBuffer;

213 const char *curPtr;

214

215

217

218

219

220 bool addedHandlerToDiagEngine;

221

222

223 const char *codeCompletionLocation;

224 };

225 }

226 }

227

228 #endif

union mlir::linalg::@1203::ArityGroupAndKind::Kind kind

This class provides an abstract interface into the parser for hooking in code completion events.

Token emitError(SMRange loc, const Twine &msg)

Emit an error to the lexer with the given location and message.

Token emitError(const char *loc, const Twine &msg)

Token emitErrorAndNote(SMRange loc, const Twine &msg, SMRange noteLoc, const Twine &note)

Token lexToken()

Lex the next token and return it.

llvm::SourceMgr & getSourceMgr()

Return a reference to the source manager used by the lexer.

ast::DiagnosticEngine & getDiagEngine()

Return a reference to the diagnostic engine used by the lexer.

void resetPointer(const char *newPointer)

Change the position of the lexer cursor.

LogicalResult pushInclude(StringRef filename, SMRange includeLoc)

Push an include of the given file.

Lexer(llvm::SourceMgr &mgr, ast::DiagnosticEngine &diagEngine, CodeCompleteContext *codeCompleteContext)

bool isNot(Kind k) const

Return if the token does not have the given kind.

bool isNot(Kind k1, Kind k2, T... others) const

bool is(Kind k) const

Return if the token has the given kind.

StringRef getSpelling() const

Return the bytes that make up this token.

SMRange getLoc() const

Return a location for the range of this token.

Token(Kind kind, StringRef spelling)

bool isString() const

Returns true if the current token is a string literal.

bool isDependentKeyword() const

Returns true if the current token is a keyword in a dependent context, and in any other situation (e....

@ code_complete_string

Token signifying a code completion location within a string.

@ code_complete

Token signifying a code completion location.

@ KW_DEPENDENT_BEGIN

Dependent keywords, i.e.

@ less

Paired punctuation.

@ kw_Attr

General keywords.

SMLoc getEndLoc() const

Return a location at the end of this token.

SMLoc getStartLoc() const

Return a location for the start of this token.

bool isAny(Kind k1, Kind k2, Kind k3, T... others) const

bool isAny(Kind k1, Kind k2) const

Return true if this token is one of the specified kinds.

bool isKeyword() const

Returns true if the current token is a keyword.

Kind getKind() const

Return the kind of this token.

std::string getStringValue() const

Given a token containing a string literal, return its value, including removing the quote characters ...

This class manages the construction and emission of PDLL diagnostics.

The OpAsmOpInterface, see OpAsmInterface.td for more details.

Include the generated interface declarations.