coli-saar / alto

Alto, the Algebraic Language Toolkit
Other
16 stars 2 forks source link

Check for cyclicity as part of TreeAutomaton#evaluateInSemiring #14

Open akoehn opened 8 years ago

akoehn commented 8 years ago

Original report by Alexander Koller (Bitbucket: akoller, GitHub: alexanderkoller).


Right now, evaluateInSemiring will return an (incorrect) value if the tree automaton has cycles. We should check for cycles in TreeAutomaton#getStatesInBottomUpOrder and throw an exception if a cycle occurs.

This has two advantages. First, it ensures that evaluateInSemiring is only used when it returns the correct value. Second, it makes the use of TreeAutomaton#isCyclic in JLanguageViewer unnecessary (the if block can just be replaced by catching the exception). For some reason, this method is incredibly slow for some grammars, and it would be good to get rid of it.