blob: c1b00b66ef5a4c2cc4e735b886a567a7a63b4f55 [file] [log] [blame]
Chris Lattnera8058742007-11-18 02:57:27 +00001//===- TGLexer.cpp - Lexer for TableGen -----------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner30609102007-12-29 20:37:13 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattnera8058742007-11-18 02:57:27 +00007//
8//===----------------------------------------------------------------------===//
9//
10// Implement the Lexer for TableGen.
11//
12//===----------------------------------------------------------------------===//
13
Chris Lattner6aaca042007-11-18 05:25:45 +000014#include "TGLexer.h"
Peter Collingbourne7c788882011-10-01 16:41:13 +000015#include "llvm/TableGen/Error.h"
Chris Lattner099e1982009-06-21 03:36:54 +000016#include "llvm/Support/SourceMgr.h"
Chris Lattnera8058742007-11-18 02:57:27 +000017#include "llvm/Support/MemoryBuffer.h"
Chuck Rose III8b0ec642007-11-21 19:36:25 +000018#include "llvm/Config/config.h"
Bill Wendlingcd466f52010-12-08 20:02:49 +000019#include "llvm/ADT/StringSwitch.h"
20#include "llvm/ADT/Twine.h"
Chris Lattnera8058742007-11-18 02:57:27 +000021#include <cctype>
Duncan Sands4520dd22008-10-08 07:23:46 +000022#include <cstdio>
Anton Korobeynikovae9f3a32008-02-20 11:08:44 +000023#include <cstdlib>
24#include <cstring>
Dan Gohman63f97202008-10-17 01:33:43 +000025#include <cerrno>
Chris Lattnera8058742007-11-18 02:57:27 +000026using namespace llvm;
27
Chris Lattner8070ea32009-06-21 03:41:50 +000028TGLexer::TGLexer(SourceMgr &SM) : SrcMgr(SM) {
Chris Lattneraa739d22009-03-13 07:05:43 +000029 CurBuffer = 0;
30 CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
Chris Lattnera8058742007-11-18 02:57:27 +000031 CurPtr = CurBuf->getBufferStart();
Chris Lattner56a9fcf2007-11-19 07:43:52 +000032 TokStart = 0;
Chris Lattnera8058742007-11-18 02:57:27 +000033}
34
Chris Lattner1e3a8a42009-06-21 03:39:35 +000035SMLoc TGLexer::getLoc() const {
36 return SMLoc::getFromPointer(TokStart);
Chris Lattner1c8ae592009-03-13 16:01:53 +000037}
38
Chris Lattnerc8a9bbc2007-11-19 07:38:58 +000039/// ReturnError - Set the error to the specified string at the specified
Chris Lattnerf4601652007-11-22 20:49:04 +000040/// location. This is defined to always return tgtok::Error.
Benjamin Kramerd1e17032010-09-27 17:42:11 +000041tgtok::TokKind TGLexer::ReturnError(const char *Loc, const Twine &Msg) {
Chris Lattnerc8a9bbc2007-11-19 07:38:58 +000042 PrintError(Loc, Msg);
Chris Lattnerf4601652007-11-22 20:49:04 +000043 return tgtok::Error;
Chris Lattnerc8a9bbc2007-11-19 07:38:58 +000044}
Chris Lattnera8058742007-11-18 02:57:27 +000045
Chris Lattnera8058742007-11-18 02:57:27 +000046int TGLexer::getNextChar() {
47 char CurChar = *CurPtr++;
48 switch (CurChar) {
49 default:
Chris Lattnerc1819182007-11-18 05:48:46 +000050 return (unsigned char)CurChar;
Chris Lattneraa739d22009-03-13 07:05:43 +000051 case 0: {
Chris Lattnera8058742007-11-18 02:57:27 +000052 // A nul character in the stream is either the end of the current buffer or
53 // a random nul in the file. Disambiguate that here.
54 if (CurPtr-1 != CurBuf->getBufferEnd())
55 return 0; // Just whitespace.
56
57 // If this is the end of an included file, pop the parent file off the
58 // include stack.
Chris Lattner1e3a8a42009-06-21 03:39:35 +000059 SMLoc ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer);
60 if (ParentIncludeLoc != SMLoc()) {
Chris Lattneraa739d22009-03-13 07:05:43 +000061 CurBuffer = SrcMgr.FindBufferContainingLoc(ParentIncludeLoc);
62 CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
Chris Lattner1c8ae592009-03-13 16:01:53 +000063 CurPtr = ParentIncludeLoc.getPointer();
Chris Lattnera8058742007-11-18 02:57:27 +000064 return getNextChar();
65 }
66
67 // Otherwise, return end of file.
68 --CurPtr; // Another call to lex will return EOF again.
69 return EOF;
Chris Lattneraa739d22009-03-13 07:05:43 +000070 }
Chris Lattnera8058742007-11-18 02:57:27 +000071 case '\n':
72 case '\r':
73 // Handle the newline character by ignoring it and incrementing the line
74 // count. However, be careful about 'dos style' files with \n\r in them.
75 // Only treat a \n\r or \r\n as a single line.
76 if ((*CurPtr == '\n' || (*CurPtr == '\r')) &&
77 *CurPtr != CurChar)
Chris Lattnerc1819182007-11-18 05:48:46 +000078 ++CurPtr; // Eat the two char newline sequence.
Chris Lattnera8058742007-11-18 02:57:27 +000079 return '\n';
80 }
81}
82
David Greenea761f922011-10-19 13:03:35 +000083int TGLexer::peekNextChar(int Index) {
84 return *(CurPtr + Index);
85}
86
Chris Lattnerf4601652007-11-22 20:49:04 +000087tgtok::TokKind TGLexer::LexToken() {
Chris Lattner56a9fcf2007-11-19 07:43:52 +000088 TokStart = CurPtr;
Chris Lattnera8058742007-11-18 02:57:27 +000089 // This always consumes at least one character.
90 int CurChar = getNextChar();
91
92 switch (CurChar) {
93 default:
Chris Lattnerc2b08752010-10-05 22:59:29 +000094 // Handle letters: [a-zA-Z_#]
David Greene065f2592009-05-05 16:28:25 +000095 if (isalpha(CurChar) || CurChar == '_' || CurChar == '#')
Chris Lattnera8058742007-11-18 02:57:27 +000096 return LexIdentifier();
97
Chris Lattnerf4601652007-11-22 20:49:04 +000098 // Unknown character, emit an error.
99 return ReturnError(TokStart, "Unexpected character");
100 case EOF: return tgtok::Eof;
101 case ':': return tgtok::colon;
102 case ';': return tgtok::semi;
103 case '.': return tgtok::period;
104 case ',': return tgtok::comma;
105 case '<': return tgtok::less;
106 case '>': return tgtok::greater;
107 case ']': return tgtok::r_square;
108 case '{': return tgtok::l_brace;
109 case '}': return tgtok::r_brace;
110 case '(': return tgtok::l_paren;
111 case ')': return tgtok::r_paren;
112 case '=': return tgtok::equal;
113 case '?': return tgtok::question;
114
Chris Lattnera8058742007-11-18 02:57:27 +0000115 case 0:
116 case ' ':
117 case '\t':
118 case '\n':
119 case '\r':
120 // Ignore whitespace.
121 return LexToken();
122 case '/':
123 // If this is the start of a // comment, skip until the end of the line or
124 // the end of the buffer.
125 if (*CurPtr == '/')
126 SkipBCPLComment();
127 else if (*CurPtr == '*') {
128 if (SkipCComment())
Chris Lattnerf4601652007-11-22 20:49:04 +0000129 return tgtok::Error;
130 } else // Otherwise, this is an error.
131 return ReturnError(TokStart, "Unexpected character");
Chris Lattnera8058742007-11-18 02:57:27 +0000132 return LexToken();
133 case '-': case '+':
134 case '0': case '1': case '2': case '3': case '4': case '5': case '6':
135 case '7': case '8': case '9':
136 return LexNumber();
137 case '"': return LexString();
138 case '$': return LexVarName();
139 case '[': return LexBracket();
140 case '!': return LexExclaim();
141 }
142}
143
144/// LexString - Lex "[^"]*"
Chris Lattnerf4601652007-11-22 20:49:04 +0000145tgtok::TokKind TGLexer::LexString() {
Chris Lattnera8058742007-11-18 02:57:27 +0000146 const char *StrStart = CurPtr;
147
Chris Lattnerea9f4df2009-03-13 21:03:27 +0000148 CurStrVal = "";
149
Chris Lattnera8058742007-11-18 02:57:27 +0000150 while (*CurPtr != '"') {
151 // If we hit the end of the buffer, report an error.
Chris Lattnerc8a9bbc2007-11-19 07:38:58 +0000152 if (*CurPtr == 0 && CurPtr == CurBuf->getBufferEnd())
153 return ReturnError(StrStart, "End of file in string literal");
154
155 if (*CurPtr == '\n' || *CurPtr == '\r')
156 return ReturnError(StrStart, "End of line in string literal");
Chris Lattnera8058742007-11-18 02:57:27 +0000157
Chris Lattnerea9f4df2009-03-13 21:03:27 +0000158 if (*CurPtr != '\\') {
159 CurStrVal += *CurPtr++;
160 continue;
161 }
162
Chris Lattnera8058742007-11-18 02:57:27 +0000163 ++CurPtr;
Chris Lattnerea9f4df2009-03-13 21:03:27 +0000164
165 switch (*CurPtr) {
166 case '\\': case '\'': case '"':
167 // These turn into their literal character.
168 CurStrVal += *CurPtr++;
169 break;
Chris Lattnere023bb62009-03-13 21:23:43 +0000170 case 't':
Chris Lattner7f3b28a2009-03-13 21:33:17 +0000171 CurStrVal += '\t';
Chris Lattnere023bb62009-03-13 21:23:43 +0000172 ++CurPtr;
173 break;
174 case 'n':
Chris Lattner7f3b28a2009-03-13 21:33:17 +0000175 CurStrVal += '\n';
Chris Lattnere023bb62009-03-13 21:23:43 +0000176 ++CurPtr;
177 break;
178
Chris Lattnerea9f4df2009-03-13 21:03:27 +0000179 case '\n':
180 case '\r':
181 return ReturnError(CurPtr, "escaped newlines not supported in tblgen");
182
183 // If we hit the end of the buffer, report an error.
184 case '\0':
185 if (CurPtr == CurBuf->getBufferEnd())
186 return ReturnError(StrStart, "End of file in string literal");
187 // FALL THROUGH
188 default:
189 return ReturnError(CurPtr, "invalid escape in string literal");
190 }
Chris Lattnera8058742007-11-18 02:57:27 +0000191 }
192
Chris Lattnera8058742007-11-18 02:57:27 +0000193 ++CurPtr;
Chris Lattnerf4601652007-11-22 20:49:04 +0000194 return tgtok::StrVal;
Chris Lattnera8058742007-11-18 02:57:27 +0000195}
196
Chris Lattnerf4601652007-11-22 20:49:04 +0000197tgtok::TokKind TGLexer::LexVarName() {
Chris Lattnera8058742007-11-18 02:57:27 +0000198 if (!isalpha(CurPtr[0]) && CurPtr[0] != '_')
Chris Lattnerf4601652007-11-22 20:49:04 +0000199 return ReturnError(TokStart, "Invalid variable name");
Chris Lattnera8058742007-11-18 02:57:27 +0000200
201 // Otherwise, we're ok, consume the rest of the characters.
202 const char *VarNameStart = CurPtr++;
203
204 while (isalpha(*CurPtr) || isdigit(*CurPtr) || *CurPtr == '_')
205 ++CurPtr;
206
Chris Lattnerf4601652007-11-22 20:49:04 +0000207 CurStrVal.assign(VarNameStart, CurPtr);
208 return tgtok::VarName;
Chris Lattnera8058742007-11-18 02:57:27 +0000209}
210
211
Chris Lattnerf4601652007-11-22 20:49:04 +0000212tgtok::TokKind TGLexer::LexIdentifier() {
Chris Lattnerc2b08752010-10-05 22:59:29 +0000213 // The first letter is [a-zA-Z_#].
Chris Lattnerf4601652007-11-22 20:49:04 +0000214 const char *IdentStart = TokStart;
Benjamin Kramer37d42af2011-10-06 18:23:56 +0000215
Chris Lattnerc2b08752010-10-05 22:59:29 +0000216 // Match the rest of the identifier regex: [0-9a-zA-Z_#]*
217 while (isalpha(*CurPtr) || isdigit(*CurPtr) || *CurPtr == '_' ||
218 *CurPtr == '#')
219 ++CurPtr;
Benjamin Kramer37d42af2011-10-06 18:23:56 +0000220
Chris Lattnera8058742007-11-18 02:57:27 +0000221 // Check to see if this identifier is a keyword.
Benjamin Kramer37d42af2011-10-06 18:23:56 +0000222 StringRef Str(IdentStart, CurPtr-IdentStart);
223
Benjamin Kramer37d42af2011-10-06 18:23:56 +0000224 if (Str == "include") {
Chris Lattnerf4601652007-11-22 20:49:04 +0000225 if (LexInclude()) return tgtok::Error;
226 return Lex();
Chris Lattnera8058742007-11-18 02:57:27 +0000227 }
Benjamin Kramer37d42af2011-10-06 18:23:56 +0000228
Benjamin Krameree573182011-10-06 18:53:43 +0000229 tgtok::TokKind Kind = StringSwitch<tgtok::TokKind>(Str)
230 .Case("int", tgtok::Int)
231 .Case("bit", tgtok::Bit)
232 .Case("bits", tgtok::Bits)
233 .Case("string", tgtok::String)
234 .Case("list", tgtok::List)
235 .Case("code", tgtok::Code)
236 .Case("dag", tgtok::Dag)
237 .Case("class", tgtok::Class)
238 .Case("def", tgtok::Def)
Benjamin Krameree573182011-10-06 18:53:43 +0000239 .Case("defm", tgtok::Defm)
240 .Case("multiclass", tgtok::MultiClass)
241 .Case("field", tgtok::Field)
242 .Case("let", tgtok::Let)
243 .Case("in", tgtok::In)
244 .Default(tgtok::Id);
245
246 if (Kind == tgtok::Id)
247 CurStrVal.assign(Str.begin(), Str.end());
248 return Kind;
Chris Lattnera8058742007-11-18 02:57:27 +0000249}
250
251/// LexInclude - We just read the "include" token. Get the string token that
252/// comes next and enter the include.
253bool TGLexer::LexInclude() {
254 // The token after the include must be a string.
Chris Lattnerf4601652007-11-22 20:49:04 +0000255 tgtok::TokKind Tok = LexToken();
256 if (Tok == tgtok::Error) return true;
257 if (Tok != tgtok::StrVal) {
258 PrintError(getLoc(), "Expected filename after include");
Chris Lattnera8058742007-11-18 02:57:27 +0000259 return true;
260 }
261
262 // Get the string.
Chris Lattnerf4601652007-11-22 20:49:04 +0000263 std::string Filename = CurStrVal;
Joerg Sonnenbergerdd137902011-06-01 13:10:15 +0000264 std::string IncludedFile;
Chris Lattnera8058742007-11-18 02:57:27 +0000265
Chris Lattner7ee5d5f2009-06-21 05:06:04 +0000266
Joerg Sonnenbergerdd137902011-06-01 13:10:15 +0000267 CurBuffer = SrcMgr.AddIncludeFile(Filename, SMLoc::getFromPointer(CurPtr),
268 IncludedFile);
Chris Lattnerd926e042009-06-21 05:33:06 +0000269 if (CurBuffer == -1) {
Chris Lattnerf4601652007-11-22 20:49:04 +0000270 PrintError(getLoc(), "Could not find include file '" + Filename + "'");
Chris Lattnera8058742007-11-18 02:57:27 +0000271 return true;
272 }
273
Joerg Sonnenbergerdd137902011-06-01 13:10:15 +0000274 Dependencies.push_back(IncludedFile);
Chris Lattnera8058742007-11-18 02:57:27 +0000275 // Save the line number and lex buffer of the includer.
Chris Lattner7ee5d5f2009-06-21 05:06:04 +0000276 CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
Chris Lattnera8058742007-11-18 02:57:27 +0000277 CurPtr = CurBuf->getBufferStart();
278 return false;
279}
280
281void TGLexer::SkipBCPLComment() {
282 ++CurPtr; // skip the second slash.
283 while (1) {
284 switch (*CurPtr) {
285 case '\n':
286 case '\r':
287 return; // Newline is end of comment.
288 case 0:
289 // If this is the end of the buffer, end the comment.
290 if (CurPtr == CurBuf->getBufferEnd())
291 return;
292 break;
293 }
294 // Otherwise, skip the character.
295 ++CurPtr;
296 }
297}
298
299/// SkipCComment - This skips C-style /**/ comments. The only difference from C
300/// is that we allow nesting.
301bool TGLexer::SkipCComment() {
302 ++CurPtr; // skip the star.
303 unsigned CommentDepth = 1;
304
305 while (1) {
306 int CurChar = getNextChar();
307 switch (CurChar) {
308 case EOF:
Chris Lattnerf4601652007-11-22 20:49:04 +0000309 PrintError(TokStart, "Unterminated comment!");
Chris Lattnera8058742007-11-18 02:57:27 +0000310 return true;
311 case '*':
312 // End of the comment?
313 if (CurPtr[0] != '/') break;
314
315 ++CurPtr; // End the */.
316 if (--CommentDepth == 0)
317 return false;
318 break;
319 case '/':
320 // Start of a nested comment?
321 if (CurPtr[0] != '*') break;
322 ++CurPtr;
323 ++CommentDepth;
324 break;
325 }
326 }
327}
328
329/// LexNumber - Lex:
330/// [-+]?[0-9]+
331/// 0x[0-9a-fA-F]+
332/// 0b[01]+
Chris Lattnerf4601652007-11-22 20:49:04 +0000333tgtok::TokKind TGLexer::LexNumber() {
Chris Lattnera8058742007-11-18 02:57:27 +0000334 if (CurPtr[-1] == '0') {
335 if (CurPtr[0] == 'x') {
336 ++CurPtr;
Chris Lattnerf4601652007-11-22 20:49:04 +0000337 const char *NumStart = CurPtr;
Chris Lattnera8058742007-11-18 02:57:27 +0000338 while (isxdigit(CurPtr[0]))
339 ++CurPtr;
340
Chris Lattnerc8a9bbc2007-11-19 07:38:58 +0000341 // Requires at least one hex digit.
342 if (CurPtr == NumStart)
Chris Lattner4226bb02009-06-21 19:22:49 +0000343 return ReturnError(TokStart, "Invalid hexadecimal number");
Chris Lattnerc8a9bbc2007-11-19 07:38:58 +0000344
Dan Gohman63f97202008-10-17 01:33:43 +0000345 errno = 0;
Chris Lattnerf4601652007-11-22 20:49:04 +0000346 CurIntVal = strtoll(NumStart, 0, 16);
Dan Gohman63f97202008-10-17 01:33:43 +0000347 if (errno == EINVAL)
Chris Lattner4226bb02009-06-21 19:22:49 +0000348 return ReturnError(TokStart, "Invalid hexadecimal number");
Dan Gohman63f97202008-10-17 01:33:43 +0000349 if (errno == ERANGE) {
350 errno = 0;
351 CurIntVal = (int64_t)strtoull(NumStart, 0, 16);
352 if (errno == EINVAL)
Chris Lattner4226bb02009-06-21 19:22:49 +0000353 return ReturnError(TokStart, "Invalid hexadecimal number");
Dan Gohman63f97202008-10-17 01:33:43 +0000354 if (errno == ERANGE)
Chris Lattner4226bb02009-06-21 19:22:49 +0000355 return ReturnError(TokStart, "Hexadecimal number out of range");
Dan Gohman63f97202008-10-17 01:33:43 +0000356 }
Chris Lattnerf4601652007-11-22 20:49:04 +0000357 return tgtok::IntVal;
Chris Lattnera8058742007-11-18 02:57:27 +0000358 } else if (CurPtr[0] == 'b') {
359 ++CurPtr;
Chris Lattnerf4601652007-11-22 20:49:04 +0000360 const char *NumStart = CurPtr;
Chris Lattnera8058742007-11-18 02:57:27 +0000361 while (CurPtr[0] == '0' || CurPtr[0] == '1')
362 ++CurPtr;
Chris Lattnerc8a9bbc2007-11-19 07:38:58 +0000363
364 // Requires at least one binary digit.
365 if (CurPtr == NumStart)
366 return ReturnError(CurPtr-2, "Invalid binary number");
Chris Lattnerf4601652007-11-22 20:49:04 +0000367 CurIntVal = strtoll(NumStart, 0, 2);
368 return tgtok::IntVal;
Chris Lattnera8058742007-11-18 02:57:27 +0000369 }
370 }
371
372 // Check for a sign without a digit.
Chris Lattnerf4601652007-11-22 20:49:04 +0000373 if (!isdigit(CurPtr[0])) {
374 if (CurPtr[-1] == '-')
375 return tgtok::minus;
376 else if (CurPtr[-1] == '+')
377 return tgtok::plus;
Chris Lattnera8058742007-11-18 02:57:27 +0000378 }
379
380 while (isdigit(CurPtr[0]))
381 ++CurPtr;
Chris Lattnerf4601652007-11-22 20:49:04 +0000382 CurIntVal = strtoll(TokStart, 0, 10);
383 return tgtok::IntVal;
Chris Lattnera8058742007-11-18 02:57:27 +0000384}
385
386/// LexBracket - We just read '['. If this is a code block, return it,
387/// otherwise return the bracket. Match: '[' and '[{ ( [^}]+ | }[^]] )* }]'
Chris Lattnerf4601652007-11-22 20:49:04 +0000388tgtok::TokKind TGLexer::LexBracket() {
Chris Lattnera8058742007-11-18 02:57:27 +0000389 if (CurPtr[0] != '{')
Chris Lattnerf4601652007-11-22 20:49:04 +0000390 return tgtok::l_square;
Chris Lattnera8058742007-11-18 02:57:27 +0000391 ++CurPtr;
392 const char *CodeStart = CurPtr;
393 while (1) {
394 int Char = getNextChar();
395 if (Char == EOF) break;
396
397 if (Char != '}') continue;
398
399 Char = getNextChar();
400 if (Char == EOF) break;
401 if (Char == ']') {
Chris Lattnerf4601652007-11-22 20:49:04 +0000402 CurStrVal.assign(CodeStart, CurPtr-2);
403 return tgtok::CodeFragment;
Chris Lattnera8058742007-11-18 02:57:27 +0000404 }
405 }
406
Chris Lattnerc8a9bbc2007-11-19 07:38:58 +0000407 return ReturnError(CodeStart-2, "Unterminated Code Block");
Chris Lattnera8058742007-11-18 02:57:27 +0000408}
409
410/// LexExclaim - Lex '!' and '![a-zA-Z]+'.
Chris Lattnerf4601652007-11-22 20:49:04 +0000411tgtok::TokKind TGLexer::LexExclaim() {
Chris Lattnera8058742007-11-18 02:57:27 +0000412 if (!isalpha(*CurPtr))
Bill Wendlingdd2b6cb2010-12-08 13:03:15 +0000413 return ReturnError(CurPtr - 1, "Invalid \"!operator\"");
Chris Lattnera8058742007-11-18 02:57:27 +0000414
415 const char *Start = CurPtr++;
416 while (isalpha(*CurPtr))
417 ++CurPtr;
418
419 // Check to see which operator this is.
Bill Wendlingcd466f52010-12-08 20:02:49 +0000420 tgtok::TokKind Kind =
421 StringSwitch<tgtok::TokKind>(StringRef(Start, CurPtr - Start))
422 .Case("eq", tgtok::XEq)
423 .Case("if", tgtok::XIf)
David Greene1434f662011-01-07 17:05:37 +0000424 .Case("head", tgtok::XHead)
425 .Case("tail", tgtok::XTail)
Bill Wendlingcd466f52010-12-08 20:02:49 +0000426 .Case("con", tgtok::XConcat)
427 .Case("shl", tgtok::XSHL)
428 .Case("sra", tgtok::XSRA)
429 .Case("srl", tgtok::XSRL)
430 .Case("cast", tgtok::XCast)
David Greene1434f662011-01-07 17:05:37 +0000431 .Case("empty", tgtok::XEmpty)
Bill Wendlingcd466f52010-12-08 20:02:49 +0000432 .Case("subst", tgtok::XSubst)
433 .Case("foreach", tgtok::XForEach)
434 .Case("strconcat", tgtok::XStrConcat)
435 .Default(tgtok::Error);
David Greened418c1b2009-05-14 20:54:48 +0000436
Bill Wendlingcd466f52010-12-08 20:02:49 +0000437 return Kind != tgtok::Error ? Kind : ReturnError(Start-1, "Unknown operator");
Chris Lattnera8058742007-11-18 02:57:27 +0000438}
439