From 6340b97a4fc435d838262ed25cee9566fea7da4c Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 16 Feb 2020 16:52:09 +0100 Subject: Add translation phases stubs --- cpp.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ cpp.h | 14 +++++++++++++ 2 files changed, 85 insertions(+) diff --git a/cpp.cpp b/cpp.cpp index d9f2efb..54dd0d2 100644 --- a/cpp.cpp +++ b/cpp.cpp @@ -1,5 +1,8 @@ #include "cpp.h" +#include +#include + void CPP::PreprocessorTokensToTokens(std::vector& tokens) { for (auto& i : tokens) { @@ -8,3 +11,71 @@ void CPP::PreprocessorTokensToTokens(std::vector& tokens) } } +// Phase 1: Map physical character set to basic source character set +void CPP::source_charset_map() +{ + // TODO +} + +// Phase 2: Escape backslashed line endings +void CPP::backslash_escape() +{ + // TODO +} + +// Phase 3: Parse preprocessing tokens +void CPP::preprocessing_tokenize() +{ + // TODO +} + +// Phase 4: Preprocessing +void CPP::preprocess() +{ + // TODO +} + +// Phase 5: Map chars and strings to execution charset +void CPP::execution_charset_map() +{ + // TODO +} + +// Phase 6: Concatenate adjacent string literals +void CPP::concatenate_strings() +{ + // TODO +} + +// Phase 7: Create tokens from preprocessing tokens +void CPP::tokens_from_pptokens() +{ +} + +// Phase 8: Instantiate objects +void CPP::instantiate() +{ +} + +// Phase 9: Link libraries +void CPP::link() +{ +} + +// phases of translation, according to standard +void CPP::translate() +{ + source_charset_map(); + backslash_escape(); + preprocessing_tokenize(); + preprocess(); + execution_charset_map(); + concatenate_strings(); + tokens_from_pptokens(); + instantiate(); + link(); +} + +TEST(Cpp, translate) { + CPP::translate(); +} diff --git a/cpp.h b/cpp.h index 97eea2c..7bb62c2 100644 --- a/cpp.h +++ b/cpp.h @@ -8,4 +8,18 @@ namespace CPP { void PreprocessorTokensToTokens(std::vector& tokens); +// phases of translation, according to standard +void source_charset_map(); // phase 1 +void backslash_escape(); // phase 2 +void preprocessing_tokenize(); // phase 3 +void preprocess(); // phase 4 +void execution_charset_map(); // phase 5 +void concatenate_strings(); // phase 6 +void tokens_from_pptokens(); // phase 7 +void instantiate(); // phase 8 +void link(); // phase 9 + +// all phases of translation +void translate(); + } -- cgit v1.2.3