diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-03-31 18:46:49 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-03-31 18:46:49 +0200 |
commit | cd6c436cb70c4323c7d14ebd74f89bb0914649f2 (patch) | |
tree | 1bdb2a8409b2b370bcaa5e1b6cf091c0c8e1f779 /lexer.cpp | |
parent | bed46a062c442656b1bc16d965e12405297029d3 (diff) |
Optimization: Replace head recursion by tail recursion in matching
Diffstat (limited to 'lexer.cpp')
-rw-r--r-- | lexer.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -85,14 +85,14 @@ void Lexer::addRule(const std::vector<std::string>& list, size_t list_index_from for (size_t i = list_index_from; i < list_index_to - 1; i++) { std::string symbol{list[i]}; if (symbol == rule_symbol) - throw std::runtime_error("Recursion found but not allowed"); + throw std::runtime_error("Recursion found but not allowed. Only head recursion allowed for lexer."); size_t state{newState()}; addPathOrTransition(previousState, state, symbol); previousState = state; } if (list.back() == rule_symbol) - throw std::runtime_error("Recursion found but not allowed"); + throw std::runtime_error("Tail recursion found but not allowed. Only head recursion allowed for lexer."); // last transition addPathOrTransition(previousState, state1, list.back()); |