Use full package paths in imports.
[python/dscho.git] / Modules / sre.h
bloba7fdfbab647f177b75681b44a4e1381cd58d853e
1 /*
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.
9 */
11 #ifndef SRE_INCLUDED
12 #define SRE_INCLUDED
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
20 #else
21 #define SRE_CODE unsigned short
22 #endif
24 typedef struct {
25 PyObject_VAR_HEAD
26 int groups; /* must be first! */
27 PyObject* groupindex;
28 PyObject* indexgroup;
29 /* compatibility */
30 PyObject* pattern; /* pattern source (or None) */
31 int flags; /* flags used when compiling pattern source */
32 /* pattern code */
33 int codesize;
34 SRE_CODE code[1];
35 } PatternObject;
37 #define PatternObject_GetCode(o) (((PatternObject*)(o))->code)
39 typedef struct {
40 PyObject_VAR_HEAD
41 PyObject* string; /* link to the target string (must be first) */
42 PyObject* regs; /* cached list of matching spans */
43 PatternObject* pattern; /* link to the regex (pattern) object */
44 int pos, endpos; /* current target slice */
45 int lastindex; /* last index marker seen by the engine (-1 if none) */
46 int groups; /* number of groups (start/end marks) */
47 int mark[1];
48 } MatchObject;
50 typedef unsigned int (*SRE_TOLOWER_HOOK)(unsigned int ch);
52 /* FIXME: <fl> shouldn't be a constant, really... */
53 #define SRE_MARK_SIZE 200
55 typedef struct SRE_REPEAT_T {
56 int count;
57 SRE_CODE* pattern; /* points to REPEAT operator arguments */
58 struct SRE_REPEAT_T *prev; /* points to previous repeat context */
59 } SRE_REPEAT;
61 typedef struct {
62 /* string pointers */
63 void* ptr; /* current position (also end of current slice) */
64 void* beginning; /* start of original string */
65 void* start; /* start of current slice */
66 void* end; /* end of original string */
67 /* attributes for the match object */
68 PyObject* string;
69 int pos, endpos;
70 /* character size */
71 int charsize;
72 /* registers */
73 int lastindex;
74 int lastmark;
75 void* mark[SRE_MARK_SIZE];
76 /* dynamically allocated stuff */
77 void** mark_stack;
78 int mark_stack_size;
79 int mark_stack_base;
80 SRE_REPEAT *repeat; /* current repeat context */
81 /* hooks */
82 SRE_TOLOWER_HOOK lower;
83 } SRE_STATE;
85 typedef struct {
86 PyObject_HEAD
87 PyObject* pattern;
88 SRE_STATE state;
89 } ScannerObject;
91 #endif