whys - Twinside/Webrexp GitHub Wiki

Implementation why

Explaination of some implementation decision. Right now mostly for myself.

Why DFS evaluator use an automata

A first thought experiment was tried to make the DFS work like the BFS evaluator : by recursion on the expression. At each point where multiple nodes would have been found, they would be stored in a list with the current expression.

Sadly this simple approach didn't work with branches which required back tracking, or even the *, if multiple nodes happen inside the star, it cannot deduce the previous Expression.

One other way to deal with might have been to store the "call" stack and to manipulate it, but it seemed tedious. As a simple translation to an automata was feasible, storing only a state index and a node and adding some counters showed itself as a more elegant design.

And it provide nice schematics :-P

Funny thing is, we can reimplement the BFS evaluator using the automata, simplifying greatly the implementation.

⚠️ **GitHub.com Fallback** ⚠️