davidbien / lexang

Lexical Analyzer Generator Template Library
Boost Software License 1.0
0 stars 0 forks source link

Detect isolated anti-accepting states (whether or not they are marked with anti-accept) and optimize. #13

Open davidbien opened 3 years ago

davidbien commented 3 years ago

If all transition from an anti-accepting state go to that same anti-accepting state then we can remove all the transitions and just accept that anti-accepting state at first encounter. This is not only faster but correctly indicates the start of the anti-accepting state. Currently we must treat anti-accepting states differently from accepting states as we want the first encountered anti-accepting state and the last encountered accepting state and in fact this treatment shouldn't change - it is and will be correct after this optimization. However in cases where all transitions return to an anti-accepting state we should be able to stop translating at first encounter.