clang 19.0.0git
TokenManager.h
Go to the documentation of this file.
1//===- TokenManager.h - Manage Tokens for syntax-tree ------------*- C++-*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Defines Token interfaces for the clang syntax-tree. This is the level of
10// abstraction that the syntax-tree uses to operate on Token.
11//
12// TokenManager decouples the syntax-tree from a particular token
13// implementation. For example, a TokenBuffer captured from a clang parser may
14// track macro expansions and associate tokens with clang's SourceManager, while
15// a clang pseudoparser would use a flat array of raw-lexed tokens in memory.
16//
17//===----------------------------------------------------------------------===//
18
19#ifndef LLVM_CLANG_TOOLING_SYNTAX_TOKEN_MANAGER_H
20#define LLVM_CLANG_TOOLING_SYNTAX_TOKEN_MANAGER_H
21
22#include "llvm/ADT/StringRef.h"
23#include <cstdint>
24
25namespace clang {
26namespace syntax {
27
28/// Defines interfaces for operating "Token" in the clang syntax-tree.
30public:
31 virtual ~TokenManager() = default;
32
33 /// Describes what the exact class kind of the TokenManager is.
34 virtual llvm::StringLiteral kind() const = 0;
35
36 /// A key to identify a specific token. The token concept depends on the
37 /// underlying implementation -- it can be a spelled token from the original
38 /// source file or an expanded token.
39 /// The syntax-tree Leaf node holds a Key.
40 using Key = uintptr_t;
41 virtual llvm::StringRef getText(Key K) const = 0;
42};
43
44} // namespace syntax
45} // namespace clang
46
47#endif // LLVM_CLANG_TOOLING_SYNTAX_TOKEN_MANAGER_H
Defines interfaces for operating "Token" in the clang syntax-tree.
Definition: TokenManager.h:29
uintptr_t Key
A key to identify a specific token.
Definition: TokenManager.h:40
virtual llvm::StringRef getText(Key K) const =0
virtual ~TokenManager()=default
virtual llvm::StringLiteral kind() const =0
Describes what the exact class kind of the TokenManager is.
The JSON file list parser is used to communicate input to InstallAPI.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...