[Python-checkins] python/dist/src/Tools/bgen/bgen scantools.py,1.25,1.26

jackjansen@sourceforge.net jackjansen@sourceforge.net
Fri, 12 Apr 2002 06:21:52 -0700


Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen
In directory usw-pr-cvs1:/tmp/cvs-serv11767

Modified Files:
	scantools.py 
Log Message:
- Added support for inherent pointer types (typedefs of arrays)
- Added a debug class variable to enable parser debugging.


Index: scantools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/scantools.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** scantools.py	12 Dec 2001 20:51:22 -0000	1.25
--- scantools.py	12 Apr 2002 13:21:49 -0000	1.26
***************
*** 33,36 ****
--- 33,39 ----
  class Scanner:
  
+ 	# Set to 1 in subclass to debug your scanner patterns.
+ 	debug = 0 
+ 
  	def __init__(self, input = None, output = None, defsoutput = None):
  		self.initsilent()
***************
*** 120,123 ****
--- 123,127 ----
  	def initrepairinstructions(self):
  		self.repairinstructions = self.makerepairinstructions()
+ 		self.inherentpointertypes = self.makeinherentpointertypes()
  
  	def makerepairinstructions(self):
***************
*** 211,214 ****
--- 215,221 ----
  			list.append((fpat, patterns, replacements))
  		return list
+ 		
+ 	def makeinherentpointertypes(self):
+ 		return []
  	
  	def openrepairfile(self, filename = "REPAIR"):
***************
*** 396,407 ****
--- 403,424 ----
  				try: line = self.getline()
  				except EOFError: break
+ 				if self.debug:
+ 					self.report("LINE: %s" % `line`)
  				if self.comment1.match(line) >= 0:
  					line = self.comment1.group('rest')
+ 					if self.debug:
+ 						self.report("\tafter comment1: %s" % `line`)
  				while self.comment2.match(line) >= 0:
  					line = self.comment2.group('rest1')+self.comment2.group('rest2')
+ 					if self.debug:
+ 						self.report("\tafter comment2: %s" % `line`)
  				if self.defsfile and self.sym.match(line) >= 0:
+ 					if self.debug:
+ 						self.report("\tmatches sym.")
  					self.dosymdef()
  					continue
  				if self.head.match(line) >= 0:
+ 					if self.debug:
+ 						self.report("\tmatches head.")
  					self.dofuncspec()
  					continue
***************
*** 412,415 ****
--- 429,434 ----
  	def dosymdef(self):
  		name, defn = self.sym.group('name', 'defn')
+ 		if self.debug:
+ 			self.report("\tsym: name=%s, defn=%s" % (`name`, `defn`))
  		if not name in self.blacklistnames:
  			self.defsfile.write("%s = %s\n" % (name, defn))
***************
*** 422,430 ****
--- 441,457 ----
  		while self.tail.search(raw) < 0:
  			line = self.getline()
+ 			if self.debug:
+ 				self.report("* CONTINUATION LINE: %s" % `line`)
  			if self.comment1.match(line) >= 0:
  				line = self.comment1.group('rest')
+ 				if self.debug:
+ 					self.report("\tafter comment1: %s" % `line`)
  			while self.comment2.match(line) >= 0:
  				line = self.comment2.group('rest1')+self.comment2.group('rest2')
+ 				if self.debug:
+ 					self.report("\tafter comment1: %s" % `line`)
  			raw = raw + line
+ 		if self.debug:
+ 			self.report("* WHOLE LINE: %s" % `raw`)
  		self.processrawspec(raw)
  
***************
*** 432,435 ****
--- 459,467 ----
  		if self.whole.search(raw) < 0:
  			self.report("Bad raw spec: %s", `raw`)
+ 			if self.debug:
+ 				if self.type.search(raw) < 0:
+ 					self.report("(Type already doesn't match)")
+ 				else:
+ 					self.report("(Type matched: %s)" % `self.type.group('type')`)
  			return
  		type, name, args = self.whole.group('type', 'name', 'args')
***************
*** 486,489 ****
--- 518,523 ----
  		elif type[-4:] == "_ptr":
  			type = type[:-4]
+ 			mode = "OutMode"
+ 		elif type in self.inherentpointertypes:
  			mode = "OutMode"
  		if type[-4:] == "_far":