~pythonregexp2.7/python/issue2636-01

« back to all changes in this revision

Viewing changes to Lib/sre_compile.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-06-04 18:18:53 UTC
  • Revision ID: darklord@timehorse.com-20080604181853-e6gdtrrue6x0bkd9
Second attempt at figuring out how to implement the non-simple version
of the Possessive Qualifiers, this time with both a custom UNTIL handler
and a custom REPEAT handler; I am now thinking we need no
POSSESSIVE_UNTIL; this can be replaced by a simple SUCCESS and do all the
work in the POSSESSIVE_REPEAT handler via a while loop and ctx->count. 
Not sure yet if this will work, but it's worth a try as the current
attempt certainly will not work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
                _compile(code, av[2], flags)
92
92
                emit(OPCODES[SUCCESS])
93
93
                code[skip] = _len(code) - skip
 
94
            elif op is POSSESSIVE_REPEAT:
 
95
                emit(OPCODES[POSSESSIVE_REPEAT])
 
96
                skip = _len(code); emit(0)
 
97
                emit(av[0])
 
98
                emit(av[1])
 
99
                _compile(code, av[2], flags)
 
100
                code[skip] = _len(code) - skip
 
101
                emit(OPCODES[POSSESSIVE_UNTIL])
94
102
            else:
95
103
                emit(OPCODES[REPEAT])
96
104
                skip = _len(code); emit(0)
102
110
                #       Default of MIN_UNTIL may be wrong
103
111
                if op is MAX_REPEAT:
104
112
                    emit(OPCODES[MAX_UNTIL])
105
 
                elif op is POSSESSIVE_REPEAT:
106
 
                    emit(OPCODES[POSSESSIVE_UNTIL])
107
113
                else:
108
114
                    emit(OPCODES[MIN_UNTIL])
109
115
        elif op is SUBPATTERN: