summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Parser/Token.cpp
diff options
context:
space:
mode:
authorChris Lattner <clattner@google.com>2018-06-28 20:45:33 -0700
committerjpienaar <jpienaar@google.com>2019-03-29 12:26:53 -0700
commit1734d78f8802fca30da5ed20780ae591b3a2b4e0 (patch)
tree9b81a515722d1139903935c8eb0edf0871637f68 /mlir/lib/Parser/Token.cpp
parent3609599af69c9c091b75d0caefadfb5a0479c913 (diff)
downloadbcm5719-llvm-1734d78f8802fca30da5ed20780ae591b3a2b4e0.tar.gz
bcm5719-llvm-1734d78f8802fca30da5ed20780ae591b3a2b4e0.zip
Sketch out parser/IR support for OperationInst, and a new Instruction base
class. Introduce an Identifier class to MLIRContext to represent uniqued identifiers, introduce string literal support to the lexer, introducing parser and printer support etc. PiperOrigin-RevId: 202592007
Diffstat (limited to 'mlir/lib/Parser/Token.cpp')
-rw-r--r--mlir/lib/Parser/Token.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/mlir/lib/Parser/Token.cpp b/mlir/lib/Parser/Token.cpp
index c721cf1d625..a8affc7f504 100644
--- a/mlir/lib/Parser/Token.cpp
+++ b/mlir/lib/Parser/Token.cpp
@@ -39,7 +39,7 @@ SMRange Token::getLocRange() const {
/// For an integer token, return its value as an unsigned. If it doesn't fit,
/// return None.
-Optional<unsigned> Token::getUnsignedIntegerValue() {
+Optional<unsigned> Token::getUnsignedIntegerValue() const {
bool isHex = spelling.size() > 1 && spelling[1] == 'x';
unsigned result = 0;
@@ -47,3 +47,12 @@ Optional<unsigned> Token::getUnsignedIntegerValue() {
return None;
return result;
}
+
+/// Given a 'string' token, return its value, including removing the quote
+/// characters and unescaping the contents of the string.
+std::string Token::getStringValue() const {
+ // TODO: Handle escaping.
+
+ // Just drop the quotes off for now.
+ return getSpelling().drop_front().drop_back().str();
+}
OpenPOWER on IntegriCloud