gh-91870: Remove unsupported SRE opcode CALL (GH-91872)

It was initially added to support atomic groups, but that
support was never fully implemented, and CALL was only left
in the compiler, but not interpreter and parser.

ATOMIC_GROUP is now used to support atomic groups.
This commit is contained in:
Serhiy Storchaka 2022-04-26 21:07:25 +03:00 committed by GitHub
parent 1af871eeee
commit f703c96cf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 52 deletions

View file

@ -164,12 +164,6 @@ def _compile(data, pattern, flags):
_compile(data, av[1], flags)
emit(SUCCESS)
code[skip] = _len(code) - skip
elif op is CALL:
emit(op)
skip = _len(code); emit(0)
_compile(data, av, flags)
emit(SUCCESS)
code[skip] = _len(code) - skip
elif op is AT:
emit(op)
if flags & SRE_FLAG_MULTILINE:

View file

@ -13,7 +13,7 @@
# update when constants are added or removed
MAGIC = 20220402
MAGIC = 20220423
from _sre import MAXREPEAT, MAXGROUPS
@ -78,7 +78,6 @@ def _makecodes(*names):
'ASSERT', 'ASSERT_NOT',
'AT',
'BRANCH',
'CALL',
'CATEGORY',
'CHARSET', 'BIGCHARSET',
'GROUPREF', 'GROUPREF_EXISTS',

View file

@ -183,10 +183,6 @@ def getwidth(self):
j = max(j, h)
lo = lo + i
hi = hi + j
elif op is CALL:
i, j = av.getwidth()
lo = lo + i
hi = hi + j
elif op is ATOMIC_GROUP:
i, j = av.getwidth()
lo = lo + i

View file

@ -11,7 +11,7 @@
* See the sre.c file for information on usage and redistribution.
*/
#define SRE_MAGIC 20220402
#define SRE_MAGIC 20220423
#define SRE_OP_FAILURE 0
#define SRE_OP_SUCCESS 1
#define SRE_OP_ANY 2
@ -20,42 +20,41 @@
#define SRE_OP_ASSERT_NOT 5
#define SRE_OP_AT 6
#define SRE_OP_BRANCH 7
#define SRE_OP_CALL 8
#define SRE_OP_CATEGORY 9
#define SRE_OP_CHARSET 10
#define SRE_OP_BIGCHARSET 11
#define SRE_OP_GROUPREF 12
#define SRE_OP_GROUPREF_EXISTS 13
#define SRE_OP_IN 14
#define SRE_OP_INFO 15
#define SRE_OP_JUMP 16
#define SRE_OP_LITERAL 17
#define SRE_OP_MARK 18
#define SRE_OP_MAX_UNTIL 19
#define SRE_OP_MIN_UNTIL 20
#define SRE_OP_NOT_LITERAL 21
#define SRE_OP_NEGATE 22
#define SRE_OP_RANGE 23
#define SRE_OP_REPEAT 24
#define SRE_OP_REPEAT_ONE 25
#define SRE_OP_SUBPATTERN 26
#define SRE_OP_MIN_REPEAT_ONE 27
#define SRE_OP_ATOMIC_GROUP 28
#define SRE_OP_POSSESSIVE_REPEAT 29
#define SRE_OP_POSSESSIVE_REPEAT_ONE 30
#define SRE_OP_GROUPREF_IGNORE 31
#define SRE_OP_IN_IGNORE 32
#define SRE_OP_LITERAL_IGNORE 33
#define SRE_OP_NOT_LITERAL_IGNORE 34
#define SRE_OP_GROUPREF_LOC_IGNORE 35
#define SRE_OP_IN_LOC_IGNORE 36
#define SRE_OP_LITERAL_LOC_IGNORE 37
#define SRE_OP_NOT_LITERAL_LOC_IGNORE 38
#define SRE_OP_GROUPREF_UNI_IGNORE 39
#define SRE_OP_IN_UNI_IGNORE 40
#define SRE_OP_LITERAL_UNI_IGNORE 41
#define SRE_OP_NOT_LITERAL_UNI_IGNORE 42
#define SRE_OP_RANGE_UNI_IGNORE 43
#define SRE_OP_CATEGORY 8
#define SRE_OP_CHARSET 9
#define SRE_OP_BIGCHARSET 10
#define SRE_OP_GROUPREF 11
#define SRE_OP_GROUPREF_EXISTS 12
#define SRE_OP_IN 13
#define SRE_OP_INFO 14
#define SRE_OP_JUMP 15
#define SRE_OP_LITERAL 16
#define SRE_OP_MARK 17
#define SRE_OP_MAX_UNTIL 18
#define SRE_OP_MIN_UNTIL 19
#define SRE_OP_NOT_LITERAL 20
#define SRE_OP_NEGATE 21
#define SRE_OP_RANGE 22
#define SRE_OP_REPEAT 23
#define SRE_OP_REPEAT_ONE 24
#define SRE_OP_SUBPATTERN 25
#define SRE_OP_MIN_REPEAT_ONE 26
#define SRE_OP_ATOMIC_GROUP 27
#define SRE_OP_POSSESSIVE_REPEAT 28
#define SRE_OP_POSSESSIVE_REPEAT_ONE 29
#define SRE_OP_GROUPREF_IGNORE 30
#define SRE_OP_IN_IGNORE 31
#define SRE_OP_LITERAL_IGNORE 32
#define SRE_OP_NOT_LITERAL_IGNORE 33
#define SRE_OP_GROUPREF_LOC_IGNORE 34
#define SRE_OP_IN_LOC_IGNORE 35
#define SRE_OP_LITERAL_LOC_IGNORE 36
#define SRE_OP_NOT_LITERAL_LOC_IGNORE 37
#define SRE_OP_GROUPREF_UNI_IGNORE 38
#define SRE_OP_IN_UNI_IGNORE 39
#define SRE_OP_LITERAL_UNI_IGNORE 40
#define SRE_OP_NOT_LITERAL_UNI_IGNORE 41
#define SRE_OP_RANGE_UNI_IGNORE 42
#define SRE_AT_BEGINNING 0
#define SRE_AT_BEGINNING_LINE 1
#define SRE_AT_BEGINNING_STRING 2

View file

@ -1547,7 +1547,6 @@ SRE(match)(SRE_STATE* state, const SRE_CODE* pattern, int toplevel)
TARGET(SRE_OP_NEGATE):
TARGET(SRE_OP_BIGCHARSET):
TARGET(SRE_OP_CHARSET):
TARGET(SRE_OP_CALL):
TRACE(("|%p|%p|UNKNOWN %d\n", pattern, ptr,
pattern[-1]));
RETURN_ERROR(SRE_ERROR_ILLEGAL);

View file

@ -11,7 +11,7 @@
* See the sre.c file for information on usage and redistribution.
*/
static void *sre_targets[44] = {
static void *sre_targets[43] = {
&&TARGET_SRE_OP_FAILURE,
&&TARGET_SRE_OP_SUCCESS,
&&TARGET_SRE_OP_ANY,
@ -20,7 +20,6 @@ static void *sre_targets[44] = {
&&TARGET_SRE_OP_ASSERT_NOT,
&&TARGET_SRE_OP_AT,
&&TARGET_SRE_OP_BRANCH,
&&TARGET_SRE_OP_CALL,
&&TARGET_SRE_OP_CATEGORY,
&&TARGET_SRE_OP_CHARSET,
&&TARGET_SRE_OP_BIGCHARSET,