From cd6c436cb70c4323c7d14ebd74f89bb0914649f2 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Tue, 31 Mar 2020 18:46:49 +0200 Subject: Optimization: Replace head recursion by tail recursion in matching --- lexer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lexer.cpp') 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& 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()); -- cgit v1.2.3