diff options
author | David Greene <greened@obbligato.org> | 2011-10-19 13:04:43 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2011-10-19 13:04:43 +0000 |
commit | d3d1cad535d1c88e13e8e082c136260ee624967f (patch) | |
tree | a79a64b8631b09ed8a0b26b0c3c2250849255223 /lib/TableGen/TGLexer.cpp | |
parent | e5b252f9fe7a3dfc85ae25ca1603cb406071851b (diff) | |
download | llvm-d3d1cad535d1c88e13e8e082c136260ee624967f.tar.gz llvm-d3d1cad535d1c88e13e8e082c136260ee624967f.tar.bz2 llvm-d3d1cad535d1c88e13e8e082c136260ee624967f.tar.xz |
Implement Paste
Add a paste operator '#' to take two identifier-like strings and joint
them. Internally paste gets represented as a !strconcat() with any
necessary casts to string added.
This will be used to implement basic for loop functionality as in:
for i = [0, 1, 2, 3, 4, 5, 6, 7] {
def R#i : Register<...>
}
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142525 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/TableGen/TGLexer.cpp')
-rw-r--r-- | lib/TableGen/TGLexer.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/TableGen/TGLexer.cpp b/lib/TableGen/TGLexer.cpp index 3262121ee8..45d0b1ed2b 100644 --- a/lib/TableGen/TGLexer.cpp +++ b/lib/TableGen/TGLexer.cpp @@ -91,10 +91,10 @@ tgtok::TokKind TGLexer::LexToken() { switch (CurChar) { default: - // Handle letters: [a-zA-Z_#] - if (isalpha(CurChar) || CurChar == '_' || CurChar == '#') + // Handle letters: [a-zA-Z_] + if (isalpha(CurChar) || CurChar == '_') return LexIdentifier(); - + // Unknown character, emit an error. return ReturnError(TokStart, "Unexpected character"); case EOF: return tgtok::Eof; @@ -111,6 +111,7 @@ tgtok::TokKind TGLexer::LexToken() { case ')': return tgtok::r_paren; case '=': return tgtok::equal; case '?': return tgtok::question; + case '#': return tgtok::paste; case 0: case ' ': @@ -250,8 +251,7 @@ tgtok::TokKind TGLexer::LexIdentifier() { const char *IdentStart = TokStart; // Match the rest of the identifier regex: [0-9a-zA-Z_#]* - while (isalpha(*CurPtr) || isdigit(*CurPtr) || *CurPtr == '_' || - *CurPtr == '#') + while (isalpha(*CurPtr) || isdigit(*CurPtr) || *CurPtr == '_') ++CurPtr; // Check to see if this identifier is a keyword. |