diff options
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(); |