Rework x86-32 stack layout
[sljit.git] / regex_src / regexJIT.h
blob95c55ff05b483a448763b5bf3d7c5b90715aa70b
1 /*
2 * Stack-less Just-In-Time compiler
4 * Copyright Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
6 * Redistribution and use in source and binary forms, with or without modification, are
7 * permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright notice, this list of
10 * conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
13 * of conditions and the following disclaimer in the documentation and/or other materials
14 * provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #ifndef _REGEX_JIT_H_
28 #define _REGEX_JIT_H_
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
34 /* Character type config. */
35 #define REGEX_USE_8BIT_CHARS
37 #ifdef REGEX_USE_8BIT_CHARS
38 typedef char regex_char_t;
39 #else
40 typedef wchar_t regex_char_t;
41 #endif
43 /* Error codes. */
44 #define REGEX_NO_ERROR 0
45 #define REGEX_MEMORY_ERROR 1
46 #define REGEX_INVALID_REGEX 2
48 /* Note: large, nested {a,b} iterations can blow up the memory consumption
49 a{n,m} is replaced by aa...aaa?a?a?a?a? (n >= 0, m > 0)
50 \__n__/\____m___/
51 a{n,} is replaced by aa...aaa+ (n > 0)
52 \_n-1_/
55 /* The value returned by regex_compile. Can be used for multiple matching. */
56 struct regex_machine;
58 /* A matching state. */
59 struct regex_match;
61 /* Note: REGEX_MATCH_BEGIN and REGEX_MATCH_END does not change the parsing
62 (Hence ^ and $ are parsed normally).
63 Force matching to start from begining of the string (same as ^). */
64 #define REGEX_MATCH_BEGIN 0x01
65 /* Force matching to continue until the last character (same as $). */
66 #define REGEX_MATCH_END 0x02
67 /* Changes . to [^\r\n]
68 Note: [...] and [^...] are NOT affected at all (as other regex engines do). */
69 #define REGEX_NEWLINE 0x04
70 /* Non greedy matching. In case of Thompson (non-recursive) algorithm,
71 it (usually) does not have a significant speed gain. */
72 #define REGEX_MATCH_NON_GREEDY 0x08
73 /* Verbose. This define can be commented out, which disables all verbose features. */
74 #define REGEX_MATCH_VERBOSE 0x10
76 /* If error occures the function returns NULL, and the error code returned in error variable.
77 You can pass NULL to error if you don't care about the error code.
78 The re_flags argument contains the default REGEX_MATCH flags. See above. */
79 struct regex_machine* regex_compile(const regex_char_t *regex_string, int length, int re_flags, int *error);
80 void regex_free_machine(struct regex_machine *machine);
82 /* Create and init match structure for a given machine. */
83 struct regex_match* regex_begin_match(struct regex_machine *machine);
84 void regex_reset_match(struct regex_match *match);
85 void regex_free_match(struct regex_match *match);
87 /* Pattern matching.
88 regex_continue_match does not support REGEX_MATCH_VERBOSE flag. */
89 void regex_continue_match(struct regex_match *match, const regex_char_t *input_string, int length);
90 int regex_get_result(struct regex_match *match, int *end, int *id);
91 /* Returns true, if the best match has already found. */
92 int regex_is_match_finished(struct regex_match *match);
94 /* Only exists if VERBOSE is defined in regexJIT.c
95 Do both sanity check and verbose.
96 (The latter only if REGEX_MATCH_VERBOSE was passed to regex_compile) */
97 void regex_continue_match_debug(struct regex_match *match, const regex_char_t *input_string, int length);
99 /* Misc. */
100 const char* regex_get_platform_name(void);
102 #ifdef __cplusplus
103 } /* extern "C" */
104 #endif
106 #endif