2 * Secret Labs' Regular Expression Engine
4 * regular expression matching engine
6 * Copyright (c) 1997-2001 by Secret Labs AB. All rights reserved.
8 * See the _sre.c file for information on usage and redistribution.
14 #include "sre_constants.h"
16 /* size of a code word (must be unsigned short or larger, and
17 large enough to hold a Py_UNICODE character) */
18 #ifdef Py_UNICODE_WIDE
19 #define SRE_CODE unsigned long
21 #define SRE_CODE unsigned short
24 #define SRE_CODE unsigned short
28 int groups
; /* must be first! */
32 PyObject
* pattern
; /* pattern source (or None) */
33 int flags
; /* flags used when compiling pattern source */
39 #define PatternObject_GetCode(o) (((PatternObject*)(o))->code)
43 PyObject
* string
; /* link to the target string (must be first) */
44 PyObject
* regs
; /* cached list of matching spans */
45 PatternObject
* pattern
; /* link to the regex (pattern) object */
46 int pos
, endpos
; /* current target slice */
47 int lastindex
; /* last index marker seen by the engine (-1 if none) */
48 int groups
; /* number of groups (start/end marks) */
52 typedef unsigned int (*SRE_TOLOWER_HOOK
)(unsigned int ch
);
54 /* FIXME: <fl> shouldn't be a constant, really... */
55 #define SRE_MARK_SIZE 200
57 typedef struct SRE_REPEAT_T
{
59 SRE_CODE
* pattern
; /* points to REPEAT operator arguments */
60 struct SRE_REPEAT_T
*prev
; /* points to previous repeat context */
65 void* ptr
; /* current position (also end of current slice) */
66 void* beginning
; /* start of original string */
67 void* start
; /* start of current slice */
68 void* end
; /* end of original string */
69 /* attributes for the match object */
77 void* mark
[SRE_MARK_SIZE
];
78 /* dynamically allocated stuff */
82 SRE_REPEAT
*repeat
; /* current repeat context */
84 SRE_TOLOWER_HOOK lower
;