[Pseudo] Token/TokenStream, PP directive parser.
authorSam McCall <sam.mccall@gmail.com>
Mon, 7 Feb 2022 18:11:16 +0000 (19:11 +0100)
committerSam McCall <sam.mccall@gmail.com>
Wed, 23 Feb 2022 16:52:02 +0000 (17:52 +0100)
commit7c1ee5e95f3159e13edef644db0509a7d49921c3
treed77a86f6ab25a1a7ebd5daf39a061001ae2e4d75
parent70ff6fbeb9b5acb4995dc42286954b762d0937fd
[Pseudo] Token/TokenStream, PP directive parser.

The TokenStream class is the representation of the source code that will
be fed into the GLR parser.

This patch allows a "raw" TokenStream to be built by reading source code.
It also supports scanning a TokenStream to find the directive structure.

Next steps (with placeholders in the code): heuristically choosing a
path through #ifs, preprocessing the code by stripping directives and comments.
These will produce a suitable stream to feed into the parser proper.

Differential Revision: https://reviews.llvm.org/D119162
13 files changed:
clang/include/clang/Basic/TokenKinds.h
clang/include/clang/Tooling/Syntax/Pseudo/Preprocess.h [new file with mode: 0644]
clang/include/clang/Tooling/Syntax/Pseudo/Token.h [new file with mode: 0644]
clang/lib/Basic/TokenKinds.cpp
clang/lib/Tooling/Syntax/Pseudo/CMakeLists.txt
clang/lib/Tooling/Syntax/Pseudo/Lex.cpp [new file with mode: 0644]
clang/lib/Tooling/Syntax/Pseudo/Preprocess.cpp [new file with mode: 0644]
clang/lib/Tooling/Syntax/Pseudo/Token.cpp [new file with mode: 0644]
clang/test/Syntax/lex.c [new file with mode: 0644]
clang/tools/clang-pseudo/ClangPseudo.cpp
clang/unittests/Tooling/Syntax/Pseudo/CMakeLists.txt
clang/unittests/Tooling/Syntax/Pseudo/PreprocessTest.cpp [new file with mode: 0644]
clang/unittests/Tooling/Syntax/Pseudo/TokenTest.cpp [new file with mode: 0644]