diff options
| author | Roland Reichwein <mail@reichwein.it> | 2020-01-25 13:19:49 +0100 | 
|---|---|---|
| committer | Roland Reichwein <mail@reichwein.it> | 2020-01-25 13:19:49 +0100 | 
| commit | c984c05f2f2d6c9cee4a0eb561fd7184786c5d1d (patch) | |
| tree | ede659042357aa5b7a3564c650edf8b42f9d7c71 | |
| parent | e172ed9f799501c234c8da18cef829244473f1d7 (diff) | |
Minor fixes
| -rw-r--r-- | grammer.cpp | 2 | ||||
| -rw-r--r-- | lexer.cpp | 2 | ||||
| -rw-r--r-- | test-lexer.cpp | 6 | 
3 files changed, 6 insertions, 4 deletions
| diff --git a/grammer.cpp b/grammer.cpp index 796c099..508d6c5 100644 --- a/grammer.cpp +++ b/grammer.cpp @@ -179,7 +179,7 @@ bool Tree::Add(const Token& token, const BNF& bnf, const std::map<std::string, s    std::vector<TreeNode> parent_nodes = getParentTreeNode(bnf, reverseBNF);    if (parent_nodes.size() == 0) -   throw std::runtime_error("Couldn't add new parent node for "s + nodes[root].token.type); +   throw std::runtime_error("Couldn't add new parent node for "s + nodes[root].token.type + "("s + std::to_string(root) + ")"s);    for (const auto &i : parent_nodes) {     AddRootNode(i); @@ -292,7 +292,7 @@ std::vector<Token> Lexer::Lex(const std::string& s)   return result;  } -// C++: Preprocessor Tokens To Tokens +// TODO: C++: Preprocessor Tokens To Tokens  void Lexer::PreprocessorTokensToTokens(std::vector<Token>& tokens)  {   for (auto& i : tokens) { diff --git a/test-lexer.cpp b/test-lexer.cpp index 4f68fc6..71f787a 100644 --- a/test-lexer.cpp +++ b/test-lexer.cpp @@ -48,8 +48,10 @@ TEST_F(Test, BNF) {   std::string Top{"program"};   BNF bnf{    {"program", {{"statement-list"}}}, -  {"statement-list", {{"statement-list", "statement"}, -                      {"statement"}, }}, +  {"statement-list", { +                      {"statement"}, +                      {"statement-list", "statement"}, +                     }},    {"statement", {{"assignment", ";"}}},    {"assignment", {{"identifier", "=", "identifier"},                    {"identifier", "=", "pp-number"}}} | 
