#include "RegexAutomaton.h"
namespace
{
namespace
{
using
namespace
collections
;
::
()
{
=
0
;
}
*
::
()
{
*
=
new
;
state
->
=
false
;
state
->
=
0
;
.
(
state
);
return
state
;
}
*
::
(
*
,
*
)
{
*
=
new
;
transition
->
=
;
transition
->
=
;
->
.
(
transition
);
->
.
(
transition
);
.
(
transition
);
return
transition
;
}
*
::
(
*
,
*
,
)
{
*
=
(
,
);
transition
->
=
::
;
transition
->
;
return
transition
;
}
*
::
(
*
,
*
)
{
*
=
(
,
);
transition
->
=
::
;
return
transition
;
}
*
::
(
*
,
*
)
{
*
=
(
,
);
transition
->
=
::
;
return
transition
;
}
*
::
(
*
,
*
)
{
*
=
(
,
);
transition
->
=
::
;
return
transition
;
}
*
::
(
*
,
*
)
{
*
=
(
,
);
transition
->
=
::
;
return
transition
;
}
*
::
(
*
,
*
,
)
{
*
=
(
,
);
transition
->
=
::
;
transition
->
=
;
return
transition
;
}
*
::
(
*
,
*
,
,
)
{
*
=
(
,
);
transition
->
=
::
;
transition
->
=
;
transition
->
=
;
return
transition
;
}
*
::
(
*
,
*
)
{
*
=
(
,
);
transition
->
=
::
;
return
transition
;
}
*
::
(
*
,
*
)
{
*
=
(
,
);
transition
->
=
::
;
return
transition
;
}
*
::
(
*
,
*
)
{
*
=
(
,
);
transition
->
=
::
;
return
transition
;
}
*
::
(
*
,
*
)
{
*
=
(
,
);
transition
->
=
::
;
return
transition
;
}
bool
(
*
)
{
switch
(
->
)
{
case
::
:
case
::
:
case
::
:
case
::
:
return
true
;
default
:
return
false
;
}
}
bool
(
*
)
{
switch
(
->
)
{
case
::
:
return
true
;
default
:
return
false
;
}
}
bool
(
*
,
*
)
{
if
(
->
!=
->
)
return
false
;
switch
(
->
)
{
case
::
:
return
->
->
;
case
::
:
return
->
==
->
;
case
::
:
return
->
==
->
&&
->
==
->
;
default
:
return
true
;
}
}
void
(
*
,
*
,
bool
(*
)(
*),
<
*>&
,
<
*>&
)
{
if
(!
.
(
))
{
.
(
);
for
(
=
0
;
i
<
->
.
();
i
++)
{
*
=
->
i
];
if
(
(
transition
))
{
if
(!
.
(
transition
->
))
{
if
(
transition
->
->
)
{
->
=
true
;
}
(
,
transition
->
,
,
,
);
}
}
else
{
.
(
transition
);
}
}
}
}
::
(
::
,
bool
(*
)(
*),
<
*,
*>&
)
{
::
=
new
;
<
*,
*>
;
<
*>
;
<
*>
;
stateMap
.
(
,
target
());
.
(
stateMap
],
);
target
=
target
0
].
();
(
target
,
);
for
(
=
0
;
i
<
target
.
();
i
++)
{
*
=
target
i
].
();
*
=
targetState
];
if
(
sourceState
->
)
{
targetState
->
=
true
;
}
epsilonStates
.
();
transitions
.
();
(
targetState
,
sourceState
,
,
epsilonStates
,
transitions
);
for
(
=
0
;
j
<
transitions
.
();
j
++)
{
*
=
transitions
j
];
if
(!
stateMap
.
().
(
transition
->
))
{
stateMap
.
(
transition
->
,
target
());
.
(
stateMap
transition
->
],
transition
->
);
}
*
=
target
(
targetState
,
stateMap
transition
->
]);
newTransition
->
=
transition
->
;
newTransition
->
=
transition
->
;
newTransition
->
transition
->
;
newTransition
->
=
transition
->
;
}
}
return
target
;
}
::
(
::
,
<
*,
*>&
)
{
::
=
new
;
<
*,
*>
;
<
*>
;
(
target
,
);
*
=
target
();
target
=
startState
;
.
(
startState
,
);
<
*>
;
<
*>
;
transitionTargets
.
(
false
);
relativeStates
.
(
false
);
for
(
=
0
;
i
<
target
.
();
i
++)
{
*
=
target
i
].
();
nfaTransitions
.
();
transitionClasses
.
();
const
<
*>&
=
currentState
];
for
(
=
0
;
j
<
nfaStates
.
();
j
++)
{
*
=
nfaStates
.
(
j
);
for
(
=
0
;
k
<
nfaState
->
.
();
k
++)
{
*
=
nfaState
->
k
];
*
=
0
;
for
(
=
0
;
l
<
nfaTransitions
.
().
();
l
++)
{
*
=
nfaTransitions
.
()
l
];
if
(
(
key
,
nfaTransition
))
{
transitionClass
=
key
;
break
;
}
}
if
(
transitionClass
==
0
)
{
transitionClass
=
nfaTransition
;
transitionClasses
.
(
transitionClass
);
}
nfaTransitions
.
(
transitionClass
,
nfaTransition
);
}
}
for
(
=
0
;
j
<
transitionClasses
.
();
j
++)
{
const
<
*>&
=
nfaTransitions
transitionClasses
j
]];
transitionTargets
.
();
for
(
=
0
;
l
<
transitionSet
.
();
l
++)
{
*
=
transitionSet
.
(
l
)->
;
if
(!
transitionTargets
.
(
nfaState
))
{
transitionTargets
.
(
nfaState
);
}
}
*
=
0
;
for
(
=
0
;
k
<
.
();
k
++)
{
(
relativeStates
,
.
(
k
));
if
(
relativeStates
.
()==
transitionTargets
.
())
{
bool
=
true
;
for
(
=
0
;
l
<
relativeStates
.
();
l
++)
{
if
(
relativeStates
l
]!=
transitionTargets
l
])
{
equal
=
false
;
break
;
}
}
if
(
equal
)
{
dfaState
=
.
()
k
];
break
;
}
}
}
if
(!
dfaState
)
{
dfaState
=
target
();
for
(
=
0
;
k
<
transitionTargets
.
();
k
++)
{
.
(
dfaState
,
transitionTargets
k
]);
if
(
transitionTargets
k
]->
)
{
dfaState
->
=
true
;
}
}
}
*
=
transitionClasses
j
];
*
=
target
(
currentState
,
dfaState
);
newTransition
->
=
transitionClass
->
;
newTransition
->
=
transitionClass
->
;
newTransition
->
transitionClass
->
;
newTransition
->
=
transitionClass
->
;
}
}
return
target
;
}
}
}