Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 pmbaty 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
 
25
namespace clang {
26
namespace syntax {
27
 
28
/// Defines interfaces for operating "Token" in the clang syntax-tree.
29
class TokenManager {
30
public:
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