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

Fredrik Lundh python-dev@python.org
Sat, 1 Jul 2000 16:49:16 -0700


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

Modified Files:
	sre_parse.py 
Log Message:


- fixed "{ in any other context" bug

- minor comment touchups in the C module

Index: sre_parse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** sre_parse.py	2000/07/01 17:50:59	1.19
--- sre_parse.py	2000/07/01 23:49:14	1.20
***************
*** 143,152 ****
  class Tokenizer:
      def __init__(self, string):
-         self.index = 0
          self.string = string
!         self.next = self.__next()
      def __next(self):
          if self.index >= len(self.string):
!             return None
          char = self.string[self.index]
          if char[0] == "\\":
--- 143,153 ----
  class Tokenizer:
      def __init__(self, string):
          self.string = string
!         self.index = 0
!         self.__next()
      def __next(self):
          if self.index >= len(self.string):
!             self.next = None
!             return
          char = self.string[self.index]
          if char[0] == "\\":
***************
*** 157,175 ****
              char = char + c
          self.index = self.index + len(char)
!         return char
      def match(self, char):
          if char == self.next:
!             self.next = self.__next()
!             return 1
!         return 0
!     def match_set(self, set):
!         if self.next and self.next in set:
!             self.next = self.__next()
              return 1
          return 0
      def get(self):
          this = self.next
!         self.next = self.__next()
          return this
  
  def isident(char):
--- 158,175 ----
              char = char + c
          self.index = self.index + len(char)
!         self.next = char
      def match(self, char):
          if char == self.next:
!             self.__next()
              return 1
          return 0
      def get(self):
          this = self.next
!         self.__next()
          return this
+     def tell(self):
+         return self.index, self.next
+     def seek(self, index):
+         self.index, self.next = index
  
  def isident(char):
***************
*** 382,385 ****
--- 382,386 ----
                  min, max = 1, MAXREPEAT
              elif this == "{":
+                 here = source.tell()
                  min, max = 0, MAXREPEAT
                  lo = hi = ""
***************
*** 392,396 ****
                      hi = lo
                  if not source.match("}"):
!                     raise error, "bogus range"
                  if lo:
                      min = int(lo)
--- 393,399 ----
                      hi = lo
                  if not source.match("}"):
!                     subpattern.append((LITERAL, ord(this)))
!                     source.seek(here)
!                     continue
                  if lo:
                      min = int(lo)