1 //===--- Bracket.h - Analyze bracket structure --------------------*-C++-*-===//
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
7 //===----------------------------------------------------------------------===//
9 // Bracket structure (particularly braces) is key to isolating broken regions
10 // of code and preventing parsing from going "off the rails".
12 // For correct C++ code, brackets are well-nested and identifying pairs and
13 // therefore blocks is simple. In broken code, brackets are not properly nested.
14 // We cannot match them all and must choose which pairs to form.
16 // Rather than have the grammar-based parser make these choices, we pair
17 // brackets up-front based on textual features like indentation.
18 // This mirrors the way humans read code, and so is likely to produce the
19 // "correct" interpretation of broken code.
21 // This interpretation then guides the parse: a rule containing a bracket pair
22 // must match against paired bracket tokens.
24 //===----------------------------------------------------------------------===//
26 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_BRACKET_H
27 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_BRACKET_H
34 /// Identifies bracket token in the stream which should be paired.
35 /// Sets Token::Pair accordingly.
36 void pairBrackets(TokenStream
&);
41 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_BRACKET_H