blob: 3664c9d295926a1cf6a1378edce79638bb763e62 [file] [log] [blame]
Guido van Rossumb700df92000-03-31 14:59:30 +00001/*
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 Rossumb700df92000-03-31 14:59:30 +000017typedef struct {
18 PyObject_HEAD
19 PyObject* code; /* link to the code string object */
Guido van Rossumb700df92000-03-31 14:59:30 +000020 int groups;
21 PyObject* groupindex;
Jeremy Hyltonb1aa1952000-06-01 17:39:12 +000022 /* compatibility */
23 PyObject* pattern; /* pattern source (or None) */
24 int flags; /* flags used when compiling pattern source */
Guido van Rossumb700df92000-03-31 14:59:30 +000025} PatternObject;
26
Jeremy Hyltonb1aa1952000-06-01 17:39:12 +000027#define PatternObject_GetCode(o)\
28 ((void*) PyString_AS_STRING(((PatternObject*)(o))->code))
Guido van Rossumb700df92000-03-31 14:59:30 +000029
30typedef 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 Hyltonb1aa1952000-06-01 17:39:12 +000038typedef 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 Rossumb700df92000-03-31 14:59:30 +000054
Jeremy Hyltonb1aa1952000-06-01 17:39:12 +000055typedef struct {
56 PyObject_HEAD
57 PyObject* pattern;
58 PyObject* string;
59 SRE_STATE state;
60} CursorObject;
61
62#endif