summaryrefslogtreecommitdiffhomepage
path: root/lexer.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-03-31 18:46:49 +0200
committerRoland Reichwein <mail@reichwein.it>2020-03-31 18:46:49 +0200
commitcd6c436cb70c4323c7d14ebd74f89bb0914649f2 (patch)
tree1bdb2a8409b2b370bcaa5e1b6cf091c0c8e1f779 /lexer.cpp
parentbed46a062c442656b1bc16d965e12405297029d3 (diff)
Optimization: Replace head recursion by tail recursion in matching
Diffstat (limited to 'lexer.cpp')
-rw-r--r--lexer.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/lexer.cpp b/lexer.cpp
index 0944738..a9cda32 100644
--- a/lexer.cpp
+++ b/lexer.cpp
@@ -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());