| 
									
										
										
										
											2006-07-17 06:21:39 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2007-03-06 14:16:53 +00:00
										 |  |  |  * $Id: rex.h,v 1.28 2007-03-06 14:16:52 bacon Exp $ | 
					
						
							| 
									
										
										
										
											2007-02-03 10:47:41 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * {License} | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2006-07-17 06:21:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:10:12 +00:00
										 |  |  | #ifndef _ASE_AWK_REX_H_
 | 
					
						
							|  |  |  | #define _ASE_AWK_REX_H_
 | 
					
						
							| 
									
										
										
										
											2006-07-17 06:21:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-06 14:16:53 +00:00
										 |  |  | #ifndef _ASE_AWK_AWK_H_
 | 
					
						
							|  |  |  | #error Never include this file directly. Include <ase/awk/awk.h> instead
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2006-07-17 06:21:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-07-19 15:58:01 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2006-10-22 11:34:53 +00:00
										 |  |  |  * Regular Esseression Syntax | 
					
						
							| 
									
										
										
										
											2006-10-22 12:39:30 +00:00
										 |  |  |  *   A regular expression is zero or more branches, separated by '|'. | 
					
						
							| 
									
										
										
										
											2006-07-19 15:58:01 +00:00
										 |  |  |  *   ...... | 
					
						
							|  |  |  |  *   ...... | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2006-10-22 12:39:30 +00:00
										 |  |  |  * Compiled form of a regular expression: | 
					
						
							| 
									
										
										
										
											2006-07-19 15:58:01 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2006-10-22 12:39:30 +00:00
										 |  |  |  *   | expression                                                                      | | 
					
						
							| 
									
										
										
										
											2006-07-20 16:21:54 +00:00
										 |  |  |  *   | header  | branch                          | branch              | branch        | | 
					
						
							|  |  |  |  *   | nb | el | na | bl | cmd | arg | cmd | arg | na | bl | cmd | arg | na | bl | cmd | | 
					
						
							| 
									
										
										
										
											2006-07-19 15:58:01 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  *   nb: the number of branches | 
					
						
							| 
									
										
										
										
											2006-10-22 12:39:30 +00:00
										 |  |  |  *   el: the length of a expression including the length of nb and el | 
					
						
							| 
									
										
										
										
											2006-07-20 16:21:54 +00:00
										 |  |  |  *   na: the number of atoms | 
					
						
							| 
									
										
										
										
											2006-07-26 16:43:35 +00:00
										 |  |  |  *   bl: the length of a branch including the length of na and bl | 
					
						
							| 
									
										
										
										
											2006-07-19 15:58:01 +00:00
										 |  |  |  *   cmd: The command and repetition info encoded together.  | 
					
						
							|  |  |  |  *      Some commands require an argument to follow them but some other don't. | 
					
						
							|  |  |  |  *      It is encoded as follows: | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2006-10-22 12:39:30 +00:00
										 |  |  |  *   Subexpressions can be nested by having the command "GROUP"  | 
					
						
							|  |  |  |  *   and a subexpression as its argument. | 
					
						
							| 
									
										
										
										
											2006-07-19 15:58:01 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Examples: | 
					
						
							|  |  |  |  *   a.c -> |1|6|5|ORD_CHAR(no bound)|a|ANY_CHAR(no bound)|ORD_CHAR(no bound)|c| | 
					
						
							|  |  |  |  *   ab|xy -> |2|10|4|ORD_CHAR(no bound)|a|ORD_CHAR(no bound)|b|4|ORD_CHAR(no bound)|x|ORD_CHAR(no bound)|y| | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:10:12 +00:00
										 |  |  | #define ASE_AWK_REX_NA(code) (*(ase_size_t*)(code))
 | 
					
						
							| 
									
										
										
										
											2006-07-26 05:19:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:10:12 +00:00
										 |  |  | #define ASE_AWK_REX_LEN(code) \
 | 
					
						
							| 
									
										
										
										
											2006-11-29 02:54:17 +00:00
										 |  |  | 	(*(ase_size_t*)((ase_byte_t*)(code)+ASE_SIZEOF(ase_size_t))) | 
					
						
							| 
									
										
										
										
											2006-07-26 05:19:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-11-19 11:55:17 +00:00
										 |  |  | enum ase_awk_rex_opt_t | 
					
						
							| 
									
										
										
										
											2006-09-10 15:50:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2006-10-24 04:10:12 +00:00
										 |  |  | 	ASE_AWK_REX_IGNORECASE = (1 << 0) | 
					
						
							| 
									
										
										
										
											2006-09-10 15:50:34 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-07-17 06:21:39 +00:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:10:12 +00:00
										 |  |  | void* ase_awk_buildrex ( | 
					
						
							|  |  |  | 	ase_awk_t* awk, const ase_char_t* ptn,  | 
					
						
							|  |  |  | 	ase_size_t len, int* errnum); | 
					
						
							| 
									
										
										
										
											2006-07-24 11:58:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:10:12 +00:00
										 |  |  | int ase_awk_matchrex ( | 
					
						
							|  |  |  | 	ase_awk_t* awk, void* code, int option, | 
					
						
							|  |  |  | 	const ase_char_t* str, ase_size_t len,  | 
					
						
							|  |  |  | 	const ase_char_t** match_ptr, ase_size_t* match_len, int* errnum); | 
					
						
							| 
									
										
										
										
											2006-07-24 11:58:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:10:12 +00:00
										 |  |  | void ase_awk_freerex (ase_awk_t* awk, void* code); | 
					
						
							| 
									
										
										
										
											2006-08-16 11:35:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:10:12 +00:00
										 |  |  | ase_bool_t ase_awk_isemptyrex (ase_awk_t* awk, void* code); | 
					
						
							| 
									
										
										
										
											2006-08-30 07:15:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-02-28 11:04:16 +00:00
										 |  |  | void ase_awk_dprintrex (ase_awk_t* awk, void* rex); | 
					
						
							| 
									
										
										
										
											2006-07-24 16:23:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-07-17 06:21:39 +00:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 |