[Python-checkins] CVS: python/dist/src/Lib sre_compile.py,1.23,1.24 sre_constants.py,1.15,1.16 sre_parse.py,1.24,1.25

Fredrik Lundh python-dev@python.org
Mon, 3 Jul 2000 14:31:51 -0700


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

Modified Files:
	sre_compile.py sre_constants.py sre_parse.py 
Log Message:


- fixed grouping error bug

- changed "group" operator to "groupref"


Index: sre_compile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** sre_compile.py	2000/07/03 18:44:21	1.23
--- sre_compile.py	2000/07/03 21:31:48	1.24
***************
*** 149,164 ****
                      emit(av[0])
                      emit(av[1])
                      _compile(code, av[2], flags)
                      emit(OPCODES[SUCCESS])
                      code[skip] = len(code) - skip
          elif op is SUBPATTERN:
!             group = av[0]
!             if group:
                  emit(OPCODES[MARK])
!                 emit((group-1)*2)
              _compile(code, av[1], flags)
!             if group:
                  emit(OPCODES[MARK])
!                 emit((group-1)*2+1)
          elif op in (SUCCESS, FAILURE):
              emit(OPCODES[op])
--- 149,171 ----
                      emit(av[0])
                      emit(av[1])
+                     mark = MAXCODE
+                     if av[2][0][0] == SUBPATTERN:
+                         # repeated subpattern
+                         gid, foo = av[2][0][1]
+                         if gid:
+                             mark = (gid-1)*2
+                     emit(mark)
                      _compile(code, av[2], flags)
                      emit(OPCODES[SUCCESS])
                      code[skip] = len(code) - skip
          elif op is SUBPATTERN:
!             gid = av[0]
!             if gid:
                  emit(OPCODES[MARK])
!                 emit((gid-1)*2)
              _compile(code, av[1], flags)
!             if gid:
                  emit(OPCODES[MARK])
!                 emit((gid-1)*2+1)
          elif op in (SUCCESS, FAILURE):
              emit(OPCODES[op])
***************
*** 208,212 ****
              else:
                  emit(CHCODES[av])
!         elif op is GROUP:
              if flags & SRE_FLAG_IGNORECASE:
                  emit(OPCODES[OP_IGNORE[op]])
--- 215,219 ----
              else:
                  emit(CHCODES[av])
!         elif op is GROUPREF:
              if flags & SRE_FLAG_IGNORECASE:
                  emit(OPCODES[OP_IGNORE[op]])

Index: sre_constants.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** sre_constants.py	2000/07/02 17:33:27	1.15
--- sre_constants.py	2000/07/03 21:31:48	1.16
***************
*** 30,35 ****
  CATEGORY = "category"
  CHARSET = "charset"
! GROUP = "group"
! GROUP_IGNORE = "group_ignore"
  IN = "in"
  IN_IGNORE = "in_ignore"
--- 30,35 ----
  CATEGORY = "category"
  CHARSET = "charset"
! GROUPREF = "groupref"
! GROUPREF_IGNORE = "groupref_ignore"
  IN = "in"
  IN_IGNORE = "in_ignore"
***************
*** 91,95 ****
      CATEGORY,
      CHARSET,
!     GROUP, GROUP_IGNORE,
      INDEX,
      IN, IN_IGNORE,
--- 91,95 ----
      CATEGORY,
      CHARSET,
!     GROUPREF, GROUPREF_IGNORE,
      INDEX,
      IN, IN_IGNORE,
***************
*** 137,141 ****
  # replacement operations for "ignore case" mode
  OP_IGNORE = {
!     GROUP: GROUP_IGNORE,
      IN: IN_IGNORE,
      LITERAL: LITERAL_IGNORE,
--- 137,141 ----
  # replacement operations for "ignore case" mode
  OP_IGNORE = {
!     GROUPREF: GROUPREF_IGNORE,
      IN: IN_IGNORE,
      LITERAL: LITERAL_IGNORE,

Index: sre_parse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -r1.24 -r1.25
*** sre_parse.py	2000/07/03 18:44:21	1.24
--- sre_parse.py	2000/07/03 21:31:48	1.25
***************
*** 242,246 ****
                      if (not source.next or
                          not _group(escape + source.next, state.groups)):
!                         return GROUP, group
                      escape = escape + source.get()
                  elif source.next in OCTDIGITS:
--- 242,246 ----
                      if (not source.next or
                          not _group(escape + source.next, state.groups)):
!                         return GROUPREF, group
                      escape = escape + source.get()
                  elif source.next in OCTDIGITS:
***************
*** 451,455 ****
                          if gid is None:
                              raise error, "unknown group name"
!                         subpattern.append((GROUP, gid))
                      elif source.match("#"):
                          index = ""
--- 451,455 ----
                          if gid is None:
                              raise error, "unknown group name"
!                         subpattern.append((GROUPREF, gid))
                      elif source.match("#"):
                          index = ""