Guido van Rossum | b700df9 | 2000-03-31 14:59:30 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Secret Labs' Regular Expression Engine |
| 3 | * $Id$ |
| 4 | * |
| 5 | * simple regular expression matching engine |
| 6 | * |
| 7 | * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. |
| 8 | * |
| 9 | * See the _sre.c file for information on usage and redistribution. |
| 10 | */ |
| 11 | |
| 12 | #ifndef SRE_INCLUDED |
| 13 | #define SRE_INCLUDED |
| 14 | |
| 15 | #include "sre_constants.h" |
| 16 | |
Guido van Rossum | b700df9 | 2000-03-31 14:59:30 +0000 | [diff] [blame] | 17 | typedef struct { |
| 18 | PyObject_HEAD |
| 19 | PyObject* code; /* link to the code string object */ |
Guido van Rossum | b700df9 | 2000-03-31 14:59:30 +0000 | [diff] [blame] | 20 | int groups; |
| 21 | PyObject* groupindex; |
Jeremy Hylton | b1aa195 | 2000-06-01 17:39:12 +0000 | [diff] [blame^] | 22 | /* compatibility */ |
| 23 | PyObject* pattern; /* pattern source (or None) */ |
| 24 | int flags; /* flags used when compiling pattern source */ |
Guido van Rossum | b700df9 | 2000-03-31 14:59:30 +0000 | [diff] [blame] | 25 | } PatternObject; |
| 26 | |
Jeremy Hylton | b1aa195 | 2000-06-01 17:39:12 +0000 | [diff] [blame^] | 27 | #define PatternObject_GetCode(o)\ |
| 28 | ((void*) PyString_AS_STRING(((PatternObject*)(o))->code)) |
Guido van Rossum | b700df9 | 2000-03-31 14:59:30 +0000 | [diff] [blame] | 29 | |
| 30 | typedef struct { |
| 31 | PyObject_HEAD |
| 32 | PyObject* string; /* link to the target string */ |
| 33 | PatternObject* pattern; /* link to the regex (pattern) object */ |
| 34 | int groups; /* number of groups (start/end marks) */ |
| 35 | int mark[2]; |
| 36 | } MatchObject; |
| 37 | |
Jeremy Hylton | b1aa195 | 2000-06-01 17:39:12 +0000 | [diff] [blame^] | 38 | typedef struct { |
| 39 | /* string pointers */ |
| 40 | void* ptr; /* current position (also end of current slice) */ |
| 41 | void* beginning; /* start of original string */ |
| 42 | void* start; /* start of current slice */ |
| 43 | void* end; /* end of original string */ |
| 44 | /* character size */ |
| 45 | int charsize; |
| 46 | /* registers */ |
| 47 | int marks; |
| 48 | void* mark[64]; /* FIXME: <fl> should be dynamically allocated! */ |
| 49 | /* backtracking stack */ |
| 50 | void** stack; |
| 51 | int stacksize; |
| 52 | int stackbase; |
| 53 | } SRE_STATE; |
Guido van Rossum | b700df9 | 2000-03-31 14:59:30 +0000 | [diff] [blame] | 54 | |
Jeremy Hylton | b1aa195 | 2000-06-01 17:39:12 +0000 | [diff] [blame^] | 55 | typedef struct { |
| 56 | PyObject_HEAD |
| 57 | PyObject* pattern; |
| 58 | PyObject* string; |
| 59 | SRE_STATE state; |
| 60 | } CursorObject; |
| 61 | |
| 62 | #endif |