\hypertarget{namespacedc__regex}{}\section{dc\+\_\+regex Module Reference}
\label{namespacedc__regex}\index{dc\+\_\+regex@{dc\+\_\+regex}}


\subsection{Detailed Description}
Provide simple regular expression subroutine\+: \textquotesingle{}match\textquotesingle{}. 

\begin{DoxyAuthor}{Author}
Youhei S\+A\+S\+A\+KI 
\end{DoxyAuthor}
\begin{DoxyCopyright}{Copyright}
Copyright (C) G\+FD Dennou Club, 2000-\/2016. All rights reserved. ~\newline
 License is B\+S\+D-\/2-\/\+Clause. see \hyperlink{COPYRIGHT}{C\+O\+P\+Y\+R\+I\+G\+HT} in detail 
\end{DoxyCopyright}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine \hyperlink{namespacedc__regex_a966a504619d48c00c095386313b36925}{preprocess\+\_\+pattern} (pattern, symbols)
\item 
recursive subroutine \hyperlink{namespacedc__regex_a4d252079ab1de7bd10e41d183fb3437d}{match\+\_\+here} (ipat, text, length)
\item 
logical function \hyperlink{namespacedc__regex_af4a270fd2f81bfde51a7641df8f3e3cb}{hit} (ipat, c)
\item 
subroutine, public \hyperlink{namespacedc__regex_abc5c6d1c941d8689bdf6e32a6b919b25}{match} (pattern, text, start, length)
\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
character, save \hyperlink{namespacedc__regex_a9f728201dff37a22e0290d900545bd5b}{c\+\_\+escape} = \textquotesingle{}\#\textquotesingle{}
\item 
integer, parameter \hyperlink{namespacedc__regex_a508717681a93bc57201e855252a0dd27}{sym\+\_\+eol} = -\/128
\item 
integer, parameter \hyperlink{namespacedc__regex_acc818c3b7bec8403b471e682b81ec955}{sym\+\_\+anychar} = 500
\item 
integer, parameter \hyperlink{namespacedc__regex_afee684d930e4211cf5252ef637a8830f}{sym\+\_\+question} = 501
\item 
integer, parameter \hyperlink{namespacedc__regex_af19845943d8d719fbc449084b5497f42}{sym\+\_\+plus} = 502
\item 
integer, parameter \hyperlink{namespacedc__regex_a5d750c4b279af3262496dfeffb9dd402}{sym\+\_\+star} = 503
\item 
integer, parameter \hyperlink{namespacedc__regex_aef499ad4034d52eb6fb8d7dfacf380eb}{sym\+\_\+normal\+\_\+set} = 520
\item 
integer, parameter \hyperlink{namespacedc__regex_aa558b709db6a370df0b2d3c1b5d66262}{sym\+\_\+reversed\+\_\+set} = 521
\item 
integer, parameter \hyperlink{namespacedc__regex_ac23262e1d00bc98302c5cf8e24255cbc}{sym\+\_\+headfix} = 540
\item 
integer, parameter \hyperlink{namespacedc__regex_ad6e72d8f105295f427eab258e21bc9f0}{sym\+\_\+tailfix} = 541
\item 
integer, parameter \hyperlink{namespacedc__regex_af2ad6d1b5e4d9fac08e0a82b2bd3f323}{sym\+\_\+isdigit} = 560
\item 
integer, parameter \hyperlink{namespacedc__regex_a490609e3026fe6e9a50dbf6a40481142}{sym\+\_\+isalpha} = 561
\item 
integer, parameter \hyperlink{namespacedc__regex_a58db3ef8ab7f22ce5f2055040ce6a454}{sym\+\_\+isword} = 562
\item 
integer, parameter \hyperlink{namespacedc__regex_a06ba95caf7e7e96ca1d540b0e4ef16cc}{sym\+\_\+isspace} = 563
\item 
integer, parameter \hyperlink{namespacedc__regex_a13ef3092a5d1eaf8c39cd285648229b4}{sym\+\_\+isxdigit} = 564
\item 
integer, parameter \hyperlink{namespacedc__regex_a1cd3b3421091582d081ee8d09ded7391}{sym\+\_\+count\+\_\+base} = 1000
\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacedc__regex_af4a270fd2f81bfde51a7641df8f3e3cb}\label{namespacedc__regex_af4a270fd2f81bfde51a7641df8f3e3cb}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!hit@{hit}}
\index{hit@{hit}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{hit()}{hit()}}
{\footnotesize\ttfamily logical function dc\+\_\+regex\+::hit (\begin{DoxyParamCaption}\item[{integer, dimension(\+:), intent(in)}]{ipat,  }\item[{character(len=$\ast$), intent(in)}]{c }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 235 of file dc\+\_\+regex.\+f90.



References sym\+\_\+anychar, sym\+\_\+isalpha, sym\+\_\+isdigit, sym\+\_\+isspace, sym\+\_\+isword, and sym\+\_\+isxdigit.



Referenced by match\+\_\+here().


\begin{DoxyCode}
235     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}:: ipat(:)
236     \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)}:: c
237     \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{parameter}:: &
238       & DIGIT = \textcolor{stringliteral}{"0123456789"}, &
239       & XDIGIT = \textcolor{stringliteral}{"ABCDEFabcdef"}, &
240       & ALPHA = \textcolor{stringliteral}{"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"}
241     \textcolor{keywordtype}{integer}:: i
242     \textcolor{keywordflow}{continue}
243     \textcolor{keywordflow}{do}, i = 1, \textcolor{keyword}{size}(ipat)
244       \textcolor{keywordflow}{select case}(ipat(i))
245       \textcolor{keywordflow}{case}(sym\_anychar)
246         result = .true.
247       \textcolor{keywordflow}{case}(sym\_isalpha)
248         result = (index(alpha, c) > 0)
249       \textcolor{keywordflow}{case}(sym\_isdigit)
250         result = (index(digit, c) > 0)
251       \textcolor{keywordflow}{case}(sym\_isword)
252         result = (index(digit, c) > 0 .or. index(alpha, c) > 0 .or. &
253           & c == \textcolor{stringliteral}{'\_'})
254       \textcolor{keywordflow}{case}(sym\_isxdigit)
255         result = (index(digit, c) > 0 .or. index(xdigit, c) > 0)
256       \textcolor{keywordflow}{case}(sym\_isspace)
257         result = (c == \textcolor{stringliteral}{' '} .or. (iachar(c) >= 8 .and. iachar(c) <= 13))
258 \textcolor{keywordflow}{      case default}
259         result = (ipat(i) == ichar(c))
260 \textcolor{keywordflow}{      end select}
261       \textcolor{keywordflow}{if} (result) \textcolor{keywordflow}{return}
262 \textcolor{keywordflow}{    enddo}
263     result = .false.
\end{DoxyCode}
Here is the caller graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=550pt]{namespacedc__regex_af4a270fd2f81bfde51a7641df8f3e3cb_icgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{namespacedc__regex_abc5c6d1c941d8689bdf6e32a6b919b25}\label{namespacedc__regex_abc5c6d1c941d8689bdf6e32a6b919b25}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!match@{match}}
\index{match@{match}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{match()}{match()}}
{\footnotesize\ttfamily subroutine, public dc\+\_\+regex\+::match (\begin{DoxyParamCaption}\item[{character(len = $\ast$), intent(in)}]{pattern,  }\item[{character(len = $\ast$), intent(in)}]{text,  }\item[{integer, intent(out)}]{start,  }\item[{integer, intent(out)}]{length }\end{DoxyParamCaption})}



