llvm-project/clang-tools-extra/pseudo
Sam McCall 56c54cf66b [pseudo] Placeholder disambiguation strategy: always choose second
Mostly mechanics here. Interesting decisions:
 - apply disambiguation in-place instead of copying the forest
   debatable, but even the final tree size is significant
 - split decide/apply into different functions - this allows the hard part
   (decide) to be tested non-destructively and combined with HTML forest easily
 - add non-const accessors to forest to enable apply
 - unit tests but no lit tests: my plan is to test actual C++ disambiguation
   heuristics with lit, generic disambiguation mechanics without the C++ grammar

Differential Revision: https://reviews.llvm.org/D132487
2022-08-26 13:16:09 +02:00
..
benchmarks [pseudo] Implement guard extension. 2022-07-05 15:55:15 +02:00
fuzzer [pseudo] Implement guard extension. 2022-07-05 15:55:15 +02:00
gen [clang-tools-extra] Fixed a number of typos 2022-08-01 15:32:25 +02:00
include [pseudo] Placeholder disambiguation strategy: always choose second 2022-08-26 13:16:09 +02:00
lib [pseudo] Placeholder disambiguation strategy: always choose second 2022-08-26 13:16:09 +02:00
test [pseudo] Eliminate a false parse of structured binding declaration. 2022-08-23 15:25:52 +02:00
tool [pseudo] Placeholder disambiguation strategy: always choose second 2022-08-26 13:16:09 +02:00
unittests [pseudo] Placeholder disambiguation strategy: always choose second 2022-08-26 13:16:09 +02:00
CMakeLists.txt [pseudo] A basic implementation of compiling cxx grammar at build time. 2022-05-25 11:26:06 +02:00
DesignNotes.md [pseudo] Design notes from discussion today. NFC 2022-05-18 00:08:47 +02:00
README.md Reapply [pseudo] Move pseudoparser from clang to clang-tools-extra" 2022-03-16 01:10:55 +01:00

README.md

clang pseudoparser

This directory implements an approximate heuristic parser for C++, based on the clang lexer, the C++ grammar, and the GLR parsing algorithm.

It parses a file in isolation, without reading its included headers. The result is a strict syntactic tree whose structure follows the C++ grammar. There is no semantic analysis, apart from guesses to disambiguate the parse. Disambiguation can optionally be guided by an AST or a symbol index.

For now, the best reference on intended scope is the design proposal, with further discussion on the RFC.

Dependencies between pseudoparser and clang

Dependencies are limited because they don't make sense, but also to avoid placing a burden on clang mantainers.

The pseudoparser reuses the clang lexer (clangLex and clangBasic libraries) but not the higher-level libraries (Parse, Sema, AST, Frontend...).

When the pseudoparser should be used together with an AST (e.g. to guide disambiguation), this is a separate "bridge" library that depends on both.

Clang does not depend on the pseudoparser at all. If this seems useful in future it should be discussed by RFC.

Parity between pseudoparser and clang

The pseudoparser aims to understand real-world code, and particularly the languages and extensions supported by Clang.

However we don't try to keep these in lockstep: there's no expectation that Clang parser changes are accompanied by pseudoparser changes or vice versa.