All pastes #405749 Raw Edit

Mine

public text v1 · immutable
·published 2007-03-21 22:20 UTC
rendered paste body
class sampleLex:

	def __init__(self):
		self.fileName = raw_input("Please enter file name: ")
		self.f = open(self.fileName, 'r')
		self.fLines = self.f.readlines()

		self.alpha = ['a','b','c','d','e','f','g','h','i','j','k','l','m'
					,'n','o','p','q','r','s','t','u','v','w','x','y','z']
		self.digit = ['0','1','2','3','4','5','6','7','8','9']
		self.table = [[1,3,0],
					  [1,1,2],
					  [2,2,2],
					  [3,3,3]]
		self.relations = {"alpha":0, "digit":1}
		self.charStack = []
		self.state = 0


		self.scan()
		
	def scan(self):
		for x in range(0,len(self.fLines)):
			for y in range(0,len(self.fLines[x])):
                                 #this line errors out
				self.state = [int(self.state)][int(self.lex(self.state, self.fLines[x][y]))]
				
	def lex(self, currState, currChar):
		if int(currState) is 3:
			print "Error"
			return 0
		elif int(currState) is 2:
			print ''.join(self.charStack)
			del self.charStack[:]
			return 0
		elif currChar in self.alpha:
			self.charStack.append(currChar)
			return int(self.relations["alpha"])
		elif currChar in self.digit:
			self.charStack.append(currChar)
			return int(self.relations["digit"])
			
sL = sampleLex()