summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Parser/Token.cpp
diff options
context:
space:
mode:
authorChris Lattner <clattner@google.com>2018-06-22 10:39:19 -0700
committerjpienaar <jpienaar@google.com>2019-03-29 12:24:05 -0700
commit9b9f7ff5d4eeeb4172241997e4e3752dfe701f6c (patch)
treef9baf47d01839347383142367a7f26d44cc1702a /mlir/lib/Parser/Token.cpp
parent5fc587ecf85419bac4bf29bf5cbb08de06ca87ab (diff)
downloadbcm5719-llvm-9b9f7ff5d4eeeb4172241997e4e3752dfe701f6c.tar.gz
bcm5719-llvm-9b9f7ff5d4eeeb4172241997e4e3752dfe701f6c.zip
Implement enough of a lexer and parser for MLIR to parse extfunc's without
arguments. PiperOrigin-RevId: 201706570
Diffstat (limited to 'mlir/lib/Parser/Token.cpp')
-rw-r--r--mlir/lib/Parser/Token.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/mlir/lib/Parser/Token.cpp b/mlir/lib/Parser/Token.cpp
new file mode 100644
index 00000000000..551bd1e1da6
--- /dev/null
+++ b/mlir/lib/Parser/Token.cpp
@@ -0,0 +1,37 @@
+//===- Token.cpp - MLIR Token Implementation ------------------------------===//
+//
+// Copyright 2019 The MLIR Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// =============================================================================
+//
+// This file implements the Token class for the MLIR textual form.
+//
+//===----------------------------------------------------------------------===//
+
+#include "Token.h"
+using namespace mlir;
+using llvm::SMLoc;
+using llvm::SMRange;
+
+SMLoc Token::getLoc() const {
+ return SMLoc::getFromPointer(spelling.data());
+}
+
+SMLoc Token::getEndLoc() const {
+ return SMLoc::getFromPointer(spelling.data() + spelling.size());
+}
+
+SMRange Token::getLocRange() const {
+ return SMRange(getLoc(), getEndLoc());
+}
OpenPOWER on IntegriCloud