Mercurial > hg > Members > masakoha > testcode
annotate c/regexParser/transition.h @ 141:71f36a59cf6a pairPro
add appendState
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 11 Dec 2015 13:12:42 +0900 |
parents | 84a2a5209d3a |
children | d8a4922eceae |
rev | line source |
---|---|
116
66c633575b53
remove error and warning
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
1 #include "bitVector.h" |
66c633575b53
remove error and warning
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
2 |
110 | 3 typedef struct transition { |
4 CharClassPtr condition; | |
5 BitVectorPtr nextState; | |
6 struct transition *next; | |
116
66c633575b53
remove error and warning
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
7 } Transition, *TransitionPtr; |
110 | 8 |
9 typedef struct state { | |
141
71f36a59cf6a
add appendState
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
140
diff
changeset
|
10 BitVectorPtr bitState; |
110 | 11 TransitionPtr transition; |
12 struct state *next; | |
116
66c633575b53
remove error and warning
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
112
diff
changeset
|
13 } State, *StatePtr; |
140
84a2a5209d3a
change some variable name
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
14 |
141
71f36a59cf6a
add appendState
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
140
diff
changeset
|
15 StatePtr createState(BitVectorPtr bi, TransitionPtr ts, StatePtr next); |
71f36a59cf6a
add appendState
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
140
diff
changeset
|
16 StatePtr appendState(StatePtr x, StatePtr y); |
140
84a2a5209d3a
change some variable name
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
17 TransitionPtr createTransition(CharClassPtr cc ,BitVectorPtr state); |
84a2a5209d3a
change some variable name
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
18 TransitionPtr appendTransition0(TransitionPtr curr,TransitionPtr next); |
84a2a5209d3a
change some variable name
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
19 TransitionPtr appendTransition(TransitionPtr curr,TransitionPtr next); |
84a2a5209d3a
change some variable name
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
20 |
110 | 21 /* |
22 正規表現木を辿って transition のList をつくる | |
112
ec485345daf9
some function use static
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
110
diff
changeset
|
23 CharClass のかさなりを判定して重なりのない新しいCharClassをつくる |
110 | 24 重なっている状態はbitvectorのorをとる |
25 重なっている状態はそれぞれの状態について木をたどる | |
112
ec485345daf9
some function use static
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
110
diff
changeset
|
26 |
110 | 27 nextState == 0 は正規表現の末端を表す |
28 nextState == 1 は受理状態を表す | |
29 正規表現のノードの番号 n に対応する 2^n のbitをセットした状態 | |
112
ec485345daf9
some function use static
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
110
diff
changeset
|
30 |
110 | 31 | の場合は両方のListを結合する |
32 + の場合は左のノードに * がある場合は右のリストも結合する | |
112
ec485345daf9
some function use static
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
110
diff
changeset
|
33 左のノードに*がない場合は、右のほうだけみる |
110 | 34 * は直下のリストを使って、次の状態を自分自身にする |
35 */ |