Definition at line 267 of file dc\+\_\+regex.\+f90.



References match\+\_\+here(), preprocess\+\_\+pattern(), and sym\+\_\+headfix.



Referenced by actual\+\_\+iorange\+\_\+dump(), dccaldatecreate1(), dccaldateparsestr1(), dcunits\+\_\+com\+::dcunitsgettoken(), historygetdouble0(), historygetdouble1(), historygetdouble2(), historygetdouble3(), historygetdouble4(), historygetdouble5(), historygetdouble6(), historygetdouble7(), historygetint0(), historygetint1(), historygetint2(), historygetint3(), historygetint4(), historygetint5(), historygetint6(), historygetint7(), historygetreal0(), historygetreal1(), historygetreal2(), historygetreal3(), historygetreal4(), historygetreal5(), historygetreal6(), historygetreal7(), and lookup\+\_\+growable\+\_\+url().


\begin{DoxyCode}
267     \textcolor{comment}{!}
268     \textcolor{comment}{! \_pattern\_ には正規表現を与えます。}
269     \textcolor{comment}{! \_text\_ には正規表現によって探査したい文字列を与えます。}
270     \textcolor{comment}{!}
271     \textcolor{comment}{! \_pattern\_ が \_text\_ にマッチした場合、}
272     \textcolor{comment}{! \_start\_ には文字列の何文字目からマッチしたのかを示す数値 (正の整数)}
273     \textcolor{comment}{! が返ります。}
274     \textcolor{comment}{! \_length\_ には何文字分マッチしたのかを示す数値 (正の整数)}
275     \textcolor{comment}{! が返ります。}
276     \textcolor{comment}{!}
277     \textcolor{comment}{! マッチしない場合、 length == -1, start == 0 となります。}
278     \textcolor{comment}{!}
279     \textcolor{comment}{!}
280     \textcolor{comment}{!=== 例}
281     \textcolor{comment}{!}
282     \textcolor{comment}{!      program regex\_test}
283     \textcolor{comment}{!        use dc\_regex, only: match}
284     \textcolor{comment}{!        use dc\_types, only: TOKEN}
285     \textcolor{comment}{!        implicit none}
286     \textcolor{comment}{!}
287     \textcolor{comment}{!        integer:: start, length}
288     \textcolor{comment}{!        character(TOKEN) :: pattern, text}
289     \textcolor{comment}{!      continue}
290     \textcolor{comment}{!        pattern = "->"}
291     \textcolor{comment}{!        text    = "time->0.0,x->hoge"}
292     \textcolor{comment}{!        call match(trim(pattern), trim(text), start, length)}
293     \textcolor{comment}{!        call formatted\_print}
294     \textcolor{comment}{!}
295     \textcolor{comment}{!        pattern = "^##+"}
296     \textcolor{comment}{!        text    = "####### hoge"}
297     \textcolor{comment}{!        call match(trim(pattern), trim(text), start, length)}
298     \textcolor{comment}{!        call formatted\_print}
299     \textcolor{comment}{!}
300     \textcolor{comment}{!        pattern = "@+$"}
301     \textcolor{comment}{!        text    = "# hoge @@@"}
302     \textcolor{comment}{!        call match(trim(pattern), trim(text), start, length)}
303     \textcolor{comment}{!        call formatted\_print}
304     \textcolor{comment}{!}
305     \textcolor{comment}{!      contains}
306     \textcolor{comment}{!        subroutine formatted\_print}
307     \textcolor{comment}{!          use dc\_string, only: Printf}
308     \textcolor{comment}{!          call Printf(fmt='pattern= %c : text= %c : start= %d : length= %d', &}
309     \textcolor{comment}{!            & c1=trim(pattern), c2=trim(text), i=(/start, length/))}
310     \textcolor{comment}{!        end subroutine formatted\_print}
311     \textcolor{comment}{!}
312     \textcolor{comment}{!      end program regex\_test}
313     \textcolor{comment}{!}
314     \textcolor{comment}{! このプログラムを実行することで以下の出力が得られるはずです。}
315     \textcolor{comment}{!}
316     \textcolor{comment}{!      pattern= -> : text= time->0.0,x->hoge : start= 5 : length= 2}
317     \textcolor{comment}{!      pattern= ^##+ : text= ####### hoge : start= 1 : length= 7}
318     \textcolor{comment}{!      pattern= @+$ : text= # hoge @@@ : start= 8 : length= 3}
319     \textcolor{comment}{!}
320     \textcolor{keywordtype}{implicit none}
321     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}:: pattern, text
322     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(out)}:: start, length
323     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{allocatable}:: ipattern(:)
324     \textcolor{keywordtype}{integer}:: text\_length
325     \textcolor{keywordflow}{continue}
326     \textcolor{comment}{! 空 pattern は空文字列に適合}
327     \textcolor{keywordflow}{if} (len(pattern) <= 0) \textcolor{keywordflow}{then}
328       length = 0
329       start = 1
330       \textcolor{keywordflow}{return}
331 \textcolor{keywordflow}{    endif}
332     \textcolor{comment}{! メタキャラクタの認識}
333     \textcolor{keyword}{allocate}(ipattern(len(pattern) + 2))
334     \textcolor{keyword}{call }preprocess\_pattern(pattern, ipattern)
335     \textcolor{comment}{! 頭寄せ指定のある場合}
336     \textcolor{keywordflow}{if} (ipattern(1) == sym\_headfix) \textcolor{keywordflow}{then}
337       start = 1
338       \textcolor{keyword}{call }match\_here(ipattern(2: ), text, length)
339       \textcolor{keywordflow}{if} (length < 0) \textcolor{keywordflow}{goto} 995
340       \textcolor{keywordflow}{goto} 999
341 \textcolor{keywordflow}{    endif}
342     \textcolor{comment}{! 最左原理}
343     text\_length = len(text)
344     \textcolor{keywordflow}{do}, start = 1, text\_length + 1
345       \textcolor{keyword}{call }match\_here(ipattern, text(start:text\_length), length)
346       \textcolor{keywordflow}{if} (length >= 0) \textcolor{keywordflow}{goto} 999
347 \textcolor{keywordflow}{    end do}
348     \textcolor{comment}{! みつからない場合}
349 995 \textcolor{keywordflow}{continue}
350     start = 0
351     length = -1
352 999 \textcolor{keywordflow}{continue}
353     \textcolor{keyword}{deallocate}(ipattern)
\end{DoxyCode}
Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{namespacedc__regex_abc5c6d1c941d8689bdf6e32a6b919b25_cgraph}
\end{center}
\end{figure}
Here is the caller graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=550pt]{namespacedc__regex_abc5c6d1c941d8689bdf6e32a6b919b25_icgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{namespacedc__regex_a4d252079ab1de7bd10e41d183fb3437d}\label{namespacedc__regex_a4d252079ab1de7bd10e41d183fb3437d}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!match\+\_\+here@{match\+\_\+here}}
\index{match\+\_\+here@{match\+\_\+here}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{match\+\_\+here()}{match\_here()}}
{\footnotesize\ttfamily recursive subroutine dc\+\_\+regex\+::match\+\_\+here (\begin{DoxyParamCaption}\item[{integer, dimension(\+:), intent(in)}]{ipat,  }\item[{character(len = $\ast$), intent(in)}]{text,  }\item[{integer, intent(out)}]{length }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 154 of file dc\+\_\+regex.\+f90.



References hit(), sym\+\_\+count\+\_\+base, sym\+\_\+eol, sym\+\_\+normal\+\_\+set, sym\+\_\+plus, sym\+\_\+question, sym\+\_\+reversed\+\_\+set, sym\+\_\+star, and sym\+\_\+tailfix.



Referenced by match().


\begin{DoxyCode}
154     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}:: ipat(:)
155     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}:: text
156     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(out)}:: length
157     \textcolor{keywordtype}{integer}:: s1, s2, remain, i, hitmax, hitcount, hit\_at\_least
158     \textcolor{keywordtype}{logical}:: normal\_hit
159     \textcolor{keywordflow}{continue}
160     \textcolor{comment}{! パターンの終わり。空パターンには何でもマッチ}
161     \textcolor{keywordflow}{if} (\textcolor{keyword}{size}(ipat) == 0 .or. ipat(1) == sym\_eol) \textcolor{keywordflow}{then}
162       length = 0
163       \textcolor{keywordflow}{return}
164 \textcolor{keywordflow}{    endif}
165     \textcolor{comment}{! パターンの文末固定指示}
166     \textcolor{keywordflow}{if} (ipat(1) == sym\_tailfix) \textcolor{keywordflow}{then}
167       \textcolor{keywordflow}{if} (text == \textcolor{stringliteral}{""}) \textcolor{keywordflow}{then}
168         length = 0
169       \textcolor{keywordflow}{else}
170         length = -1
171 \textcolor{keywordflow}{      endif}
172       \textcolor{keywordflow}{return}
173 \textcolor{keywordflow}{    endif}
174     \textcolor{keywordflow}{if} (len(text) == 0) \textcolor{keywordflow}{then}
175       length = -1
176       \textcolor{keywordflow}{return}
177 \textcolor{keywordflow}{    endif}
178     \textcolor{comment}{! 1字指定(範囲または1字リテラル)の抽出 ... ipat(s1:s2)}
179     \textcolor{keywordflow}{if} (ipat(1) == sym\_normal\_set) \textcolor{keywordflow}{then}
180       s1 = 3
181       s2 = 2 + ipat(2) - sym\_count\_base
182       normal\_hit = .true.
183     \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (ipat(1) == sym\_reversed\_set) \textcolor{keywordflow}{then}
184       s1 = 3
185       s2 = 2 + ipat(2) - sym\_count\_base
186       normal\_hit = .false.
187     \textcolor{keywordflow}{else}
188       s1 = 1
189       s2 = 1
190       normal\_hit = .true.
191 \textcolor{keywordflow}{    endif}
192     \textcolor{comment}{! その次の記号 ipat(s2+1) は量化子か次の1字指定である}
193     remain = s2 + 2
194     \textcolor{keywordflow}{select case} (ipat(s2 + 1))
195     \textcolor{keywordflow}{case}(sym\_star)
196       hitmax = len(text)
197       hit\_at\_least = 0
198     \textcolor{keywordflow}{case}(sym\_plus)
199       hitmax = len(text)
200       hit\_at\_least = 1
201     \textcolor{keywordflow}{case}(sym\_question)
202       hitmax = 1
203       hit\_at\_least = 0
204 \textcolor{keywordflow}{    case default}
205       hitmax = 1
206       hit\_at\_least = 1
207       remain = s2 + 1
208 \textcolor{keywordflow}{    end select}
209     \textcolor{comment}{! 現位置以降の1字指定のヒット数を数える}
210     hitcount = 0
211     \textcolor{keywordflow}{do}, i = 1, hitmax
212       \textcolor{keywordflow}{if} (hit(ipat(s1:s2), text(i:i)) .neqv. normal\_hit) \textcolor{keywordflow}{then}
213         \textcolor{keywordflow}{exit}
214 \textcolor{keywordflow}{      endif}
215       hitcount = i
216 \textcolor{keywordflow}{    enddo}
217     \textcolor{comment}{! 現位置で無ヒットの場合、ヒットを要するならマッチ失敗}
218     \textcolor{keywordflow}{if} (hitcount < hit\_at\_least) \textcolor{keywordflow}{then}
219       length = -1
220       \textcolor{keywordflow}{return}
221 \textcolor{keywordflow}{    endif}
222     \textcolor{comment}{! 最長原理: なるべく長くヒットしたものから、残りのマッチする}
223     \textcolor{comment}{! ものを探す。いわゆる最左最長探索の最長である。}
224     \textcolor{keywordflow}{do}, i = 1 + hitcount, 1 + hit\_at\_least, -1
225       \textcolor{keyword}{call }match\_here(ipat(remain: ), text(i: ), length)
226       \textcolor{keywordflow}{if} (length >= 0) \textcolor{keywordflow}{then}
227         length = length + i - 1
228         \textcolor{keywordflow}{return}
229 \textcolor{keywordflow}{      endif}
230 \textcolor{keywordflow}{    enddo}
231     length = -1
\end{DoxyCode}
Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=302pt]{namespacedc__regex_a4d252079ab1de7bd10e41d183fb3437d_cgraph}
\end{center}
\end{figure}
Here is the caller graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=550pt]{namespacedc__regex_a4d252079ab1de7bd10e41d183fb3437d_icgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{namespacedc__regex_a966a504619d48c00c095386313b36925}\label{namespacedc__regex_a966a504619d48c00c095386313b36925}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!preprocess\+\_\+pattern@{preprocess\+\_\+pattern}}
\index{preprocess\+\_\+pattern@{preprocess\+\_\+pattern}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{preprocess\+\_\+pattern()}{preprocess\_pattern()}}
{\footnotesize\ttfamily subroutine dc\+\_\+regex\+::preprocess\+\_\+pattern (\begin{DoxyParamCaption}\item[{character(len = $\ast$), intent(in)}]{pattern,  }\item[{integer, dimension(\+:), intent(out)}]{symbols }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 41 of file dc\+\_\+regex.\+f90.



References c\+\_\+escape, sym\+\_\+anychar, sym\+\_\+count\+\_\+base, sym\+\_\+eol, sym\+\_\+headfix, sym\+\_\+isalpha, sym\+\_\+isdigit, sym\+\_\+isspace, sym\+\_\+isword, sym\+\_\+isxdigit, sym\+\_\+normal\+\_\+set, sym\+\_\+plus, sym\+\_\+question, sym\+\_\+reversed\+\_\+set, sym\+\_\+star, and sym\+\_\+tailfix.



Referenced by match().


\begin{DoxyCode}
41     \textcolor{comment}{!}
42     \textcolor{comment}{! メタキャラクタと普通の文字を分離}
43     \textcolor{comment}{!}
44     \textcolor{keywordtype}{character(len = *)}, \textcolor{keywordtype}{intent(in)}:: pattern
45     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(out)}:: symbols(:)
46     \textcolor{keywordtype}{integer}:: i, j, code, imax, j\_last\_set
47     \textcolor{keywordtype}{integer}:: status, stat\_return
48     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter}:: stat\_init = 1, stat\_escape = 2, &
49       stat\_open\_set = 3, stat\_in\_set = 4, stat\_hexadecimal = 5
50     \textcolor{keywordtype}{character}:: c
51     \textcolor{keywordflow}{continue}
52     status = stat\_init
53     stat\_return = stat\_init
54     symbols(:) = sym\_eol
55     j\_last\_set = 0
56     imax = len\_trim(pattern)
57     j = 1
58     \textcolor{keywordflow}{do}, i = 1, imax
59       c = pattern(i:i)
60       \textcolor{keywordflow}{select case}(status)
61       \textcolor{keywordflow}{case}(stat\_init)
62         \textcolor{keywordflow}{if} (c == c\_escape) \textcolor{keywordflow}{then}
63           status = stat\_escape
64           cycle
65         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == \textcolor{stringliteral}{"["}) \textcolor{keywordflow}{then}
66           symbols(j) = sym\_normal\_set
67           status = stat\_open\_set
68         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == \textcolor{stringliteral}{"."}) \textcolor{keywordflow}{then}
69           symbols(j) = sym\_anychar
70         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == \textcolor{stringliteral}{"?"}) \textcolor{keywordflow}{then}
71           symbols(j) = sym\_question
72         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == \textcolor{stringliteral}{"+"}) \textcolor{keywordflow}{then}
73           symbols(j) = sym\_plus
74         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == \textcolor{stringliteral}{"*"}) \textcolor{keywordflow}{then}
75           symbols(j) = sym\_star
76         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == \textcolor{stringliteral}{"^"} .and. i == 1) \textcolor{keywordflow}{then}
77           symbols(j) = sym\_headfix
78         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == \textcolor{stringliteral}{"$"} .and. i == imax) \textcolor{keywordflow}{then}
79           symbols(j) = sym\_tailfix
80         \textcolor{keywordflow}{else}
81           symbols(j) = ichar(c)
82 \textcolor{keywordflow}{        endif}
83       \textcolor{keywordflow}{case}(stat\_escape)
84         \textcolor{keywordflow}{if} (c == \textcolor{stringliteral}{'d'} .or. c == \textcolor{stringliteral}{'D'}) \textcolor{keywordflow}{then}
85           symbols(j) = sym\_isdigit
86         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == \textcolor{stringliteral}{'a'} .or. c == \textcolor{stringliteral}{'A'}) \textcolor{keywordflow}{then}
87           symbols(j) = sym\_isalpha
88         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == \textcolor{stringliteral}{'w'} .or. c == \textcolor{stringliteral}{'W'}) \textcolor{keywordflow}{then}
89           symbols(j) = sym\_isword
90         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == \textcolor{stringliteral}{'s'} .or. c == \textcolor{stringliteral}{'S'}) \textcolor{keywordflow}{then}
91           symbols(j) = sym\_isspace
92         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == \textcolor{stringliteral}{'z'} .or. c == \textcolor{stringliteral}{'Z'}) \textcolor{keywordflow}{then}
93           symbols(j) = sym\_isxdigit
94         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == \textcolor{stringliteral}{'x'} .or. c == \textcolor{stringliteral}{'X'}) \textcolor{keywordflow}{then}
95           symbols(j) = -1
96           status = stat\_hexadecimal
97           cycle
98         \textcolor{keywordflow}{else}
99           symbols(j) = ichar(c)
100 \textcolor{keywordflow}{        end if}
101         status = stat\_return
102       \textcolor{keywordflow}{case}(stat\_hexadecimal)
103         code = index(\textcolor{stringliteral}{"123456789ABCDEFabcdef"}, c)
104         \textcolor{keywordflow}{if} (code >= 16) code = code - 6
105         \textcolor{keywordflow}{if} (symbols(j) == -1) \textcolor{keywordflow}{then}
106           symbols(j) = code
107           cycle
108         \textcolor{keywordflow}{else}
109           symbols(j) = symbols(j) * 16 + code
110           status = stat\_return
111 \textcolor{keywordflow}{        endif}
112       \textcolor{keywordflow}{case}(stat\_open\_set)
113         symbols(j) = sym\_count\_base
114         j\_last\_set = j
115         stat\_return = stat\_in\_set
116         \textcolor{keywordflow}{if} (c == \textcolor{stringliteral}{'^'}) \textcolor{keywordflow}{then}
117           symbols(j - 1) = sym\_reversed\_set
118           status = stat\_in\_set
119         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == c\_escape) \textcolor{keywordflow}{then}
120           status = stat\_escape
121         \textcolor{keywordflow}{else}
122           j = j + 1
123           symbols(j) = ichar(c)
124           status = stat\_in\_set
125 \textcolor{keywordflow}{        endif}
126       \textcolor{keywordflow}{case}(stat\_in\_set)
127         \textcolor{keywordflow}{if} (c == \textcolor{stringliteral}{']'}) \textcolor{keywordflow}{then}
128           symbols(j\_last\_set) = sym\_count\_base + j - j\_last\_set - 1
129           stat\_return = stat\_init
130           status = stat\_init
131           cycle
132         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (c == c\_escape) \textcolor{keywordflow}{then}
133           status = stat\_escape
134           cycle
135         \textcolor{keywordflow}{else}
136           symbols(j) = ichar(c)
137 \textcolor{keywordflow}{        endif}
138 \textcolor{keywordflow}{      end select}
139       j = j + 1
140 \textcolor{keywordflow}{    enddo}
141     \textcolor{keywordflow}{select case}(status)
142     \textcolor{keywordflow}{case}(stat\_escape)
143       symbols(j) = ichar(\textcolor{stringliteral}{' '})
144     \textcolor{keywordflow}{case}(stat\_open\_set)
145       symbols(j) = sym\_count\_base
146     \textcolor{keywordflow}{case}(stat\_in\_set)
147       symbols(j\_last\_set) = sym\_count\_base + j - j\_last\_set - 1
148 \textcolor{keywordflow}{    end select}
\end{DoxyCode}
Here is the caller graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=550pt]{namespacedc__regex_a966a504619d48c00c095386313b36925_icgraph}
\end{center}
\end{figure}


