Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/cxx-frontend/src/TokenKind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export enum TokenKind {
UTF32_STRING_LITERAL,
UTF8_STRING_LITERAL,
WIDE_STRING_LITERAL,
PP_INTERNAL_VARIABLE,
AMP_AMP,
AMP_EQUAL,
AMP,
Expand Down
1 change: 1 addition & 0 deletions packages/cxx-gen-ast/src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const BASE_TOKENS: string[] = [
"UTF32_STRING_LITERAL",
"UTF8_STRING_LITERAL",
"WIDE_STRING_LITERAL",
"PP_INTERNAL_VARIABLE",
];

export const OPERATORS: Array<[kind: string, spelling: string]> = [
Expand Down
34 changes: 17 additions & 17 deletions src/frontend/cxx/frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ auto runOnFile(const CLI& cli, const std::string& fileName) -> bool {
VerifyDiagnosticsClient diagnosticsClient;
TranslationUnit unit(&diagnosticsClient);

auto preprocesor = unit.preprocessor();
auto preprocessor = unit.preprocessor();

std::unique_ptr<Toolchain> toolchain;

if (cli.opt_verify) {
diagnosticsClient.setVerify(true);
preprocesor->setCommentHandler(&diagnosticsClient);
preprocessor->setCommentHandler(&diagnosticsClient);
}

auto toolchainId = cli.getSingle("-toolchain");
Expand All @@ -117,7 +117,7 @@ auto runOnFile(const CLI& cli, const std::string& fileName) -> bool {
}

if (toolchainId == "darwin" || toolchainId == "macos") {
auto macosToolchain = std::make_unique<MacOSToolchain>(preprocesor);
auto macosToolchain = std::make_unique<MacOSToolchain>(preprocessor);
std::string host;
#ifdef __aarch64__
host = "aarch64";
Expand All @@ -128,7 +128,7 @@ auto runOnFile(const CLI& cli, const std::string& fileName) -> bool {
toolchain = std::move(macosToolchain);

} else if (toolchainId == "wasm32") {
auto wasmToolchain = std::make_unique<Wasm32WasiToolchain>(preprocesor);
auto wasmToolchain = std::make_unique<Wasm32WasiToolchain>(preprocessor);

fs::path app_dir;

Expand Down Expand Up @@ -162,9 +162,9 @@ auto runOnFile(const CLI& cli, const std::string& fileName) -> bool {
#endif

std::string arch = cli.getSingle("-arch").value_or(host);
toolchain = std::make_unique<GCCLinuxToolchain>(preprocesor, arch);
toolchain = std::make_unique<GCCLinuxToolchain>(preprocessor, arch);
} else if (toolchainId == "windows") {
auto windowsToolchain = std::make_unique<WindowsToolchain>(preprocesor);
auto windowsToolchain = std::make_unique<WindowsToolchain>(preprocessor);

if (auto paths = cli.get("-vctoolsdir"); !paths.empty()) {
windowsToolchain->setVctoolsdir(paths.back());
Expand Down Expand Up @@ -192,12 +192,12 @@ auto runOnFile(const CLI& cli, const std::string& fileName) -> bool {
}

for (const auto& path : cli.get("-I")) {
preprocesor->addSystemIncludePath(path);
preprocessor->addSystemIncludePath(path);
}

if (cli.opt_v) {
std::cerr << std::format("#include <...> search starts here:\n");
const auto& paths = preprocesor->systemIncludePaths();
const auto& paths = preprocessor->systemIncludePaths();
for (auto it = rbegin(paths); it != rend(paths); ++it) {
std::cerr << std::format(" {}\n", *it);
}
Expand All @@ -208,14 +208,14 @@ auto runOnFile(const CLI& cli, const std::string& fileName) -> bool {
auto sep = macro.find_first_of("=");

if (sep == std::string::npos) {
preprocesor->defineMacro(macro, "1");
preprocessor->defineMacro(macro, "1");
} else {
preprocesor->defineMacro(macro.substr(0, sep), macro.substr(sep + 1));
preprocessor->defineMacro(macro.substr(0, sep), macro.substr(sep + 1));
}
}

for (const auto& macro : cli.get("-U")) {
preprocesor->undefMacro(macro);
preprocessor->undefMacro(macro);
}

auto outputs = cli.get("-o");
Expand All @@ -229,11 +229,11 @@ auto runOnFile(const CLI& cli, const std::string& fileName) -> bool {
bool shouldExit = false;

if (cli.opt_P) {
preprocesor->setOmitLineMarkers(true);
preprocessor->setOmitLineMarkers(true);
}

if (cli.opt_H && (cli.opt_E || cli.opt_Eonly)) {
preprocesor->setOnWillIncludeHeader(
preprocessor->setOnWillIncludeHeader(
[&](const std::string& header, int level) {
std::string fill(level, '.');
std::cout << std::format("{} {}\n", fill, header);
Expand All @@ -243,14 +243,14 @@ auto runOnFile(const CLI& cli, const std::string& fileName) -> bool {
if (auto source = readAll(fileName)) {
if (cli.opt_E && !cli.opt_dM) {
std::vector<Token> tokens;
preprocesor->preprocess(std::move(*source), fileName, tokens);
preprocesor->getPreprocessedText(tokens, output);
preprocessor->preprocess(std::move(*source), fileName, tokens);
preprocessor->getPreprocessedText(tokens, output);
shouldExit = true;
} else {
unit.setSource(std::move(*source), fileName);

if (cli.opt_dM) {
preprocesor->printMacros(output);
preprocessor->printMacros(output);
shouldExit = true;
} else if (cli.opt_dump_tokens) {
dumpTokens(cli, unit, output);
Expand All @@ -266,7 +266,7 @@ auto runOnFile(const CLI& cli, const std::string& fileName) -> bool {
}

if (!shouldExit) {
preprocesor->squeeze();
preprocessor->squeeze();

unit.parse(ParserConfiguration{
.checkTypes = cli.opt_fcheck,
Expand Down
Loading