[Python-checkins] CVS: python/dist/src/Tools/bgen/bgen scantools.py,1.21,1.22

Jack Jansen jackjansen@users.sourceforge.net
Fri, 13 Jul 2001 15:28:38 -0700


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

Modified Files:
	scantools.py 
Log Message:
Allow [] after a parameter name. We currently take this to be the same as * in front, which isn't 100% correct but good enough.

Index: scantools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/scantools.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -r1.21 -r1.22
*** scantools.py	2001/06/26 21:53:25	1.21
--- scantools.py	2001/07/13 22:28:36	1.22
***************
*** 245,249 ****
  		self.sym_pat = "^[ \t]*\(<name>[a-zA-Z0-9_]+\)[ \t]*=" + \
  		               "[ \t]*\(<defn>[-0-9_a-zA-Z'\"(][^\t\n,;}]*\),?"
! 		self.asplit_pat = "^\(<type>.*[^a-zA-Z0-9_]\)\(<name>[a-zA-Z0-9_]+\)$"
  		self.comment1_pat = "\(<rest>.*\)//.*"
  		# note that the next pattern only removes comments that are wholly within one line
--- 245,249 ----
  		self.sym_pat = "^[ \t]*\(<name>[a-zA-Z0-9_]+\)[ \t]*=" + \
  		               "[ \t]*\(<defn>[-0-9_a-zA-Z'\"(][^\t\n,;}]*\),?"
! 		self.asplit_pat = "^\(<type>.*[^a-zA-Z0-9_]\)\(<name>[a-zA-Z0-9_]+\)\(<array>\[\]\)?$"
  		self.comment1_pat = "\(<rest>.*\)//.*"
  		# note that the next pattern only removes comments that are wholly within one line
***************
*** 471,476 ****
  		if self.asplit.match(part) < 0:
  			self.error("Indecipherable argument: %s", `part`)
  			return ("unknown", part, mode)
! 		type, name = self.asplit.group('type', 'name')
  		type = regsub.gsub("\*", " ptr ", type)
  		type = string.strip(type)
--- 471,480 ----
  		if self.asplit.match(part) < 0:
  			self.error("Indecipherable argument: %s", `part`)
+ 			import pdb ; pdb.set_trace()
  			return ("unknown", part, mode)
! 		type, name, array = self.asplit.group('type', 'name', 'array')
! 		if array:
! 			# array matches an optional [] after the argument name
! 			type = type + " ptr "
  		type = regsub.gsub("\*", " ptr ", type)
  		type = string.strip(type)
***************
*** 574,581 ****
  		Scanner.initpatterns(self)
  		self.head_pat = "^extern pascal[ \t]+" # XXX Mac specific!
- 		self.tail_pat = "[;={}]"
  		self.type_pat = "pascal[ \t\n]+\(<type>[a-zA-Z0-9_ \t]*[a-zA-Z0-9_]\)[ \t\n]+"
- 		self.name_pat = "\(<name>[a-zA-Z0-9_]+\)[ \t\n]*"
- 		self.args_pat = "(\(<args>\([^(;=)]+\|([^(;=)]*)\)*\))"
  		self.whole_pat = self.type_pat + self.name_pat + self.args_pat
  		self.sym_pat = "^[ \t]*\(<name>[a-zA-Z0-9_]+\)[ \t]*=" + \
--- 578,582 ----
***************
*** 586,605 ****
  	"""Scanner for modern (post UH3.3) Universal Headers """
  	def initpatterns(self):
  		self.head_pat = "^EXTERN_API_C"
- 		self.tail_pat = "[;={}]"
  		self.type_pat = "EXTERN_API_C" + \
  						"[ \t\n]*([ \t\n]*" + \
  						"\(<type>[a-zA-Z0-9_* \t]*[a-zA-Z0-9_*]\)" + \
  						"[ \t\n]*)[ \t\n]*"
- 		self.name_pat = "\(<name>[a-zA-Z0-9_]+\)[ \t\n]*"
- 		self.args_pat = "(\(<args>\([^(;=)]+\|([^(;=)]*)\)*\))"
  		self.whole_pat = self.type_pat + self.name_pat + self.args_pat
  		self.sym_pat = "^[ \t]*\(<name>[a-zA-Z0-9_]+\)[ \t]*=" + \
  		               "[ \t]*\(<defn>[-0-9_a-zA-Z'\"(][^\t\n,;}]*\),?"
- 		self.asplit_pat = "^\(<type>.*[^a-zA-Z0-9_]\)\(<name>[a-zA-Z0-9_]+\)$"
- 		self.comment1_pat = "\(<rest>.*\)//.*"
- 		# note that the next pattern only removes comments that are wholly within one line
- 		self.comment2_pat = "\(<rest1>.*\)/\*.*\*/\(<rest2>.*\)"
- 
  	
  def test():
--- 587,599 ----
  	"""Scanner for modern (post UH3.3) Universal Headers """
  	def initpatterns(self):
+ 		Scanner.initpatterns(self)
  		self.head_pat = "^EXTERN_API_C"
  		self.type_pat = "EXTERN_API_C" + \
  						"[ \t\n]*([ \t\n]*" + \
  						"\(<type>[a-zA-Z0-9_* \t]*[a-zA-Z0-9_*]\)" + \
  						"[ \t\n]*)[ \t\n]*"
  		self.whole_pat = self.type_pat + self.name_pat + self.args_pat
  		self.sym_pat = "^[ \t]*\(<name>[a-zA-Z0-9_]+\)[ \t]*=" + \
  		               "[ \t]*\(<defn>[-0-9_a-zA-Z'\"(][^\t\n,;}]*\),?"
  	
  def test():