示例#1
0
task2 = table(sys.argv[1])
mx = task2.construct()

for line in open(sys.argv[2], 'rU'):
    trig = 0
    stk = Stack()
    stk.push('S $')
    #	print '***',stk.prt()
    #	line=line[:-1]
    line = line[:-1] + '$'
    #	line+='$'
    print '++', line
    index = 0
    a = line[index]
    while not stk.is_empty():
        print '--', stk.prt()
        #		print '||',a
        X = stk.top()
        if X.isupper():
            #			print 'run 1','|',X,'|',a,'|',mx.get(X,a)
            if mx.get(X, a) != -1 and mx.get(X, a) != None:
                print mx.get(X, a)
                stk.pop()
                stk.push(mx.get(X, a)[0])
            else:
                print 'reject 1'
                trig = 1
                break
        else:
            #			print 'run 2','|',X,'|',a
            if X == a:
示例#2
0
#! /usr/local/bin/python
from common import table
from common import Stack
import sys
task2 = table(sys.argv[1])
mx = task2.construct()
#stk=Stack()
#stk.push('S $')

for line in open(sys.argv[2], 'rU'):
    trig = 0
    stk = Stack()
    stk.push('S $')
    print '***', stk.prt()
    line = line[:-1]
    line += '$'
    print '++', line
    index = 0
    a = line[index]
    while not stk.is_empty():
        print '--', stk.prt()
        #		print '||',a
        X = stk.top()
        if X.isupper():
            print 'run 1', '|', X, '|', a, '|', mx.get(X, a)
            if mx.get(X, a) != -1 and mx.get(X, a) != None:
                print mx.get(X, a)
                stk.pop()
                stk.push(mx.get(X, a)[0])
            else:
                print 'reject 1'
示例#3
0
#! /usr/local/bin/python
from common import Stack
ss = Stack()
ss.push('abc')
ss.push('def')

print ss.prt()
示例#4
0
#! /usr/local/bin/python
from common import table
from common import Stack
import sys
task2=table(sys.argv[1])
mx=task2.construct()
#stk=Stack()
#stk.push('S $')

for line in open(sys.argv[2],'rU'):
	trig=0
	stk=Stack()
	stk.push('S $')
	print '***',stk.prt()
	line=line[:-1]
	line+='$'
	print '++',line
	index=0
	a=line[index]
	while not stk.is_empty():
		print '--',stk.prt()
		#		print '||',a
		X=stk.top()
		if X.isupper():
			print 'run 1','|',X,'|',a,'|',mx.get(X,a)
			if mx.get(X,a)!=-1 and mx.get(X,a)!=None:
				print mx.get(X,a)
				stk.pop()
				stk.push(mx.get(X,a)[0])
			else:
				print 'reject 1'
示例#5
0
文件: test.py 项目: mtswiss/UniWork
#! /usr/local/bin/python
from common import Stack
ss=Stack()
ss.push('abc')
ss.push('def')


print ss.prt()