Commit 2122559c authored by Jerome Galtier's avatar Jerome Galtier
Browse files

Add automata projection algorithms to Taf-Kit.

	* taf-kit/src/Makefile.am: Use new macros.
	* taf-kit/src/common_automaton_commands.hh: Define the new
	  first_projection and second_projection commands.
	* taf-kit/src/pipe.hh,
	* taf-kit/src/pipe_writers.hh,
	* taf-kit/src/pipe_writers.hxx: Update to support auxiliary
	  automaton types.
parent f6055ddd
2008-10-06 Jerome Galtier <jerome.galtier@lrde.epita.fr>
Add automata projection algorithms to Taf-Kit.
* taf-kit/src/Makefile.am: Use new macros.
* taf-kit/src/common_automaton_commands.hh: Define the new
first_projection and second_projection commands.
* taf-kit/src/pipe.hh,
* taf-kit/src/pipe_writers.hh,
* taf-kit/src/pipe_writers.hxx: Update to support auxiliary
automaton types.
2008-10-06 Jerome Galtier <jerome.galtier@lrde.epita.fr>
 
Add new automaton projection algorithms (close #172).
......
......@@ -141,7 +141,9 @@ vcsn_char_char_b_SOURCES = $(COMMON_SOURCES) \
common_automaton_commands.hh \
b_commands.cc
vcsn_char_char_b_CPPFLAGS = $(AM_CPPFLAGS) -DCONTEXT=char_char_boolean_automaton \
-DVCSN_USE_LIB
-DVCSN_USE_LIB \
-DFIRST_PROJECTION_CONTEXT=boolean_automaton \
-DSECOND_PROJECTION_CONTEXT=boolean_automaton
vcsn_char_char_b_LDADD = $(LDADD) \
$(top_builddir)/lib/libkrat_exp.la \
$(top_builddir)/lib/libvcsn-char-char-b.la
......@@ -151,7 +153,9 @@ vcsn_int_int_b_SOURCES = $(COMMON_SOURCES) \
common_automaton_commands.hh \
b_commands.cc
vcsn_int_int_b_CPPFLAGS = $(AM_CPPFLAGS) -DCONTEXT=int_int_boolean_automaton \
-DVCSN_USE_LIB
-DVCSN_USE_LIB \
-DFIRST_PROJECTION_CONTEXT=int_boolean_automaton \
-DSECOND_PROJECTION_CONTEXT=int_boolean_automaton
vcsn_int_int_b_LDADD = $(LDADD) \
$(top_builddir)/lib/libkrat_exp.la \
$(top_builddir)/lib/libvcsn-int-int-b.la
......
......@@ -122,6 +122,28 @@ DEFINE_COMMAND (NAME (standardize)
KEEP_AUTOMATON(a)
RETURNVALUE (0));
# ifdef FIRST_PROJECTION_CONTEXT
DEFINE_COMMAND (NAME (first_projection)
CODE (
automaton_t src = get_aut(args.args[1]);
vcsn::CONTEXT::projection_traits_t::first_projection_t a =
vcsn::CONTEXT::projection_traits_t::first_projection(src);
first_projection(src, a))
KEEP_AUTOMATON (a)
RETURNVALUE (0));
# endif
# ifdef SECOND_PROJECTION_CONTEXT
DEFINE_COMMAND (NAME (second_projection)
CODE (
automaton_t src = get_aut(args.args[1]);
vcsn::CONTEXT::projection_traits_t::second_projection_t a =
vcsn::CONTEXT::projection_traits_t::second_projection(src);
second_projection(src, a))
KEEP_AUTOMATON (a)
RETURNVALUE (0));
# endif
# define DEFINE_COMMAND_OF_STANDARD(Algo) \
DEFINE_COMMAND (NAME (Algo ## _of_standard) \
CODE (automaton_t a = get_aut (args.args[1]); \
......@@ -148,6 +170,21 @@ DEFINE_COMMAND (NAME (star_of_standard)
KEEP_AUTOMATON (a)
RETURNVALUE(0));
# ifdef FIRST_PROJECTION_CONTEXT
# define FIRST_PROJECTION_COMMAND_ENTRY \
COMMAND_ENTRY (first_projection, Aut, \
"Give the first projection of `aut'."),
# else
# define FIRST_PROJECTION_COMMAND_ENTRY
# endif
# ifdef SECOND_PROJECTION_CONTEXT
# define SECOND_PROJECTION_COMMAND_ENTRY \
COMMAND_ENTRY (second_projection, Aut, \
"Give the second projection of `aut'."),
# else
# define SECOND_PROJECTION_COMMAND_ENTRY
# endif
# define USE_GENERIC_AUTOMATON_COMMAND_GROUP() \
COMMAND_GROUP ( \
......@@ -155,6 +192,8 @@ DEFINE_COMMAND (NAME (star_of_standard)
\
COMMAND_ENTRY (accessible, Aut, \
"Give the maximal accessible subautomaton of `aut'."), \
FIRST_PROJECTION_COMMAND_ENTRY \
SECOND_PROJECTION_COMMAND_ENTRY \
COMMAND_ENTRY (eps_removal, Aut, \
"Give `aut' closed over epsilon transitions."), \
COMMAND_ENTRY (eps_removal_sp, Aut, \
......
......@@ -51,6 +51,16 @@
# define RW_CONTEXT_HEADER <vaucanson/RW_CONTEXT.hh>
# include RW_CONTEXT_HEADER
# endif
# ifdef FIRST_PROJECTION_CONTEXT
# define FIRST_PROJECTION_CONTEXT_HEADER <vaucanson/ \
FIRST_PROJECTION_CONTEXT.hh>
# include FIRST_PROJECTION_CONTEXT_HEADER
# endif
# ifdef SECOND_PROJECTION_CONTEXT
# define SECOND_PROJECTION_CONTEXT_HEADER <vaucanson/ \
SECOND_PROJECTION_CONTEXT.hh>
# include SECOND_PROJECTION_CONTEXT_HEADER
# endif
using namespace CONTEXT_NAMESPACE;
using namespace vcsn;
......@@ -72,6 +82,12 @@ typedef boost::variant<command_output_status,
# endif
# ifdef RW_CONTEXT
RW_CONTEXT::automaton_t,
# endif
# ifdef FIRST_PROJECTION_CONTEXT
FIRST_PROJECTION_CONTEXT::automaton_t,
# endif
# ifdef SECOND_PROJECTION_CONTEXT
SECOND_PROJECTION_CONTEXT::automaton_t,
# endif
std::string> command_output_variant;
......
......@@ -61,6 +61,13 @@ public:
void operator() (RW_CONTEXT::automaton_t& a) const;
# endif
# ifdef FIRST_PROJECTION_CONTEXT
void operator() (FIRST_PROJECTION_CONTEXT::automaton_t& a) const;
# endif
# if defined SECOND_PROJECTION_CONTEXT and SECOND_PROJECTION_CONTEXT != FIRST_PROJECTION_CONTEXT
void operator() (SECOND_PROJECTION_CONTEXT::automaton_t& a) const;
# endif
template<typename T>
void operator() (T&) const;
......
......@@ -134,6 +134,50 @@ pipe_stream_writer::operator()
}
# endif // IOAUT_CONTEXT
# ifdef FIRST_PROJECTION_CONTEXT
void
pipe_stream_writer::operator()
(FIRST_PROJECTION_CONTEXT::automaton_t& a) const
{
switch (aut_f)
{
case OUTPUT_TYPE_XML:
o << automaton_saver (a, string_out (), XML ());
break;
case OUTPUT_TYPE_FSM:
fsm_dump (o, a);
break;
case OUTPUT_TYPE_DOT:
dot_dump (o, a, "");
break;
default:
std::cerr << "Could not save automaton: unkown output type." << std::endl;
}
}
# endif // ! FIRST_PROJECTION_CONTEXT
# if defined SECOND_PROJECTION_CONTEXT and SECOND_PROJECTION_CONTEXT != FIRST_PROJECTION_CONTEXT
void
pipe_stream_writer::operator()
(SECOND_PROJECTION_CONTEXT::automaton_t& a) const
{
switch (aut_f)
{
case OUTPUT_TYPE_XML:
o << automaton_saver (a, string_out (), XML ());
break;
case OUTPUT_TYPE_FSM:
fsm_dump (o, a);
break;
case OUTPUT_TYPE_DOT:
dot_dump (o, a, "");
break;
default:
std::cerr << "Could not save automaton: unkown output type." << std::endl;
}
}
# endif // ! SECOND_PROJECTION_CONTEXT
template<typename T>
void
pipe_stream_writer::operator() (T&) const
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment