diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-03-29 20:15:52 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-03-29 20:15:52 +0200 |
commit | 2eb2383387d16fc919c07e1a6b9211406576b893 (patch) | |
tree | 83e5c5feb3b337552590d1ce7a4730d91081327f /cpp.cpp | |
parent | 12c12ebbdd3f843c87ba12c29727003f1f78a7ff (diff) |
Fix compiler structure
Diffstat (limited to 'cpp.cpp')
-rw-r--r-- | cpp.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -182,7 +182,7 @@ namespace { } // Phase 7.a: Create tokens from preprocessing tokens -std::vector<Token> CPP::tokens_from_pptokens(std::vector<Token> pp_tokens) +std::vector<Token> CPP::tokens_from_pptokens(const std::vector<Token>& pp_tokens) { std::vector<Token> result; @@ -213,7 +213,7 @@ std::vector<Token> CPP::tokens_from_pptokens(std::vector<Token> pp_tokens) } // Phase 7.b: Grammar Analysis -std::vector<Gram::TreeNode> CPP::analysis(std::vector<Token> tokens) +std::vector<Gram::TreeNode> CPP::analysis(const std::vector<Token>& tokens) { auto bnf = SubBNF(CPPBNF::GetCppBNFGram(), "translation-unit"); @@ -223,9 +223,12 @@ std::vector<Gram::TreeNode> CPP::analysis(std::vector<Token> tokens) } // Phase 7.c: Translate -void CPP::translate() +void CPP::translate(const std::vector<Gram::TreeNode>& tree) { - // TODO + if (tree.size() == 0) + throw std::runtime_error("ICE: Tree is empty"); + + //traverse(i, ); } // Phase 8: Instantiate objects @@ -241,7 +244,7 @@ void CPP::link() } // phases of translation, according to standard -void CPP::translate(const std::string& code) +void CPP::compile(const std::string& code) { source_charset_map(); @@ -257,7 +260,7 @@ void CPP::translate(const std::string& code) auto tokens = tokens_from_pptokens(pp_tokens); auto nodes = analysis(tokens); - translate(); + translate(nodes); instantiate(); |