@staticmethod
    def _traverse_grammar_postfix(grammar, start="root"):
        nalt, natom = [], 0
        parens = []
        for c in GrammarCracker._traverse_grammar_infix(grammar, start):
            if c is GrammarCracker._lparen:
                if natom > 1:
                    natom -= 1
                    yield GrammarCracker._concat
                parens.append((nalt, natom))
                nalt, natom = [], 0
            elif isinstance(c, _bstate):
                assert natom > 0
                for _ in range(natom-1):
                    yield GrammarCracker._concat
                natom = 0
                nalt.append(c)
            elif c is GrammarCracker._rparen:
                assert len(parens)
                assert natom > 0
                for _ in range(natom-1):
                    yield GrammarCracker._concat
                for i in reversed(nalt):
                    yield i
                nalt, natom = parens.pop()
                natom += 1
            elif isinstance(c, tuple):
                assert natom > 0
                yield c
            else:
                if natom > 1:
                    yield GrammarCracker._concat
                else:
                    natom += 1
                yield c
        assert not parens
        for _ in range(natom-1):
            yield GrammarCracker._concat
        for i in reversed(nalt):
            yield i
Convert infix regexp re to postfix notation.
dataset/ETHPy150Open blackberry/ALF/alf/fuzz/grammr2_crack.py/GrammarCracker._traverse_grammar_postfix