\subsection{Variable Documentation}
\mbox{\Hypertarget{namespacedc__regex_a9f728201dff37a22e0290d900545bd5b}\label{namespacedc__regex_a9f728201dff37a22e0290d900545bd5b}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!c\+\_\+escape@{c\+\_\+escape}}
\index{c\+\_\+escape@{c\+\_\+escape}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{c\+\_\+escape}{c\_escape}}
{\footnotesize\ttfamily character, save dc\+\_\+regex\+::c\+\_\+escape = \textquotesingle{}\#\textquotesingle{}\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 21 of file dc\+\_\+regex.\+f90.



Referenced by preprocess\+\_\+pattern().


\begin{DoxyCode}
21   \textcolor{keywordtype}{character}, \textcolor{keywordtype}{save}    :: c\_escape = \textcolor{stringliteral}{'#'}
\end{DoxyCode}
\mbox{\Hypertarget{namespacedc__regex_acc818c3b7bec8403b471e682b81ec955}\label{namespacedc__regex_acc818c3b7bec8403b471e682b81ec955}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!sym\+\_\+anychar@{sym\+\_\+anychar}}
\index{sym\+\_\+anychar@{sym\+\_\+anychar}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{sym\+\_\+anychar}{sym\_anychar}}
{\footnotesize\ttfamily integer, parameter dc\+\_\+regex\+::sym\+\_\+anychar = 500\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 23 of file dc\+\_\+regex.\+f90.



Referenced by hit(), and preprocess\+\_\+pattern().


\begin{DoxyCode}
23   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: sym\_anychar = 500
\end{DoxyCode}
\mbox{\Hypertarget{namespacedc__regex_a1cd3b3421091582d081ee8d09ded7391}\label{namespacedc__regex_a1cd3b3421091582d081ee8d09ded7391}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!sym\+\_\+count\+\_\+base@{sym\+\_\+count\+\_\+base}}
\index{sym\+\_\+count\+\_\+base@{sym\+\_\+count\+\_\+base}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{sym\+\_\+count\+\_\+base}{sym\_count\_base}}
{\footnotesize\ttfamily integer, parameter dc\+\_\+regex\+::sym\+\_\+count\+\_\+base = 1000\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 36 of file dc\+\_\+regex.\+f90.



Referenced by match\+\_\+here(), and preprocess\+\_\+pattern().


\begin{DoxyCode}
36   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: sym\_count\_base = 1000
\end{DoxyCode}
\mbox{\Hypertarget{namespacedc__regex_a508717681a93bc57201e855252a0dd27}\label{namespacedc__regex_a508717681a93bc57201e855252a0dd27}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!sym\+\_\+eol@{sym\+\_\+eol}}
\index{sym\+\_\+eol@{sym\+\_\+eol}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{sym\+\_\+eol}{sym\_eol}}
{\footnotesize\ttfamily integer, parameter dc\+\_\+regex\+::sym\+\_\+eol = -\/128\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 22 of file dc\+\_\+regex.\+f90.



Referenced by match\+\_\+here(), and preprocess\+\_\+pattern().


\begin{DoxyCode}
22   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: sym\_eol = -128
\end{DoxyCode}
\mbox{\Hypertarget{namespacedc__regex_ac23262e1d00bc98302c5cf8e24255cbc}\label{namespacedc__regex_ac23262e1d00bc98302c5cf8e24255cbc}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!sym\+\_\+headfix@{sym\+\_\+headfix}}
\index{sym\+\_\+headfix@{sym\+\_\+headfix}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{sym\+\_\+headfix}{sym\_headfix}}
{\footnotesize\ttfamily integer, parameter dc\+\_\+regex\+::sym\+\_\+headfix = 540\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 29 of file dc\+\_\+regex.\+f90.



Referenced by match(), and preprocess\+\_\+pattern().


\begin{DoxyCode}
29   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: sym\_headfix = 540
\end{DoxyCode}
\mbox{\Hypertarget{namespacedc__regex_a490609e3026fe6e9a50dbf6a40481142}\label{namespacedc__regex_a490609e3026fe6e9a50dbf6a40481142}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!sym\+\_\+isalpha@{sym\+\_\+isalpha}}
\index{sym\+\_\+isalpha@{sym\+\_\+isalpha}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{sym\+\_\+isalpha}{sym\_isalpha}}
{\footnotesize\ttfamily integer, parameter dc\+\_\+regex\+::sym\+\_\+isalpha = 561\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 32 of file dc\+\_\+regex.\+f90.



Referenced by hit(), and preprocess\+\_\+pattern().


\begin{DoxyCode}
32   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: sym\_isalpha = 561
\end{DoxyCode}
\mbox{\Hypertarget{namespacedc__regex_af2ad6d1b5e4d9fac08e0a82b2bd3f323}\label{namespacedc__regex_af2ad6d1b5e4d9fac08e0a82b2bd3f323}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!sym\+\_\+isdigit@{sym\+\_\+isdigit}}
\index{sym\+\_\+isdigit@{sym\+\_\+isdigit}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{sym\+\_\+isdigit}{sym\_isdigit}}
{\footnotesize\ttfamily integer, parameter dc\+\_\+regex\+::sym\+\_\+isdigit = 560\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 31 of file dc\+\_\+regex.\+f90.



Referenced by hit(), and preprocess\+\_\+pattern().


\begin{DoxyCode}
31   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: sym\_isdigit = 560
\end{DoxyCode}
\mbox{\Hypertarget{namespacedc__regex_a06ba95caf7e7e96ca1d540b0e4ef16cc}\label{namespacedc__regex_a06ba95caf7e7e96ca1d540b0e4ef16cc}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!sym\+\_\+isspace@{sym\+\_\+isspace}}
\index{sym\+\_\+isspace@{sym\+\_\+isspace}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{sym\+\_\+isspace}{sym\_isspace}}
{\footnotesize\ttfamily integer, parameter dc\+\_\+regex\+::sym\+\_\+isspace = 563\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 34 of file dc\+\_\+regex.\+f90.



Referenced by hit(), and preprocess\+\_\+pattern().


\begin{DoxyCode}
34   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: sym\_isspace = 563
\end{DoxyCode}
\mbox{\Hypertarget{namespacedc__regex_a58db3ef8ab7f22ce5f2055040ce6a454}\label{namespacedc__regex_a58db3ef8ab7f22ce5f2055040ce6a454}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!sym\+\_\+isword@{sym\+\_\+isword}}
\index{sym\+\_\+isword@{sym\+\_\+isword}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{sym\+\_\+isword}{sym\_isword}}
{\footnotesize\ttfamily integer, parameter dc\+\_\+regex\+::sym\+\_\+isword = 562\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 33 of file dc\+\_\+regex.\+f90.



Referenced by hit(), and preprocess\+\_\+pattern().


\begin{DoxyCode}
33   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: sym\_isword = 562
\end{DoxyCode}
\mbox{\Hypertarget{namespacedc__regex_a13ef3092a5d1eaf8c39cd285648229b4}\label{namespacedc__regex_a13ef3092a5d1eaf8c39cd285648229b4}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!sym\+\_\+isxdigit@{sym\+\_\+isxdigit}}
\index{sym\+\_\+isxdigit@{sym\+\_\+isxdigit}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{sym\+\_\+isxdigit}{sym\_isxdigit}}
{\footnotesize\ttfamily integer, parameter dc\+\_\+regex\+::sym\+\_\+isxdigit = 564\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 35 of file dc\+\_\+regex.\+f90.



Referenced by hit(), and preprocess\+\_\+pattern().


\begin{DoxyCode}
35   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: sym\_isxdigit = 564
\end{DoxyCode}
\mbox{\Hypertarget{namespacedc__regex_aef499ad4034d52eb6fb8d7dfacf380eb}\label{namespacedc__regex_aef499ad4034d52eb6fb8d7dfacf380eb}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!sym\+\_\+normal\+\_\+set@{sym\+\_\+normal\+\_\+set}}
\index{sym\+\_\+normal\+\_\+set@{sym\+\_\+normal\+\_\+set}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{sym\+\_\+normal\+\_\+set}{sym\_normal\_set}}
{\footnotesize\ttfamily integer, parameter dc\+\_\+regex\+::sym\+\_\+normal\+\_\+set = 520\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 27 of file dc\+\_\+regex.\+f90.



Referenced by match\+\_\+here(), and preprocess\+\_\+pattern().


\begin{DoxyCode}
27   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: sym\_normal\_set = 520
\end{DoxyCode}
\mbox{\Hypertarget{namespacedc__regex_af19845943d8d719fbc449084b5497f42}\label{namespacedc__regex_af19845943d8d719fbc449084b5497f42}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!sym\+\_\+plus@{sym\+\_\+plus}}
\index{sym\+\_\+plus@{sym\+\_\+plus}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{sym\+\_\+plus}{sym\_plus}}
{\footnotesize\ttfamily integer, parameter dc\+\_\+regex\+::sym\+\_\+plus = 502\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 25 of file dc\+\_\+regex.\+f90.



Referenced by match\+\_\+here(), and preprocess\+\_\+pattern().


\begin{DoxyCode}
25   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: sym\_plus = 502
\end{DoxyCode}
\mbox{\Hypertarget{namespacedc__regex_afee684d930e4211cf5252ef637a8830f}\label{namespacedc__regex_afee684d930e4211cf5252ef637a8830f}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!sym\+\_\+question@{sym\+\_\+question}}
\index{sym\+\_\+question@{sym\+\_\+question}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{sym\+\_\+question}{sym\_question}}
{\footnotesize\ttfamily integer, parameter dc\+\_\+regex\+::sym\+\_\+question = 501\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 24 of file dc\+\_\+regex.\+f90.



Referenced by match\+\_\+here(), and preprocess\+\_\+pattern().


\begin{DoxyCode}
24   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: sym\_question = 501
\end{DoxyCode}
\mbox{\Hypertarget{namespacedc__regex_aa558b709db6a370df0b2d3c1b5d66262}\label{namespacedc__regex_aa558b709db6a370df0b2d3c1b5d66262}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!sym\+\_\+reversed\+\_\+set@{sym\+\_\+reversed\+\_\+set}}
\index{sym\+\_\+reversed\+\_\+set@{sym\+\_\+reversed\+\_\+set}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{sym\+\_\+reversed\+\_\+set}{sym\_reversed\_set}}
{\footnotesize\ttfamily integer, parameter dc\+\_\+regex\+::sym\+\_\+reversed\+\_\+set = 521\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 28 of file dc\+\_\+regex.\+f90.



Referenced by match\+\_\+here(), and preprocess\+\_\+pattern().


\begin{DoxyCode}
28   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: sym\_reversed\_set = 521
\end{DoxyCode}
\mbox{\Hypertarget{namespacedc__regex_a5d750c4b279af3262496dfeffb9dd402}\label{namespacedc__regex_a5d750c4b279af3262496dfeffb9dd402}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!sym\+\_\+star@{sym\+\_\+star}}
\index{sym\+\_\+star@{sym\+\_\+star}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{sym\+\_\+star}{sym\_star}}
{\footnotesize\ttfamily integer, parameter dc\+\_\+regex\+::sym\+\_\+star = 503\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 26 of file dc\+\_\+regex.\+f90.



Referenced by match\+\_\+here(), and preprocess\+\_\+pattern().


\begin{DoxyCode}
26   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: sym\_star = 503
\end{DoxyCode}
\mbox{\Hypertarget{namespacedc__regex_ad6e72d8f105295f427eab258e21bc9f0}\label{namespacedc__regex_ad6e72d8f105295f427eab258e21bc9f0}} 
\index{dc\+\_\+regex@{dc\+\_\+regex}!sym\+\_\+tailfix@{sym\+\_\+tailfix}}
\index{sym\+\_\+tailfix@{sym\+\_\+tailfix}!dc\+\_\+regex@{dc\+\_\+regex}}
\subsubsection{\texorpdfstring{sym\+\_\+tailfix}{sym\_tailfix}}
{\footnotesize\ttfamily integer, parameter dc\+\_\+regex\+::sym\+\_\+tailfix = 541\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 30 of file dc\+\_\+regex.\+f90.



Referenced by match\+\_\+here(), and preprocess\+\_\+pattern().


\begin{DoxyCode}
30   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: sym\_tailfix = 541
\end{DoxyCode}
