[ create a new paste ] login | about

Link: http://codepad.org/wK8m0Ebf    [ raw code | fork ]

C, pasted on Jun 12:
shift_eims = (current, nodes, edges, cc, right_recursive, leos):
    if is_leo_eligible(edges, right_recursive)
        eim = edges[0].eim
        bb = edges[0].cc
        if eim.rule in leos
            root = leos[eim.rule]
            if eim.leo
                root.leo = eim.leo
                eim = eim.leo
            else
                root.leo = eim
            print("  OH SHIT, LION, RUN!!!")
            print("     ", leos[eim.rule])
            print("     ", eim)
            # todo, put leo item into cc
        else
            leos[eim.rule] = eim
        shift_eim(current, nodes, eim, bb, cc)
    else
        for trans in edges
            shift_eim(current, nodes, trans.eim, trans.cc, cc)

is_leo_eligible = (edges, right_recursive):
    if edges.length != 1 # must be postdot-unique
        return false
    eim = edges[0].eim
    return eim.rule in right_recursive and eim.pos == eim.rule.rhs.length - 1 #quasi-complete

shift_eim = (current, nodes, eim, bb, cc):
    eim = eim.next()
    try
        sppf = nodes[eim]
        sppf.insert(bb, cc)
    except KeyError as _
        if bb
            start = bb.start
        else
            start = cc.start
        nodes[eim] = sppf = SPPF(start, cc.stop, eim.rule, Link(bb, cc))
        current.append(eim)


Create a new paste based on this one


Comments: