Ejemplo n.º 1
0
def main(filename):
    global tokentuple
    Scan.init(filename)
    while True:
        raw_input("Press Enter")
        print
        (textline, indent, tokens) = Scan.readLine()
        tree, rest = Parse.parseCOMMANDLINE(tokens)
        print "tree =", tree
        print "what's left over:", rest
        prop2 = nnfOf(tree[1])
        print "- shifted inwards:"
        print prop2
        print
        prop3 = nfOf("or", "and", prop2)
        print "cnf:"
        print prop3
        print
        prop4 = flatten("or", "and", prop3)
        print "flattened cnf:"
        print prop4
        print
        prop5 = removeDuplicates(prop4)
        print "no duplicates:", prop5
        prop6 = removeOpposites(prop5)
        print "simplified cnf:"
        print prop6
        for clause in prop6:
            print clause
    Scan.quit()
Ejemplo n.º 2
0
def main(filename) :
    global tokentuple
    Scan.init(filename)
    while True :
       raw_input("Press Enter")
       print
       (textline, indent, tokens) = Scan.readLine()
       tree, rest = parseCOMMANDLINE(tokens) 
       Scan.write(textline)
       print "tree =", tree
       print "what's left over:", rest
Ejemplo n.º 3
0
def testmatch(filename) :
    global tokentuple
    Scan.init(filename)
    raw_input("Press Enter")
    print
    (textline, indent, tokens) = Scan.readLine()
    scheme, rest = parseCOMMANDLINE(tokens)
    Scan.write(textline)
    print "SCHEME =", scheme[1]
    print "what's left over:", rest

    raw_input("Press Enter")
    print
    (textline, indent, tokens) = Scan.readLine()
    tree, rest = parseCOMMANDLINE(tokens)
    Scan.write(textline)
    print "tree =", tree[1]
    print "what's left over:", rest

    matches = {}
    success = match(matches, tree[1],scheme[1])
    print "success = ", success
    print "matches =",  matches