2002-10-22 00:09:32 +00:00
|
|
|
//
|
|
|
|
// Copyright (C) 2002 International Business Machines Corporation
|
|
|
|
// and others. All rights reserved.
|
|
|
|
//
|
|
|
|
// file: regeximp.h
|
|
|
|
//
|
2002-11-07 02:34:46 +00:00
|
|
|
// ICU Regular Expressions,
|
|
|
|
// Definitions of constant values used in the compiled form of
|
|
|
|
// a regular expression pattern.
|
2002-10-22 00:09:32 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef _REGEXIMP_H
|
|
|
|
#define _REGEXIMP_H
|
|
|
|
|
|
|
|
|
2002-11-19 19:31:03 +00:00
|
|
|
//
|
|
|
|
// debugging support. Enable one or more of the #defines immediately following
|
|
|
|
//
|
|
|
|
//#define REGEX_SCAN_DEBUG
|
2002-11-20 23:30:20 +00:00
|
|
|
//#define REGEX_DUMP_DEBUG
|
2002-11-19 19:31:03 +00:00
|
|
|
//#define REGEX_RUN_DEBUG
|
|
|
|
// End of #defines inteded to be directly set.
|
|
|
|
|
|
|
|
#ifdef REGEX_SCAN_DEBUG
|
|
|
|
#define REGEX_SCAN_DEBUG_PRINTF printf
|
|
|
|
#else
|
|
|
|
#define REGEX_SCAN_DEBUG_PRINTF
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef REGEX_DUMP_DEBUG
|
|
|
|
#define REGEX_DUMP_DEBUG_PRINTF printf
|
|
|
|
#else
|
|
|
|
#define REGEX_DUMP_DEBUG_PRINTF
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef REGEX_RUN_DEBUG
|
|
|
|
#define REGEX_RUN_DEBUG_PRINTF printf
|
|
|
|
#define REGEX_DUMP_DEBUG_PRINTF printf
|
|
|
|
#else
|
|
|
|
#define REGEX_RUN_DEBUG_PRINTF
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(REGEX_SCAN_DEBUG) || defined(REGEX_RUN_DEBUG) || defined(REGEX_DUMP_DEBUG)
|
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2002-10-22 00:09:32 +00:00
|
|
|
//
|
2002-11-11 18:49:49 +00:00
|
|
|
// Opcode types In the compiled form of the regexp, these are the type, or opcodes,
|
2002-10-22 00:09:32 +00:00
|
|
|
// of the entries.
|
|
|
|
//
|
2002-11-11 18:49:49 +00:00
|
|
|
enum {
|
2002-11-14 18:27:00 +00:00
|
|
|
URX_RESERVED_OP = 0,
|
2002-11-19 19:31:03 +00:00
|
|
|
URX_BACKTRACK = 1,
|
2002-11-11 18:49:49 +00:00
|
|
|
URX_END = 2,
|
|
|
|
URX_ONECHAR = 3, // Value field is the 21 bit unicode char to match
|
|
|
|
URX_STRING = 4, // Value field is index of string start
|
|
|
|
URX_STRING_LEN = 5, // Value field is string length (code units)
|
|
|
|
URX_STATE_SAVE = 6, // Value field is pattern position to push
|
|
|
|
URX_NOP = 7,
|
|
|
|
URX_START_CAPTURE = 8, // Value field is capture group number.
|
|
|
|
URX_END_CAPTURE = 9, // Value field is capture group number
|
|
|
|
URX_STATIC_SETREF = 10, // Value field is index of set in array of sets.
|
|
|
|
URX_SETREF = 11, // Value field is index of set in array of sets.
|
|
|
|
URX_DOTANY = 12,
|
|
|
|
URX_JMP = 13, // Value field is destination position in
|
2002-10-22 00:09:32 +00:00
|
|
|
// the pattern.
|
2002-11-11 18:49:49 +00:00
|
|
|
URX_FAIL = 14, // Stop match operation, No match.
|
2002-10-22 00:09:32 +00:00
|
|
|
|
2002-11-11 18:49:49 +00:00
|
|
|
URX_BACKSLASH_A = 15,
|
|
|
|
URX_BACKSLASH_B = 16, // Value field: 0: \b 1: \B
|
|
|
|
URX_BACKSLASH_G = 17,
|
|
|
|
URX_BACKSLASH_W = 18, // Value field: 0: \w 1: \W
|
|
|
|
URX_BACKSLASH_X = 19,
|
|
|
|
URX_BACKSLASH_Z = 20, // \z Unconditional end of line.
|
2002-10-28 17:18:44 +00:00
|
|
|
|
2002-11-11 18:49:49 +00:00
|
|
|
URX_DOTANY_ALL = 21, // ., in the . matches any mode.
|
|
|
|
URX_BACKSLASH_D = 22, // Value field: 0: \d 1: \D
|
|
|
|
URX_CARET = 23, // Value field: 1: multi-line mode.
|
|
|
|
URX_DOLLAR = 24 // Also for \Z
|
|
|
|
};
|
2002-10-31 01:58:01 +00:00
|
|
|
|
2002-11-14 18:27:00 +00:00
|
|
|
// Keep this list of opcode names in sync with the above enum
|
|
|
|
// Used for debug printing only.
|
|
|
|
#define URX_OPCODE_NAMES \
|
|
|
|
"URX_RESERVED_OP", \
|
2002-11-19 19:31:03 +00:00
|
|
|
"URX_BACKTRACK", \
|
2002-11-14 18:27:00 +00:00
|
|
|
"END", \
|
|
|
|
"ONECHAR", \
|
|
|
|
"STRING", \
|
|
|
|
"STRING_LEN", \
|
|
|
|
"STATE_SAVE", \
|
|
|
|
"NOP", \
|
|
|
|
"START_CAPTURE", \
|
|
|
|
"END_CAPTURE", \
|
|
|
|
"URX_STATIC_SETREF", \
|
|
|
|
"SETREF", \
|
|
|
|
"DOTANY", \
|
|
|
|
"JMP", \
|
|
|
|
"FAIL", \
|
|
|
|
"URX_BACKSLASH_A", \
|
|
|
|
"URX_BACKSLASH_B", \
|
|
|
|
"URX_BACKSLASH_G", \
|
|
|
|
"URX_BACKSLASH_W", \
|
|
|
|
"URX_BACKSLASH_X", \
|
|
|
|
"URX_BACKSLASH_Z", \
|
|
|
|
"URX_DOTANY_ALL", \
|
|
|
|
"URX_BACKSLASH_D", \
|
|
|
|
"URX_CARET", \
|
|
|
|
"URX_DOLLAR"
|
2002-10-28 17:18:44 +00:00
|
|
|
|
2002-10-22 00:09:32 +00:00
|
|
|
//
|
|
|
|
// Convenience macros for assembling and disassembling a compiled operation.
|
|
|
|
//
|
|
|
|
#define URX_BUILD(type, val) (int32_t)((type << 24) | (val))
|
|
|
|
#define URX_TYPE(x) ((x) >> 24)
|
|
|
|
#define URX_VAL(x) ((x) & 0xffffff)
|
|
|
|
|
|
|
|
|
2002-10-31 01:58:01 +00:00
|
|
|
//
|
2002-11-07 02:34:46 +00:00
|
|
|
// Access to Unicode Sets for Perl-like composite character properties
|
2002-10-31 01:58:01 +00:00
|
|
|
// The sets are accessed by the match engine for things like \w (word boundary)
|
|
|
|
//
|
2002-11-11 18:49:49 +00:00
|
|
|
enum {
|
|
|
|
URX_ISWORD_SET = 1,
|
|
|
|
URX_ISALNUM_SET = 2,
|
|
|
|
URX_ISALPHA_SET = 3,
|
|
|
|
URX_ISSPACE_SET = 4,
|
|
|
|
URX_LAST_SET = 5,
|
|
|
|
|
|
|
|
URX_NEG_SET = 0x800000 // Flag bit to reverse sense of set
|
|
|
|
// membership test.
|
|
|
|
};
|
2002-10-31 01:58:01 +00:00
|
|
|
|
2002-10-22 00:09:32 +00:00
|
|
|
#endif
|
|
|
|
|