[Python-checkins] CVS: python/dist/src/Lib sre_parse.py,1.13,1.14

Fredrik Lundh python-dev@python.org
Fri, 30 Jun 2000 02:13:08 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory slayer.i.sourceforge.net:/tmp/cvs-serv5441/Lib

Modified Files:
	sre_parse.py 
Log Message:

- added support for (?P=name)
  (closes #3 and #7 from the status report)


Index: sre_parse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** sre_parse.py	2000/06/30 07:50:59	1.13
--- sre_parse.py	2000/06/30 09:13:05	1.14
***************
*** 190,196 ****
      # check if the escape string represents a valid group
      try:
!         group = int(escape[1:])
!         if group and group < groups:
!             return group
      except ValueError:
          pass
--- 190,196 ----
      # check if the escape string represents a valid group
      try:
!         gid = int(escape[1:])
!         if gid and gid < groups:
!             return gid
      except ValueError:
          pass
***************
*** 443,447 ****
                      elif source.match("="):
                          # named backreference
!                         raise error, "not yet implemented"
                      else:
                          char = source.get()
--- 443,460 ----
                      elif source.match("="):
                          # named backreference
!                         name = ""
!                         while 1:
!                             char = source.get()
!                             if char is None:
!                                 raise error, "unterminated name"
!                             if char == ")":
!                                 break
!                             name = name + char
!                         if not isname(name):
!                             raise error, "illegal character in group name"
!                         gid = state.groupdict.get(name)
!                         if gid is None:
!                             raise error, "unknown group name"
!                         subpattern.append((GROUP, gid))
                      else:
                          char = source.get()