Last change
on this file was
5901,
checked in by westram, 16 years ago
|
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
File size:
949 bytes
|
Line | |
---|
1 | #include <stdio.h> |
---|
2 | #include <memory.h> |
---|
3 | #include "awt_automata.hxx" |
---|
4 | |
---|
5 | AWT_automata::AWT_automata(bool free_value){ |
---|
6 | memset((char *)this,0,sizefof(*this)); |
---|
7 | value_is_malloced = free_value; |
---|
8 | } |
---|
9 | |
---|
10 | // set gaps[gap] = 1 gaps[nogap] = 0 |
---|
11 | void AWT_automata::set_gaps(char *ga) { |
---|
12 | memset(gaps,0,256); |
---|
13 | while (*ga) gaps[*(ga++)] = 1; |
---|
14 | } |
---|
15 | |
---|
16 | void AWT_automata::get_fwd(char *str,int pos) { |
---|
17 | AWT_auto_states *state = this; |
---|
18 | AW_CL last_value = 0; |
---|
19 | unsigned char *p = (unsigned char *)str + pos; |
---|
20 | int b; |
---|
21 | |
---|
22 | for ( ; b=*p;p++) { |
---|
23 | if (gaps[b]) continue; // do not read gaps |
---|
24 | if (state->value) last_value = state->value; |
---|
25 | if (!state->children) return last_value; // that's it |
---|
26 | state = state->children[b]; // can we go deeper |
---|
27 | if (!state) return last_value; |
---|
28 | } |
---|
29 | return last_value; |
---|
30 | } |
---|
31 | |
---|
32 | char *AWT_automata::insert(char *str, AW_CL value){ |
---|
33 | |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | |
---|
38 | |
---|
39 | |
---|
40 | |
---|
41 | }; |
---|
Note: See
TracBrowser
for help on using the repository browser.