LLVM  14.0.0git
TGLexer.cpp
Go to the documentation of this file.
1 //===- TGLexer.cpp - Lexer for TableGen -----------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Implement the Lexer for TableGen.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "TGLexer.h"
14 #include "llvm/ADT/ArrayRef.h"
15 #include "llvm/ADT/StringSwitch.h"
16 #include "llvm/ADT/Twine.h"
17 #include "llvm/Config/config.h" // for strtoull()/strtoll() define
18 #include "llvm/Support/Compiler.h"
20 #include "llvm/Support/SourceMgr.h"
21 #include "llvm/TableGen/Error.h"
22 #include <algorithm>
23 #include <cctype>
24 #include <cerrno>
25 #include <cstdint>
26 #include <cstdio>
27 #include <cstdlib>
28 #include <cstring>
29 
30 using namespace llvm;
31 
32 namespace {
33 // A list of supported preprocessing directives with their
34 // internal token kinds and names.
35 struct {
37  const char *Word;
38 } PreprocessorDirs[] = {
39  { tgtok::Ifdef, "ifdef" },
40  { tgtok::Ifndef, "ifndef" },
41  { tgtok::Else, "else" },
42  { tgtok::Endif, "endif" },
43  { tgtok::Define, "define" }
44 };
45 } // end anonymous namespace
46 
48  CurBuffer = SrcMgr.getMainFileID();
49  CurBuf = SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer();
50  CurPtr = CurBuf.begin();
51  TokStart = nullptr;
52 
53  // Pretend that we enter the "top-level" include file.
54  PrepIncludeStack.push_back(
55  std::make_unique<std::vector<PreprocessorControlDesc>>());
56 
57  // Put all macros defined in the command line into the DefinedMacros set.
58  std::for_each(Macros.begin(), Macros.end(),
59  [this](const std::string &MacroName) {
60  DefinedMacros.insert(MacroName);
61  });
62 }
63 
65  return SMLoc::getFromPointer(TokStart);
66 }
67 
68 /// ReturnError - Set the error to the specified string at the specified
69 /// location. This is defined to always return tgtok::Error.
70 tgtok::TokKind TGLexer::ReturnError(SMLoc Loc, const Twine &Msg) {
71  PrintError(Loc, Msg);
72  return tgtok::Error;
73 }
74 
75 tgtok::TokKind TGLexer::ReturnError(const char *Loc, const Twine &Msg) {
76  return ReturnError(SMLoc::getFromPointer(Loc), Msg);
77 }
78 
79 bool TGLexer::processEOF() {
80  SMLoc ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer);
81  if (ParentIncludeLoc != SMLoc()) {
82  // If prepExitInclude() detects a problem with the preprocessing
83  // control stack, it will return false. Pretend that we reached
84  // the final EOF and stop lexing more tokens by returning false
85  // to LexToken().
86  if (!prepExitInclude(false))
87  return false;
88 
89  CurBuffer = SrcMgr.FindBufferContainingLoc(ParentIncludeLoc);
90  CurBuf = SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer();
91  CurPtr = ParentIncludeLoc.getPointer();
92  // Make sure TokStart points into the parent file's buffer.
93  // LexToken() assigns to it before calling getNextChar(),
94  // so it is pointing into the included file now.
95  TokStart = CurPtr;
96  return true;
97  }
98 
99  // Pretend that we exit the "top-level" include file.
100  // Note that in case of an error (e.g. control stack imbalance)
101  // the routine will issue a fatal error.
102  prepExitInclude(true);
103  return false;
104 }
105 
106 int TGLexer::getNextChar() {
107  char CurChar = *CurPtr++;
108  switch (CurChar) {
109  default:
110  return (unsigned char)CurChar;
111 
112  case 0: {
113  // A NUL character in the stream is either the end of the current buffer or
114  // a spurious NUL in the file. Disambiguate that here.
115  if (CurPtr - 1 == CurBuf.end()) {
116  --CurPtr; // Arrange for another call to return EOF again.
117  return EOF;
118  }
119  PrintError(getLoc(),
120  "NUL character is invalid in source; treated as space");
121  return ' ';
122  }
123 
124  case '\n':
125  case '\r':
126  // Handle the newline character by ignoring it and incrementing the line
127  // count. However, be careful about 'dos style' files with \n\r in them.
128  // Only treat a \n\r or \r\n as a single line.
129  if ((*CurPtr == '\n' || (*CurPtr == '\r')) &&
130  *CurPtr != CurChar)
131  ++CurPtr; // Eat the two char newline sequence.
132  return '\n';
133  }
134 }
135 
136 int TGLexer::peekNextChar(int Index) const {
137  return *(CurPtr + Index);
138 }
139 
140 tgtok::TokKind TGLexer::LexToken(bool FileOrLineStart) {
141  TokStart = CurPtr;
142  // This always consumes at least one character.
143  int CurChar = getNextChar();
144 
145  switch (CurChar) {
146  default:
147  // Handle letters: [a-zA-Z_]
148  if (isalpha(CurChar) || CurChar == '_')
149  return LexIdentifier();
150 
151  // Unknown character, emit an error.
152  return ReturnError(TokStart, "Unexpected character");
153  case EOF:
154  // Lex next token, if we just left an include file.
155  // Note that leaving an include file means that the next
156  // symbol is located at the end of the 'include "..."'
157  // construct, so LexToken() is called with default
158  // false parameter.
159  if (processEOF())
160  return LexToken();
161 
162  // Return EOF denoting the end of lexing.
163  return tgtok::Eof;
164 
165  case ':': return tgtok::colon;
166  case ';': return tgtok::semi;
167  case ',': return tgtok::comma;
168  case '<': return tgtok::less;
169  case '>': return tgtok::greater;
170  case ']': return tgtok::r_square;
171  case '{': return tgtok::l_brace;
172  case '}': return tgtok::r_brace;
173  case '(': return tgtok::l_paren;
174  case ')': return tgtok::r_paren;
175  case '=': return tgtok::equal;
176  case '?': return tgtok::question;
177  case '#':
178  if (FileOrLineStart) {
179  tgtok::TokKind Kind = prepIsDirective();
180  if (Kind != tgtok::Error)
181  return lexPreprocessor(Kind);
182  }
183 
184  return tgtok::paste;
185 
186  // The period is a separate case so we can recognize the "..."
187  // range punctuator.
188  case '.':
189  if (peekNextChar(0) == '.') {
190  ++CurPtr; // Eat second dot.
191  if (peekNextChar(0) == '.') {
192  ++CurPtr; // Eat third dot.
193  return tgtok::dotdotdot;
194  }
195  return ReturnError(TokStart, "Invalid '..' punctuation");
196  }
197  return tgtok::dot;
198 
199  case '\r':
200  PrintFatalError("getNextChar() must never return '\r'");
201  return tgtok::Error;
202 
203  case ' ':
204  case '\t':
205  // Ignore whitespace.
206  return LexToken(FileOrLineStart);
207  case '\n':
208  // Ignore whitespace, and identify the new line.
209  return LexToken(true);
210  case '/':
211  // If this is the start of a // comment, skip until the end of the line or
212  // the end of the buffer.
213  if (*CurPtr == '/')
214  SkipBCPLComment();
215  else if (*CurPtr == '*') {
216  if (SkipCComment())
217  return tgtok::Error;
218  } else // Otherwise, this is an error.
219  return ReturnError(TokStart, "Unexpected character");
220  return LexToken(FileOrLineStart);
221  case '-': case '+':
222  case '0': case '1': case '2': case '3': case '4': case '5': case '6':
223  case '7': case '8': case '9': {
224  int NextChar = 0;
225  if (isdigit(CurChar)) {
226  // Allow identifiers to start with a number if it is followed by
227  // an identifier. This can happen with paste operations like
228  // foo#8i.
229  int i = 0;
230  do {
231  NextChar = peekNextChar(i++);
232  } while (isdigit(NextChar));
233 
234  if (NextChar == 'x' || NextChar == 'b') {
235  // If this is [0-9]b[01] or [0-9]x[0-9A-fa-f] this is most
236  // likely a number.
237  int NextNextChar = peekNextChar(i);
238  switch (NextNextChar) {
239  default:
240  break;
241  case '0': case '1':
242  if (NextChar == 'b')
243  return LexNumber();
245  case '2': case '3': case '4': case '5':
246  case '6': case '7': case '8': case '9':
247  case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
248  case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
249  if (NextChar == 'x')
250  return LexNumber();
251  break;
252  }
253  }
254  }
255 
256  if (isalpha(NextChar) || NextChar == '_')
257  return LexIdentifier();
258 
259  return LexNumber();
260  }
261  case '"': return LexString();
262  case '$': return LexVarName();
263  case '[': return LexBracket();
264  case '!': return LexExclaim();
265  }
266 }
267 
268 /// LexString - Lex "[^"]*"
269 tgtok::TokKind TGLexer::LexString() {
270  const char *StrStart = CurPtr;
271 
272  CurStrVal = "";
273 
274  while (*CurPtr != '"') {
275  // If we hit the end of the buffer, report an error.
276  if (*CurPtr == 0 && CurPtr == CurBuf.end())
277  return ReturnError(StrStart, "End of file in string literal");
278 
279  if (*CurPtr == '\n' || *CurPtr == '\r')
280  return ReturnError(StrStart, "End of line in string literal");
281 
282  if (*CurPtr != '\\') {
283  CurStrVal += *CurPtr++;
284  continue;
285  }
286 
287  ++CurPtr;
288 
289  switch (*CurPtr) {
290  case '\\': case '\'': case '"':
291  // These turn into their literal character.
292  CurStrVal += *CurPtr++;
293  break;
294  case 't':
295  CurStrVal += '\t';
296  ++CurPtr;
297  break;
298  case 'n':
299  CurStrVal += '\n';
300  ++CurPtr;
301  break;
302 
303  case '\n':
304  case '\r':
305  return ReturnError(CurPtr, "escaped newlines not supported in tblgen");
306 
307  // If we hit the end of the buffer, report an error.
308  case '\0':
309  if (CurPtr == CurBuf.end())
310  return ReturnError(StrStart, "End of file in string literal");
312  default:
313  return ReturnError(CurPtr, "invalid escape in string literal");
314  }
315  }
316 
317  ++CurPtr;
318  return tgtok::StrVal;
319 }
320 
321 tgtok::TokKind TGLexer::LexVarName() {
322  if (!isalpha(CurPtr[0]) && CurPtr[0] != '_')
323  return ReturnError(TokStart, "Invalid variable name");
324 
325  // Otherwise, we're ok, consume the rest of the characters.
326  const char *VarNameStart = CurPtr++;
327 
328  while (isalpha(*CurPtr) || isdigit(*CurPtr) || *CurPtr == '_')
329  ++CurPtr;
330 
331  CurStrVal.assign(VarNameStart, CurPtr);
332  return tgtok::VarName;
333 }
334 
335 tgtok::TokKind TGLexer::LexIdentifier() {
336  // The first letter is [a-zA-Z_].
337  const char *IdentStart = TokStart;
338 
339  // Match the rest of the identifier regex: [0-9a-zA-Z_]*
340  while (isalpha(*CurPtr) || isdigit(*CurPtr) || *CurPtr == '_')
341  ++CurPtr;
342 
343  // Check to see if this identifier is a reserved keyword.
344  StringRef Str(IdentStart, CurPtr-IdentStart);
345 
347  .Case("int", tgtok::Int)
348  .Case("bit", tgtok::Bit)
349  .Case("bits", tgtok::Bits)
350  .Case("string", tgtok::String)
351  .Case("list", tgtok::List)
352  .Case("code", tgtok::Code)
353  .Case("dag", tgtok::Dag)
354  .Case("class", tgtok::Class)
355  .Case("def", tgtok::Def)
356  .Case("true", tgtok::TrueVal)
357  .Case("false", tgtok::FalseVal)
358  .Case("foreach", tgtok::Foreach)
359  .Case("defm", tgtok::Defm)
360  .Case("defset", tgtok::Defset)
361  .Case("multiclass", tgtok::MultiClass)
362  .Case("field", tgtok::Field)
363  .Case("let", tgtok::Let)
364  .Case("in", tgtok::In)
365  .Case("defvar", tgtok::Defvar)
366  .Case("include", tgtok::Include)
367  .Case("if", tgtok::If)
368  .Case("then", tgtok::Then)
369  .Case("else", tgtok::ElseKW)
370  .Case("assert", tgtok::Assert)
371  .Default(tgtok::Id);
372 
373  // A couple of tokens require special processing.
374  switch (Kind) {
375  case tgtok::Include:
376  if (LexInclude()) return tgtok::Error;
377  return Lex();
378  case tgtok::Id:
379  CurStrVal.assign(Str.begin(), Str.end());
380  break;
381  default:
382  break;
383  }
384 
385  return Kind;
386 }
387 
388 /// LexInclude - We just read the "include" token. Get the string token that
389 /// comes next and enter the include.
390 bool TGLexer::LexInclude() {
391  // The token after the include must be a string.
392  tgtok::TokKind Tok = LexToken();
393  if (Tok == tgtok::Error) return true;
394  if (Tok != tgtok::StrVal) {
395  PrintError(getLoc(), "Expected filename after include");
396  return true;
397  }
398 
399  // Get the string.
400  std::string Filename = CurStrVal;
401  std::string IncludedFile;
402 
403  CurBuffer = SrcMgr.AddIncludeFile(Filename, SMLoc::getFromPointer(CurPtr),
404  IncludedFile);
405  if (!CurBuffer) {
406  PrintError(getLoc(), "Could not find include file '" + Filename + "'");
407  return true;
408  }
409 
410  Dependencies.insert(IncludedFile);
411  // Save the line number and lex buffer of the includer.
412  CurBuf = SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer();
413  CurPtr = CurBuf.begin();
414 
415  PrepIncludeStack.push_back(
416  std::make_unique<std::vector<PreprocessorControlDesc>>());
417  return false;
418 }
419 
420 /// SkipBCPLComment - Skip over the comment by finding the next CR or LF.
421 /// Or we may end up at the end of the buffer.
422 void TGLexer::SkipBCPLComment() {
423  ++CurPtr; // skip the second slash.
424  auto EOLPos = CurBuf.find_first_of("\r\n", CurPtr - CurBuf.data());
425  CurPtr = (EOLPos == StringRef::npos) ? CurBuf.end() : CurBuf.data() + EOLPos;
426 }
427 
428 /// SkipCComment - This skips C-style /**/ comments. The only difference from C
429 /// is that we allow nesting.
430 bool TGLexer::SkipCComment() {
431  ++CurPtr; // skip the star.
432  unsigned CommentDepth = 1;
433 
434  while (true) {
435  int CurChar = getNextChar();
436  switch (CurChar) {
437  case EOF:
438  PrintError(TokStart, "Unterminated comment!");
439  return true;
440  case '*':
441  // End of the comment?
442  if (CurPtr[0] != '/') break;
443 
444  ++CurPtr; // End the */.
445  if (--CommentDepth == 0)
446  return false;
447  break;
448  case '/':
449  // Start of a nested comment?
450  if (CurPtr[0] != '*') break;
451  ++CurPtr;
452  ++CommentDepth;
453  break;
454  }
455  }
456 }
457 
458 /// LexNumber - Lex:
459 /// [-+]?[0-9]+
460 /// 0x[0-9a-fA-F]+
461 /// 0b[01]+
462 tgtok::TokKind TGLexer::LexNumber() {
463  if (CurPtr[-1] == '0') {
464  if (CurPtr[0] == 'x') {
465  ++CurPtr;
466  const char *NumStart = CurPtr;
467  while (isxdigit(CurPtr[0]))
468  ++CurPtr;
469 
470  // Requires at least one hex digit.
471  if (CurPtr == NumStart)
472  return ReturnError(TokStart, "Invalid hexadecimal number");
473 
474  errno = 0;
475  CurIntVal = strtoll(NumStart, nullptr, 16);
476  if (errno == EINVAL)
477  return ReturnError(TokStart, "Invalid hexadecimal number");
478  if (errno == ERANGE) {
479  errno = 0;
480  CurIntVal = (int64_t)strtoull(NumStart, nullptr, 16);
481  if (errno == EINVAL)
482  return ReturnError(TokStart, "Invalid hexadecimal number");
483  if (errno == ERANGE)
484  return ReturnError(TokStart, "Hexadecimal number out of range");
485  }
486  return tgtok::IntVal;
487  } else if (CurPtr[0] == 'b') {
488  ++CurPtr;
489  const char *NumStart = CurPtr;
490  while (CurPtr[0] == '0' || CurPtr[0] == '1')
491  ++CurPtr;
492 
493  // Requires at least one binary digit.
494  if (CurPtr == NumStart)
495  return ReturnError(CurPtr-2, "Invalid binary number");
496  CurIntVal = strtoll(NumStart, nullptr, 2);
497  return tgtok::BinaryIntVal;
498  }
499  }
500 
501  // Check for a sign without a digit.
502  if (!isdigit(CurPtr[0])) {
503  if (CurPtr[-1] == '-')
504  return tgtok::minus;
505  else if (CurPtr[-1] == '+')
506  return tgtok::plus;
507  }
508 
509  while (isdigit(CurPtr[0]))
510  ++CurPtr;
511  CurIntVal = strtoll(TokStart, nullptr, 10);
512  return tgtok::IntVal;
513 }
514 
515 /// LexBracket - We just read '['. If this is a code block, return it,
516 /// otherwise return the bracket. Match: '[' and '[{ ( [^}]+ | }[^]] )* }]'
517 tgtok::TokKind TGLexer::LexBracket() {
518  if (CurPtr[0] != '{')
519  return tgtok::l_square;
520  ++CurPtr;
521  const char *CodeStart = CurPtr;
522  while (true) {
523  int Char = getNextChar();
524  if (Char == EOF) break;
525 
526  if (Char != '}') continue;
527 
528  Char = getNextChar();
529  if (Char == EOF) break;
530  if (Char == ']') {
531  CurStrVal.assign(CodeStart, CurPtr-2);
532  return tgtok::CodeFragment;
533  }
534  }
535 
536  return ReturnError(CodeStart - 2, "Unterminated code block");
537 }
538 
539 /// LexExclaim - Lex '!' and '![a-zA-Z]+'.
540 tgtok::TokKind TGLexer::LexExclaim() {
541  if (!isalpha(*CurPtr))
542  return ReturnError(CurPtr - 1, "Invalid \"!operator\"");
543 
544  const char *Start = CurPtr++;
545  while (isalpha(*CurPtr))
546  ++CurPtr;
547 
548  // Check to see which operator this is.
550  StringSwitch<tgtok::TokKind>(StringRef(Start, CurPtr - Start))
551  .Case("eq", tgtok::XEq)
552  .Case("ne", tgtok::XNe)
553  .Case("le", tgtok::XLe)
554  .Case("lt", tgtok::XLt)
555  .Case("ge", tgtok::XGe)
556  .Case("gt", tgtok::XGt)
557  .Case("if", tgtok::XIf)
558  .Case("cond", tgtok::XCond)
559  .Case("isa", tgtok::XIsA)
560  .Case("head", tgtok::XHead)
561  .Case("tail", tgtok::XTail)
562  .Case("size", tgtok::XSize)
563  .Case("con", tgtok::XConcat)
564  .Case("dag", tgtok::XDag)
565  .Case("add", tgtok::XADD)
566  .Case("sub", tgtok::XSUB)
567  .Case("mul", tgtok::XMUL)
568  .Case("not", tgtok::XNOT)
569  .Case("and", tgtok::XAND)
570  .Case("or", tgtok::XOR)
571  .Case("xor", tgtok::XXOR)
572  .Case("shl", tgtok::XSHL)
573  .Case("sra", tgtok::XSRA)
574  .Case("srl", tgtok::XSRL)
575  .Case("cast", tgtok::XCast)
576  .Case("empty", tgtok::XEmpty)
577  .Case("subst", tgtok::XSubst)
578  .Case("foldl", tgtok::XFoldl)
579  .Case("foreach", tgtok::XForEach)
580  .Case("filter", tgtok::XFilter)
581  .Case("listconcat", tgtok::XListConcat)
582  .Case("listsplat", tgtok::XListSplat)
583  .Case("strconcat", tgtok::XStrConcat)
584  .Case("interleave", tgtok::XInterleave)
585  .Case("substr", tgtok::XSubstr)
586  .Case("find", tgtok::XFind)
587  .Cases("setdagop", "setop", tgtok::XSetDagOp) // !setop is deprecated.
588  .Cases("getdagop", "getop", tgtok::XGetDagOp) // !getop is deprecated.
590 
591  return Kind != tgtok::Error ? Kind : ReturnError(Start-1, "Unknown operator");
592 }
593 
594 bool TGLexer::prepExitInclude(bool IncludeStackMustBeEmpty) {
595  // Report an error, if preprocessor control stack for the current
596  // file is not empty.
597  if (!PrepIncludeStack.back()->empty()) {
598  prepReportPreprocessorStackError();
599 
600  return false;
601  }
602 
603  // Pop the preprocessing controls from the include stack.
604  if (PrepIncludeStack.empty()) {
605  PrintFatalError("Preprocessor include stack is empty");
606  }
607 
608  PrepIncludeStack.pop_back();
609 
610  if (IncludeStackMustBeEmpty) {
611  if (!PrepIncludeStack.empty())
612  PrintFatalError("Preprocessor include stack is not empty");
613  } else {
614  if (PrepIncludeStack.empty())
615  PrintFatalError("Preprocessor include stack is empty");
616  }
617 
618  return true;
619 }
620 
621 tgtok::TokKind TGLexer::prepIsDirective() const {
622  for (const auto &PD : PreprocessorDirs) {
623  int NextChar = *CurPtr;
624  bool Match = true;
625  unsigned I = 0;
626  for (; I < strlen(PD.Word); ++I) {
627  if (NextChar != PD.Word[I]) {
628  Match = false;
629  break;
630  }
631 
632  NextChar = peekNextChar(I + 1);
633  }
634 
635  // Check for whitespace after the directive. If there is no whitespace,
636  // then we do not recognize it as a preprocessing directive.
637  if (Match) {
638  tgtok::TokKind Kind = PD.Kind;
639 
640  // New line and EOF may follow only #else/#endif. It will be reported
641  // as an error for #ifdef/#define after the call to prepLexMacroName().
642  if (NextChar == ' ' || NextChar == '\t' || NextChar == EOF ||
643  NextChar == '\n' ||
644  // It looks like TableGen does not support '\r' as the actual
645  // carriage return, e.g. getNextChar() treats a single '\r'
646  // as '\n'. So we do the same here.
647  NextChar == '\r')
648  return Kind;
649 
650  // Allow comments after some directives, e.g.:
651  // #else// OR #else/**/
652  // #endif// OR #endif/**/
653  //
654  // Note that we do allow comments after #ifdef/#define here, e.g.
655  // #ifdef/**/ AND #ifdef//
656  // #define/**/ AND #define//
657  //
658  // These cases will be reported as incorrect after calling
659  // prepLexMacroName(). We could have supported C-style comments
660  // after #ifdef/#define, but this would complicate the code
661  // for little benefit.
662  if (NextChar == '/') {
663  NextChar = peekNextChar(I + 1);
664 
665  if (NextChar == '*' || NextChar == '/')
666  return Kind;
667 
668  // Pretend that we do not recognize the directive.
669  }
670  }
671  }
672 
673  return tgtok::Error;
674 }
675 
676 bool TGLexer::prepEatPreprocessorDirective(tgtok::TokKind Kind) {
677  TokStart = CurPtr;
678 
679  for (const auto &PD : PreprocessorDirs)
680  if (PD.Kind == Kind) {
681  // Advance CurPtr to the end of the preprocessing word.
682  CurPtr += strlen(PD.Word);
683  return true;
684  }
685 
686  PrintFatalError("Unsupported preprocessing token in "
687  "prepEatPreprocessorDirective()");
688  return false;
689 }
690 
691 tgtok::TokKind TGLexer::lexPreprocessor(
692  tgtok::TokKind Kind, bool ReturnNextLiveToken) {
693 
694  // We must be looking at a preprocessing directive. Eat it!
695  if (!prepEatPreprocessorDirective(Kind))
696  PrintFatalError("lexPreprocessor() called for unknown "
697  "preprocessor directive");
698 
699  if (Kind == tgtok::Ifdef || Kind == tgtok::Ifndef) {
700  StringRef MacroName = prepLexMacroName();
701  StringRef IfTokName = Kind == tgtok::Ifdef ? "#ifdef" : "#ifndef";
702  if (MacroName.empty())
703  return ReturnError(TokStart, "Expected macro name after " + IfTokName);
704 
705  bool MacroIsDefined = DefinedMacros.count(MacroName) != 0;
706 
707  // Canonicalize ifndef to ifdef equivalent
708  if (Kind == tgtok::Ifndef) {
709  MacroIsDefined = !MacroIsDefined;
710  Kind = tgtok::Ifdef;
711  }
712 
713  // Regardless of whether we are processing tokens or not,
714  // we put the #ifdef control on stack.
715  PrepIncludeStack.back()->push_back(
716  {Kind, MacroIsDefined, SMLoc::getFromPointer(TokStart)});
717 
718  if (!prepSkipDirectiveEnd())
719  return ReturnError(CurPtr, "Only comments are supported after " +
720  IfTokName + " NAME");
721 
722  // If we were not processing tokens before this #ifdef,
723  // then just return back to the lines skipping code.
724  if (!ReturnNextLiveToken)
725  return Kind;
726 
727  // If we were processing tokens before this #ifdef,
728  // and the macro is defined, then just return the next token.
729  if (MacroIsDefined)
730  return LexToken();
731 
732  // We were processing tokens before this #ifdef, and the macro
733  // is not defined, so we have to start skipping the lines.
734  // If the skipping is successful, it will return the token following
735  // either #else or #endif corresponding to this #ifdef.
736  if (prepSkipRegion(ReturnNextLiveToken))
737  return LexToken();
738 
739  return tgtok::Error;
740  } else if (Kind == tgtok::Else) {
741  // Check if this #else is correct before calling prepSkipDirectiveEnd(),
742  // which will move CurPtr away from the beginning of #else.
743  if (PrepIncludeStack.back()->empty())
744  return ReturnError(TokStart, "#else without #ifdef or #ifndef");
745 
746  PreprocessorControlDesc IfdefEntry = PrepIncludeStack.back()->back();
747 
748  if (IfdefEntry.Kind != tgtok::Ifdef) {
749  PrintError(TokStart, "double #else");
750  return ReturnError(IfdefEntry.SrcPos, "Previous #else is here");
751  }
752 
753  // Replace the corresponding #ifdef's control with its negation
754  // on the control stack.
755  PrepIncludeStack.back()->pop_back();
756  PrepIncludeStack.back()->push_back(
757  {Kind, !IfdefEntry.IsDefined, SMLoc::getFromPointer(TokStart)});
758 
759  if (!prepSkipDirectiveEnd())
760  return ReturnError(CurPtr, "Only comments are supported after #else");
761 
762  // If we were processing tokens before this #else,
763  // we have to start skipping lines until the matching #endif.
764  if (ReturnNextLiveToken) {
765  if (prepSkipRegion(ReturnNextLiveToken))
766  return LexToken();
767 
768  return tgtok::Error;
769  }
770 
771  // Return to the lines skipping code.
772  return Kind;
773  } else if (Kind == tgtok::Endif) {
774  // Check if this #endif is correct before calling prepSkipDirectiveEnd(),
775  // which will move CurPtr away from the beginning of #endif.
776  if (PrepIncludeStack.back()->empty())
777  return ReturnError(TokStart, "#endif without #ifdef");
778 
779  auto &IfdefOrElseEntry = PrepIncludeStack.back()->back();
780 
781  if (IfdefOrElseEntry.Kind != tgtok::Ifdef &&
782  IfdefOrElseEntry.Kind != tgtok::Else) {
783  PrintFatalError("Invalid preprocessor control on the stack");
784  return tgtok::Error;
785  }
786 
787  if (!prepSkipDirectiveEnd())
788  return ReturnError(CurPtr, "Only comments are supported after #endif");
789 
790  PrepIncludeStack.back()->pop_back();
791 
792  // If we were processing tokens before this #endif, then
793  // we should continue it.
794  if (ReturnNextLiveToken) {
795  return LexToken();
796  }
797 
798  // Return to the lines skipping code.
799  return Kind;
800  } else if (Kind == tgtok::Define) {
801  StringRef MacroName = prepLexMacroName();
802  if (MacroName.empty())
803  return ReturnError(TokStart, "Expected macro name after #define");
804 
805  if (!DefinedMacros.insert(MacroName).second)
807  "Duplicate definition of macro: " + Twine(MacroName));
808 
809  if (!prepSkipDirectiveEnd())
810  return ReturnError(CurPtr,
811  "Only comments are supported after #define NAME");
812 
813  if (!ReturnNextLiveToken) {
814  PrintFatalError("#define must be ignored during the lines skipping");
815  return tgtok::Error;
816  }
817 
818  return LexToken();
819  }
820 
821  PrintFatalError("Preprocessing directive is not supported");
822  return tgtok::Error;
823 }
824 
825 bool TGLexer::prepSkipRegion(bool MustNeverBeFalse) {
826  if (!MustNeverBeFalse)
827  PrintFatalError("Invalid recursion.");
828 
829  do {
830  // Skip all symbols to the line end.
831  prepSkipToLineEnd();
832 
833  // Find the first non-whitespace symbol in the next line(s).
834  if (!prepSkipLineBegin())
835  return false;
836 
837  // If the first non-blank/comment symbol on the line is '#',
838  // it may be a start of preprocessing directive.
839  //
840  // If it is not '#' just go to the next line.
841  if (*CurPtr == '#')
842  ++CurPtr;
843  else
844  continue;
845 
846  tgtok::TokKind Kind = prepIsDirective();
847 
848  // If we did not find a preprocessing directive or it is #define,
849  // then just skip to the next line. We do not have to do anything
850  // for #define in the line-skipping mode.
851  if (Kind == tgtok::Error || Kind == tgtok::Define)
852  continue;
853 
854  tgtok::TokKind ProcessedKind = lexPreprocessor(Kind, false);
855 
856  // If lexPreprocessor() encountered an error during lexing this
857  // preprocessor idiom, then return false to the calling lexPreprocessor().
858  // This will force tgtok::Error to be returned to the tokens processing.
859  if (ProcessedKind == tgtok::Error)
860  return false;
861 
862  if (Kind != ProcessedKind)
863  PrintFatalError("prepIsDirective() and lexPreprocessor() "
864  "returned different token kinds");
865 
866  // If this preprocessing directive enables tokens processing,
867  // then return to the lexPreprocessor() and get to the next token.
868  // We can move from line-skipping mode to processing tokens only
869  // due to #else or #endif.
870  if (prepIsProcessingEnabled()) {
871  if (Kind != tgtok::Else && Kind != tgtok::Endif) {
872  PrintFatalError("Tokens processing was enabled by an unexpected "
873  "preprocessing directive");
874  return false;
875  }
876 
877  return true;
878  }
879  } while (CurPtr != CurBuf.end());
880 
881  // We have reached the end of the file, but never left the lines-skipping
882  // mode. This means there is no matching #endif.
883  prepReportPreprocessorStackError();
884  return false;
885 }
886 
887 StringRef TGLexer::prepLexMacroName() {
888  // Skip whitespaces between the preprocessing directive and the macro name.
889  while (*CurPtr == ' ' || *CurPtr == '\t')
890  ++CurPtr;
891 
892  TokStart = CurPtr;
893  // Macro names start with [a-zA-Z_].
894  if (*CurPtr != '_' && !isalpha(*CurPtr))
895  return "";
896 
897  // Match the rest of the identifier regex: [0-9a-zA-Z_]*
898  while (isalpha(*CurPtr) || isdigit(*CurPtr) || *CurPtr == '_')
899  ++CurPtr;
900 
901  return StringRef(TokStart, CurPtr - TokStart);
902 }
903 
904 bool TGLexer::prepSkipLineBegin() {
905  while (CurPtr != CurBuf.end()) {
906  switch (*CurPtr) {
907  case ' ':
908  case '\t':
909  case '\n':
910  case '\r':
911  break;
912 
913  case '/': {
914  int NextChar = peekNextChar(1);
915  if (NextChar == '*') {
916  // Skip C-style comment.
917  // Note that we do not care about skipping the C++-style comments.
918  // If the line contains "//", it may not contain any processable
919  // preprocessing directive. Just return CurPtr pointing to
920  // the first '/' in this case. We also do not care about
921  // incorrect symbols after the first '/' - we are in lines-skipping
922  // mode, so incorrect code is allowed to some extent.
923 
924  // Set TokStart to the beginning of the comment to enable proper
925  // diagnostic printing in case of error in SkipCComment().
926  TokStart = CurPtr;
927 
928  // CurPtr must point to '*' before call to SkipCComment().
929  ++CurPtr;
930  if (SkipCComment())
931  return false;
932  } else {
933  // CurPtr points to the non-whitespace '/'.
934  return true;
935  }
936 
937  // We must not increment CurPtr after the comment was lexed.
938  continue;
939  }
940 
941  default:
942  return true;
943  }
944 
945  ++CurPtr;
946  }
947 
948  // We have reached the end of the file. Return to the lines skipping
949  // code, and allow it to handle the EOF as needed.
950  return true;
951 }
952 
953 bool TGLexer::prepSkipDirectiveEnd() {
954  while (CurPtr != CurBuf.end()) {
955  switch (*CurPtr) {
956  case ' ':
957  case '\t':
958  break;
959 
960  case '\n':
961  case '\r':
962  return true;
963 
964  case '/': {
965  int NextChar = peekNextChar(1);
966  if (NextChar == '/') {
967  // Skip C++-style comment.
968  // We may just return true now, but let's skip to the line/buffer end
969  // to simplify the method specification.
970  ++CurPtr;
971  SkipBCPLComment();
972  } else if (NextChar == '*') {
973  // When we are skipping C-style comment at the end of a preprocessing
974  // directive, we can skip several lines. If any meaningful TD token
975  // follows the end of the C-style comment on the same line, it will
976  // be considered as an invalid usage of TD token.
977  // For example, we want to forbid usages like this one:
978  // #define MACRO class Class {}
979  // But with C-style comments we also disallow the following:
980  // #define MACRO /* This macro is used
981  // to ... */ class Class {}
982  // One can argue that this should be allowed, but it does not seem
983  // to be worth of the complication. Moreover, this matches
984  // the C preprocessor behavior.
985 
986  // Set TokStart to the beginning of the comment to enable proper
987  // diagnostic printer in case of error in SkipCComment().
988  TokStart = CurPtr;
989  ++CurPtr;
990  if (SkipCComment())
991  return false;
992  } else {
993  TokStart = CurPtr;
994  PrintError(CurPtr, "Unexpected character");
995  return false;
996  }
997 
998  // We must not increment CurPtr after the comment was lexed.
999  continue;
1000  }
1001 
1002  default:
1003  // Do not allow any non-whitespaces after the directive.
1004  TokStart = CurPtr;
1005  return false;
1006  }
1007 
1008  ++CurPtr;
1009  }
1010 
1011  return true;
1012 }
1013 
1014 void TGLexer::prepSkipToLineEnd() {
1015  while (*CurPtr != '\n' && *CurPtr != '\r' && CurPtr != CurBuf.end())
1016  ++CurPtr;
1017 }
1018 
1019 bool TGLexer::prepIsProcessingEnabled() {
1020  for (auto I = PrepIncludeStack.back()->rbegin(),
1021  E = PrepIncludeStack.back()->rend();
1022  I != E; ++I) {
1023  if (!I->IsDefined)
1024  return false;
1025  }
1026 
1027  return true;
1028 }
1029 
1030 void TGLexer::prepReportPreprocessorStackError() {
1031  if (PrepIncludeStack.back()->empty())
1032  PrintFatalError("prepReportPreprocessorStackError() called with "
1033  "empty control stack");
1034 
1035  auto &PrepControl = PrepIncludeStack.back()->back();
1036  PrintError(CurBuf.end(), "Reached EOF without matching #endif");
1037  PrintError(PrepControl.SrcPos, "The latest preprocessor control is here");
1038 
1039  TokStart = CurPtr;
1040 }
llvm::tgtok::XFilter
@ XFilter
Definition: TGLexer.h:57
llvm::StringSwitch::Case
StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:67
i
i
Definition: README.txt:29
MemoryBuffer.h
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::tgtok::Def
@ Def
Definition: TGLexer.h:50
llvm::StringRef::empty
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:153
llvm::pdb::PDB_BuiltinType::Char
@ Char
llvm::tgtok::XForEach
@ XForEach
Definition: TGLexer.h:57
llvm::tgtok::Field
@ Field
Definition: TGLexer.h:51
llvm::StringSwitch::Default
LLVM_NODISCARD R Default(T Value)
Definition: StringSwitch.h:181
llvm::StringRef::npos
static constexpr size_t npos
Definition: StringRef.h:60
llvm::tgtok::Code
@ Code
Definition: TGLexer.h:50
llvm::tgtok::paste
@ paste
Definition: TGLexer.h:45
llvm::tgtok::XXOR
@ XXOR
Definition: TGLexer.h:55
llvm::tgtok::l_brace
@ l_brace
Definition: TGLexer.h:39
llvm::tgtok::XStrConcat
@ XStrConcat
Definition: TGLexer.h:56
llvm::tgtok::l_paren
@ l_paren
Definition: TGLexer.h:40
llvm::tgtok::VarName
@ VarName
Definition: TGLexer.h:71
llvm::tgtok::Defm
@ Defm
Definition: TGLexer.h:50
llvm::SourceMgr::getParentIncludeLoc
SMLoc getParentIncludeLoc(unsigned i) const
Definition: SourceMgr.h:134
llvm::tgtok::comma
@ comma
Definition: TGLexer.h:43
llvm::tgtok::Bits
@ Bits
Definition: TGLexer.h:50
llvm::tgtok::XGe
@ XGe
Definition: TGLexer.h:58
llvm::tgtok::XSUB
@ XSUB
Definition: TGLexer.h:55
llvm::tgtok::l_square
@ l_square
Definition: TGLexer.h:38
llvm::tgtok::FalseVal
@ FalseVal
Definition: TGLexer.h:61
llvm::StringSet::insert
std::pair< typename Base::iterator, bool > insert(StringRef key)
Definition: StringSet.h:33
llvm::DiagnosticPredicateTy::Match
@ Match
TGLexer.h
llvm::tgtok::XHead
@ XHead
Definition: TGLexer.h:57
llvm::tgtok::Else
@ Else
Definition: TGLexer.h:75
llvm::tgtok::BinaryIntVal
@ BinaryIntVal
Definition: TGLexer.h:68
llvm::TGLexer::TGLexer
TGLexer(SourceMgr &SrcMgr, ArrayRef< std::string > Macros)
Definition: TGLexer.cpp:47
llvm::tgtok::plus
@ plus
Definition: TGLexer.h:37
llvm::TGLexer::Lex
tgtok::TokKind Lex()
Definition: TGLexer.h:106
llvm::tgtok::XMUL
@ XMUL
Definition: TGLexer.h:55
llvm::tgtok::Dag
@ Dag
Definition: TGLexer.h:50
llvm::tgtok::XFind
@ XFind
Definition: TGLexer.h:56
llvm::tgtok::Then
@ Then
Definition: TGLexer.h:52
llvm::tgtok::question
@ question
Definition: TGLexer.h:44
llvm::tgtok::XOR
@ XOR
Definition: TGLexer.h:55
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Twine.h
llvm::tgtok::Assert
@ Assert
Definition: TGLexer.h:50
llvm::SrcMgr
SourceMgr SrcMgr
Definition: Error.cpp:24
llvm::tgtok::XIsA
@ XIsA
Definition: TGLexer.h:58
llvm::tgtok::XCast
@ XCast
Definition: TGLexer.h:56
llvm::tgtok::XListConcat
@ XListConcat
Definition: TGLexer.h:56
llvm::PrintFatalError
void PrintFatalError(const Twine &Msg)
Definition: Error.cpp:125
llvm::SourceMgr::getMainFileID
unsigned getMainFileID() const
Definition: SourceMgr.h:129
llvm::tgtok::If
@ If
Definition: TGLexer.h:51
llvm::MemoryBuffer::getBuffer
StringRef getBuffer() const
Definition: MemoryBuffer.h:69
llvm::tgtok::equal
@ equal
Definition: TGLexer.h:44
llvm::tgtok::XNOT
@ XNOT
Definition: TGLexer.h:55
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
SourceMgr.h
llvm::tgtok::XGt
@ XGt
Definition: TGLexer.h:58
llvm::SourceMgr::getMemoryBuffer
const MemoryBuffer * getMemoryBuffer(unsigned i) const
Definition: SourceMgr.h:122
llvm::tgtok::XSRA
@ XSRA
Definition: TGLexer.h:55
llvm::tgtok::Foreach
@ Foreach
Definition: TGLexer.h:51
llvm::tgtok::XInterleave
@ XInterleave
Definition: TGLexer.h:56
llvm::tgtok::In
@ In
Definition: TGLexer.h:51
Error.h
llvm::tgtok::Defset
@ Defset
Definition: TGLexer.h:50
llvm::tgtok::XIf
@ XIf
Definition: TGLexer.h:57
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
llvm::tgtok::XEq
@ XEq
Definition: TGLexer.h:58
llvm::for_each
UnaryFunction for_each(R &&Range, UnaryFunction F)
Provide wrappers to std::for_each which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1540
llvm::StringRef::end
iterator end() const
Definition: StringRef.h:130
llvm::tgtok::Int
@ Int
Definition: TGLexer.h:51
llvm::tgtok::ElseKW
@ ElseKW
Definition: TGLexer.h:50
llvm::tgtok::r_square
@ r_square
Definition: TGLexer.h:38
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::tgtok::Defvar
@ Defvar
Definition: TGLexer.h:50
ArrayRef.h
llvm::tgtok::XSubstr
@ XSubstr
Definition: TGLexer.h:56
llvm::tgtok::Include
@ Include
Definition: TGLexer.h:51
llvm::X86II::PD
@ PD
Definition: X86BaseInfo.h:782
llvm::tgtok::r_paren
@ r_paren
Definition: TGLexer.h:40
llvm::tgtok::XConcat
@ XConcat
Definition: TGLexer.h:55
llvm::tgtok::XLe
@ XLe
Definition: TGLexer.h:58
llvm::irsymtab::storage::Word
support::ulittle32_t Word
Definition: IRSymtab.h:52
llvm::tgtok::XCond
@ XCond
Definition: TGLexer.h:58
llvm::ArrayRef< std::string >
llvm::SourceMgr::FindBufferContainingLoc
unsigned FindBufferContainingLoc(SMLoc Loc) const
Return the ID of the buffer containing the specified location.
Definition: SourceMgr.cpp:61
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::tgtok::Endif
@ Endif
Definition: TGLexer.h:75
llvm::tgtok::String
@ String
Definition: TGLexer.h:52
llvm::tgtok::XADD
@ XADD
Definition: TGLexer.h:55
llvm::SourceMgr
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Definition: SourceMgr.h:31
Compiler.h
llvm::tgtok::XSRL
@ XSRL
Definition: TGLexer.h:55
llvm::tgtok::XGetDagOp
@ XGetDagOp
Definition: TGLexer.h:58
llvm::tgtok::Ifdef
@ Ifdef
Definition: TGLexer.h:75
LLVM_FALLTHROUGH
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Definition: Compiler.h:273
llvm::StringSwitch::Cases
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, T Value)
Definition: StringSwitch.h:88
llvm::tgtok::Ifndef
@ Ifndef
Definition: TGLexer.h:75
llvm::tgtok::StrVal
@ StrVal
Definition: TGLexer.h:71
llvm::tgtok::dot
@ dot
Definition: TGLexer.h:43
llvm::tgtok::IntVal
@ IntVal
Definition: TGLexer.h:64
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::tgtok::r_brace
@ r_brace
Definition: TGLexer.h:39
llvm::tgtok::Eof
@ Eof
Definition: TGLexer.h:34
llvm::SMLoc::getPointer
const char * getPointer() const
Definition: SMLoc.h:34
llvm::ArrayRef::begin
iterator begin() const
Definition: ArrayRef.h:153
llvm::tgtok::XAND
@ XAND
Definition: TGLexer.h:55
llvm::tgtok::Error
@ Error
Definition: TGLexer.h:34
llvm::tgtok::XListSplat
@ XListSplat
Definition: TGLexer.h:56
llvm::tgtok::XSHL
@ XSHL
Definition: TGLexer.h:55
StringSwitch.h
llvm::StringMap::count
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Definition: StringMap.h:244
llvm::tgtok::XFoldl
@ XFoldl
Definition: TGLexer.h:57
llvm::tgtok::XSubst
@ XSubst
Definition: TGLexer.h:57
llvm::tgtok::Class
@ Class
Definition: TGLexer.h:50
llvm::SourceMgr::AddIncludeFile
unsigned AddIncludeFile(const std::string &Filename, SMLoc IncludeLoc, std::string &IncludedFile)
Search for a file with the specified name in the current directory or in one of the IncludeDirs.
Definition: SourceMgr.cpp:40
llvm::tgtok::XDag
@ XDag
Definition: TGLexer.h:58
llvm::tgtok::greater
@ greater
Definition: TGLexer.h:41
llvm::tgtok::CodeFragment
@ CodeFragment
Definition: TGLexer.h:71
llvm::tgtok::XSize
@ XSize
Definition: TGLexer.h:57
llvm::tgtok::XNe
@ XNe
Definition: TGLexer.h:58
llvm::PrintError
void PrintError(const Twine &Msg)
Definition: Error.cpp:101
llvm::tgtok::less
@ less
Definition: TGLexer.h:41
llvm::tgtok::MultiClass
@ MultiClass
Definition: TGLexer.h:51
llvm::tgtok::TokKind
TokKind
Definition: TGLexer.h:32
llvm::PrintWarning
void PrintWarning(const Twine &Msg)
Definition: Error.cpp:89
llvm::tgtok::Bit
@ Bit
Definition: TGLexer.h:50
llvm::StringRef::data
const LLVM_NODISCARD char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:149
llvm::SMLoc::getFromPointer
static SMLoc getFromPointer(const char *Ptr)
Definition: SMLoc.h:36
llvm::tgtok::XSetDagOp
@ XSetDagOp
Definition: TGLexer.h:58
llvm::StringSwitch
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:42
llvm::StringRef::find_first_of
LLVM_NODISCARD size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
Definition: StringRef.h:410
llvm::TGLexer::getLoc
SMLoc getLoc() const
Definition: TGLexer.cpp:64
llvm::tgtok::List
@ List
Definition: TGLexer.h:51
llvm::tgtok::XTail
@ XTail
Definition: TGLexer.h:57
llvm::tgtok::semi
@ semi
Definition: TGLexer.h:42
llvm::StringRef::begin
iterator begin() const
Definition: StringRef.h:128
llvm::tgtok::TrueVal
@ TrueVal
Definition: TGLexer.h:61
llvm::tgtok::minus
@ minus
Definition: TGLexer.h:37
llvm::tgtok::XLt
@ XLt
Definition: TGLexer.h:58
llvm::tgtok::Define
@ Define
Definition: TGLexer.h:75
llvm::tgtok::colon
@ colon
Definition: TGLexer.h:42
llvm::ArrayRef::end
iterator end() const
Definition: ArrayRef.h:154
llvm::tgtok::dotdotdot
@ dotdotdot
Definition: TGLexer.h:46
llvm::tgtok::Id
@ Id
Definition: TGLexer.h:71
llvm::tgtok::XEmpty
@ XEmpty
Definition: TGLexer.h:57
llvm::tgtok::Let
@ Let
Definition: TGLexer.h:51