From 2eb2383387d16fc919c07e1a6b9211406576b893 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 29 Mar 2020 20:15:52 +0200 Subject: Fix compiler structure --- cpp.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'cpp.cpp') diff --git a/cpp.cpp b/cpp.cpp index 73f11e1..ea40661 100644 --- a/cpp.cpp +++ b/cpp.cpp @@ -182,7 +182,7 @@ namespace { } // Phase 7.a: Create tokens from preprocessing tokens -std::vector CPP::tokens_from_pptokens(std::vector pp_tokens) +std::vector CPP::tokens_from_pptokens(const std::vector& pp_tokens) { std::vector result; @@ -213,7 +213,7 @@ std::vector CPP::tokens_from_pptokens(std::vector pp_tokens) } // Phase 7.b: Grammar Analysis -std::vector CPP::analysis(std::vector tokens) +std::vector CPP::analysis(const std::vector& tokens) { auto bnf = SubBNF(CPPBNF::GetCppBNFGram(), "translation-unit"); @@ -223,9 +223,12 @@ std::vector CPP::analysis(std::vector tokens) } // Phase 7.c: Translate -void CPP::translate() +void CPP::translate(const std::vector& 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(); -- cgit v1.2.3