| 
									
										
										
										
											2000-03-31 14:59:30 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Secret Labs' Regular Expression Engine | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2000-06-29 18:03:25 +00:00
										 |  |  |  * regular expression matching engine | 
					
						
							| 
									
										
										
										
											2000-03-31 14:59:30 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2001-07-02 16:42:49 +00:00
										 |  |  |  * Copyright (c) 1997-2001 by Secret Labs AB.  All rights reserved. | 
					
						
							| 
									
										
										
										
											2000-03-31 14:59:30 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * See the _sre.c file for information on usage and redistribution. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef SRE_INCLUDED
 | 
					
						
							|  |  |  | #define SRE_INCLUDED
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "sre_constants.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-06-27 18:59:43 +00:00
										 |  |  | /* size of a code word (must be unsigned short or larger, and
 | 
					
						
							|  |  |  |    large enough to hold a Py_UNICODE character) */ | 
					
						
							|  |  |  | #ifdef Py_UNICODE_WIDE
 | 
					
						
							| 
									
										
										
										
											2004-05-07 07:18:13 +00:00
										 |  |  | #define SRE_CODE Py_UCS4
 | 
					
						
							| 
									
										
										
										
											2001-06-26 17:17:07 +00:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2000-06-29 08:55:54 +00:00
										 |  |  | #define SRE_CODE unsigned short
 | 
					
						
							| 
									
										
										
										
											2001-06-26 17:17:07 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2000-06-29 08:55:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-03-31 14:59:30 +00:00
										 |  |  | typedef struct { | 
					
						
							| 
									
										
										
										
											2000-07-03 18:44:21 +00:00
										 |  |  |     PyObject_VAR_HEAD | 
					
						
							| 
									
										
										
										
											2001-07-02 16:42:49 +00:00
										 |  |  |     int groups; /* must be first! */ | 
					
						
							| 
									
										
										
										
											2000-03-31 14:59:30 +00:00
										 |  |  |     PyObject* groupindex; | 
					
						
							| 
									
										
										
										
											2000-07-02 22:25:39 +00:00
										 |  |  |     PyObject* indexgroup; | 
					
						
							| 
									
										
										
										
											2000-06-01 17:39:12 +00:00
										 |  |  |     /* compatibility */ | 
					
						
							|  |  |  |     PyObject* pattern; /* pattern source (or None) */ | 
					
						
							|  |  |  |     int flags; /* flags used when compiling pattern source */ | 
					
						
							| 
									
										
										
										
											2004-05-31 03:09:25 +00:00
										 |  |  |     PyObject *weakreflist; /* List of weak references */ | 
					
						
							| 
									
										
										
										
											2000-07-03 18:44:21 +00:00
										 |  |  |     /* pattern code */ | 
					
						
							| 
									
										
										
										
											2001-07-02 16:42:49 +00:00
										 |  |  |     int codesize; | 
					
						
							| 
									
										
										
										
											2000-07-03 18:44:21 +00:00
										 |  |  |     SRE_CODE code[1]; | 
					
						
							| 
									
										
										
										
											2000-03-31 14:59:30 +00:00
										 |  |  | } PatternObject; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-07-03 18:44:21 +00:00
										 |  |  | #define PatternObject_GetCode(o) (((PatternObject*)(o))->code)
 | 
					
						
							| 
									
										
										
										
											2000-03-31 14:59:30 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							| 
									
										
										
										
											2000-07-03 18:44:21 +00:00
										 |  |  |     PyObject_VAR_HEAD | 
					
						
							| 
									
										
										
										
											2001-07-02 16:42:49 +00:00
										 |  |  |     PyObject* string; /* link to the target string (must be first) */ | 
					
						
							| 
									
										
										
										
											2000-07-23 21:46:17 +00:00
										 |  |  |     PyObject* regs; /* cached list of matching spans */ | 
					
						
							| 
									
										
										
										
											2000-03-31 14:59:30 +00:00
										 |  |  |     PatternObject* pattern; /* link to the regex (pattern) object */ | 
					
						
							| 
									
										
										
										
											2000-07-03 18:44:21 +00:00
										 |  |  |     int pos, endpos; /* current target slice */ | 
					
						
							|  |  |  |     int lastindex; /* last index marker seen by the engine (-1 if none) */ | 
					
						
							| 
									
										
										
										
											2000-03-31 14:59:30 +00:00
										 |  |  |     int groups; /* number of groups (start/end marks) */ | 
					
						
							| 
									
										
										
										
											2000-07-03 18:44:21 +00:00
										 |  |  |     int mark[1]; | 
					
						
							| 
									
										
										
										
											2000-03-31 14:59:30 +00:00
										 |  |  | } MatchObject; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-06-29 08:55:54 +00:00
										 |  |  | typedef unsigned int (*SRE_TOLOWER_HOOK)(unsigned int ch); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-06-29 16:57:40 +00:00
										 |  |  | /* FIXME: <fl> shouldn't be a constant, really... */ | 
					
						
							|  |  |  | #define SRE_MARK_SIZE 200
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-01 18:20:07 +00:00
										 |  |  | typedef struct SRE_REPEAT_T { | 
					
						
							|  |  |  |     int count; | 
					
						
							|  |  |  |     SRE_CODE* pattern; /* points to REPEAT operator arguments */ | 
					
						
							| 
									
										
										
										
											2003-10-17 22:13:16 +00:00
										 |  |  |     void* last_ptr; /* helper to check for infinite loops */ | 
					
						
							| 
									
										
										
										
											2000-08-01 18:20:07 +00:00
										 |  |  |     struct SRE_REPEAT_T *prev; /* points to previous repeat context */ | 
					
						
							|  |  |  | } SRE_REPEAT; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-06-01 17:39:12 +00:00
										 |  |  | typedef struct { | 
					
						
							|  |  |  |     /* string pointers */ | 
					
						
							|  |  |  |     void* ptr; /* current position (also end of current slice) */ | 
					
						
							|  |  |  |     void* beginning; /* start of original string */ | 
					
						
							|  |  |  |     void* start; /* start of current slice */ | 
					
						
							|  |  |  |     void* end; /* end of original string */ | 
					
						
							| 
									
										
										
										
											2000-07-23 21:46:17 +00:00
										 |  |  |     /* attributes for the match object */ | 
					
						
							|  |  |  |     PyObject* string; | 
					
						
							|  |  |  |     int pos, endpos; | 
					
						
							| 
									
										
										
										
											2000-06-01 17:39:12 +00:00
										 |  |  |     /* character size */ | 
					
						
							|  |  |  |     int charsize; | 
					
						
							|  |  |  |     /* registers */ | 
					
						
							| 
									
										
										
										
											2000-07-03 18:44:21 +00:00
										 |  |  |     int lastindex; | 
					
						
							| 
									
										
										
										
											2000-06-29 08:55:54 +00:00
										 |  |  |     int lastmark; | 
					
						
							| 
									
										
										
										
											2000-06-29 16:57:40 +00:00
										 |  |  |     void* mark[SRE_MARK_SIZE]; | 
					
						
							| 
									
										
										
										
											2000-08-01 18:20:07 +00:00
										 |  |  |     /* dynamically allocated stuff */ | 
					
						
							| 
									
										
										
										
											2003-10-17 22:13:16 +00:00
										 |  |  |     char* data_stack; | 
					
						
							| 
									
										
										
										
											2004-02-14 00:31:13 +00:00
										 |  |  |     unsigned int data_stack_size; | 
					
						
							|  |  |  |     unsigned int data_stack_base; | 
					
						
							| 
									
										
										
										
											2003-10-17 22:13:16 +00:00
										 |  |  |     /* current repeat context */ | 
					
						
							|  |  |  |     SRE_REPEAT *repeat; | 
					
						
							| 
									
										
										
										
											2000-06-29 08:55:54 +00:00
										 |  |  |     /* hooks */ | 
					
						
							| 
									
										
										
										
											2000-06-29 12:48:37 +00:00
										 |  |  |     SRE_TOLOWER_HOOK lower; | 
					
						
							| 
									
										
										
										
											2000-06-01 17:39:12 +00:00
										 |  |  | } SRE_STATE; | 
					
						
							| 
									
										
										
										
											2000-03-31 14:59:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-06-01 17:39:12 +00:00
										 |  |  | typedef struct { | 
					
						
							|  |  |  |     PyObject_HEAD | 
					
						
							|  |  |  |     PyObject* pattern; | 
					
						
							|  |  |  |     SRE_STATE state; | 
					
						
							| 
									
										
										
										
											2000-06-29 16:57:40 +00:00
										 |  |  | } ScannerObject; | 
					
						
							| 
									
										
										
										
											2000-06-01 17:39:12 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif
 |