Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:37:11

0001 //===- TokenManager.h - Manage Tokens for syntax-tree ------------*- C++-*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // Defines Token interfaces for the clang syntax-tree. This is the level of
0010 // abstraction that the syntax-tree uses to operate on Token.
0011 //
0012 // TokenManager decouples the syntax-tree from a particular token
0013 // implementation. For example, a TokenBuffer captured from a clang parser may
0014 // track macro expansions and associate tokens with clang's SourceManager, while
0015 // a clang pseudoparser would use a flat array of raw-lexed tokens in memory.
0016 //
0017 //===----------------------------------------------------------------------===//
0018 
0019 #ifndef LLVM_CLANG_TOOLING_SYNTAX_TOKEN_MANAGER_H
0020 #define LLVM_CLANG_TOOLING_SYNTAX_TOKEN_MANAGER_H
0021 
0022 #include "llvm/ADT/StringRef.h"
0023 #include <cstdint>
0024 
0025 namespace clang {
0026 namespace syntax {
0027 
0028 /// Defines interfaces for operating "Token" in the clang syntax-tree.
0029 class TokenManager {
0030 public:
0031   virtual ~TokenManager() = default;
0032 
0033   /// Describes what the exact class kind of the TokenManager is.
0034   virtual llvm::StringLiteral kind() const = 0;
0035 
0036   /// A key to identify a specific token. The token concept depends on the
0037   /// underlying implementation -- it can be a spelled token from the original
0038   /// source file or an expanded token.
0039   /// The syntax-tree Leaf node holds a Key.
0040   using Key = uintptr_t;
0041   virtual llvm::StringRef getText(Key K) const = 0;
0042 };
0043 
0044 } // namespace syntax
0045 } // namespace clang
0046 
0047 #endif // LLVM_CLANG_TOOLING_SYNTAX_TOKEN_MANAGER_H