Commit 4fed37bb authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

Introduce IOAUT_CONTEXT and RW_CONTEXT for fmp.

parent c5cbceed
2008-08-05 Alexandre Duret-Lutz <adl@lrde.epita.fr>
* taf-kit/src/Makefile.am (vcsn_char_fmp_CPPFLAGS): Define
IOAUT_CONTEXT and RW_CONTEXT.
* taf-kit/src/fmp_commands.cc, taf-kit/src/getters.hxx,
taf-kit/src/pipe.hh, taf-kit/src/pipe_getters.hh,
taf-kit/src/pipe_getters.hxx, taf-kit/src/pipe_writers.hh,
taf-kit/src/pipe_writers.hxx: Use IOAUT_CONTEXT and RW_CONTEXT
instead of assuming boolean_automaton and boolean_transucer. Also
disable the command "to_rw" if RW_CONTEXT is undefined.
2008-08-05 Alexandre Duret-Lutz <adl@lrde.epita.fr>
* taf-kit/src/edition_commands.hxx
......
......@@ -66,7 +66,9 @@ vcsn_char_fmp_SOURCES = $(COMMON_SOURCES) fmp_commands.cc
#vcsn_char_fmp_CPPFLAGS = $(AM_CPPFLAGS) -DCONTEXT=fmp_transducer \
# -DWITH_TWO_ALPHABETS -DVCSN_USE_LIB
vcsn_char_fmp_CPPFLAGS = $(AM_CPPFLAGS) \
-DCONTEXT=fmp_transducer -DWITH_TWO_ALPHABETS
-DCONTEXT=fmp_transducer -DWITH_TWO_ALPHABETS \
-DIOAUT_CONTEXT=boolean_automaton \
-DRW_CONTEXT=boolean_transducer
vcsn_char_fmp_LDADD = $(LDADD) \
$(top_builddir)/lib/libvcsn-fmp-tdc.la \
$(top_builddir)/lib/libkrat_exp.la
......
......@@ -71,53 +71,54 @@ DEFINE_COMMAND (NAME (evaluation)
CODE (/* empty */)
OUTPUT (
evaluation (get_aut(args.args[1]),
boolean_automaton::make_rat_exp(
IOAUT_CONTEXT::make_rat_exp(
get_first_alphabet (args.alphabet),
args.args[2], args.tok_rep)) << std::endl)
RETURNVALUE (0));
DEFINE_COMMAND (NAME (evaluation_fmp)
CODE (
boolean_automaton::automaton_t a = get_boolean_aut(args.args[2]);
boolean_automaton::automaton_t res =
boolean_automaton::make_automaton(get_second_alphabet(args.alphabet2));
IOAUT_CONTEXT::automaton_t a = get_boolean_aut(args.args[2]);
IOAUT_CONTEXT::automaton_t res =
IOAUT_CONTEXT::make_automaton(get_second_alphabet(args.alphabet2));
evaluation_fmp(get_aut(args.args[1]), a, res))
KEEP_AUTOMATON (res)
RETURNVALUE (0));
DEFINE_COMMAND (NAME (domain)
CODE (
boolean_automaton::automaton_t a =
boolean_automaton::make_automaton(get_first_alphabet(args.alphabet));
IOAUT_CONTEXT::automaton_t a =
IOAUT_CONTEXT::make_automaton(get_first_alphabet(args.alphabet));
domain(get_aut(args.args[1]), a))
KEEP_AUTOMATON (a)
RETURNVALUE (0));
DEFINE_COMMAND (NAME (image)
CODE (
boolean_automaton::automaton_t a =
boolean_automaton::make_automaton(get_second_alphabet(args.alphabet2));
IOAUT_CONTEXT::automaton_t a =
IOAUT_CONTEXT::make_automaton(get_second_alphabet(args.alphabet2));
image(get_aut(args.args[1]), a))
KEEP_AUTOMATON (a)
RETURNVALUE (0));
#ifdef RW_CONTEXT
DEFINE_COMMAND (NAME (to_rw)
CODE (
automaton_t fmp = get_aut(args.args[1]);
automaton_t::monoid_t m = fmp.structure().series().monoid();
boolean_transducer::automaton_t a =
boolean_transducer::make_automaton(m.first_monoid().alphabet(),
m.second_monoid().alphabet());
RW_CONTEXT::automaton_t a =
RW_CONTEXT::make_automaton(m.first_monoid().alphabet(),
m.second_monoid().alphabet());
fmp_to_rw(fmp, a))
KEEP_AUTOMATON (a)
RETURNVALUE (0));
#endif
DEFINE_COMMAND (NAME (intersection)
CODE (
boolean_automaton::automaton_t a =
IOAUT_CONTEXT::automaton_t a =
get_boolean_aut(args.args[1]);
boolean_automaton::alphabet_t A =
IOAUT_CONTEXT::alphabet_t A =
a.structure().series().monoid().alphabet();
automaton_t fmp = make_automaton(A,A);
identity(a, fmp))
......@@ -192,8 +193,10 @@ const command_t command_map[] =
COMMAND_ENTRY (u_compose, AutAut,
"Compose `aut1' and `aut2', two Boolean transducers,\n\t"
"preserve the number of path."),
#ifdef RW_CONTEXT
COMMAND_ENTRY (to_rw, Aut,
"Give the equivalent rational weight transducer of `aut'."),
#endif
COMMAND_ENTRY (invert, Aut, "Give the inverse of `aut'."),
COMMAND_ENTRY (intersection, Aut,
"Transform a Boolean automaton in a fmp transducer by\n\t"
......
......@@ -172,12 +172,12 @@ static automaton_t get_aut (const std::string& s)
}
#ifdef WITH_TWO_ALPHABETS
static boolean_automaton::automaton_t get_boolean_aut(std::string s)
static IOAUT_CONTEXT::automaton_t get_boolean_aut(std::string s)
{
# ifdef GLOBAL_RESULT
if (s == "-")
{
boolean_automaton::automaton_t a =
IOAUT_CONTEXT::automaton_t a =
boost::apply_visitor(boolean_automaton_getter
(GLOBAL_RESULT.name, GLOBAL_RESULT.input_type),
GLOBAL_RESULT.output);
......@@ -191,8 +191,8 @@ static boolean_automaton::automaton_t get_boolean_aut(std::string s)
using namespace vcsn::tools;
using namespace vcsn::xml;
boolean_automaton::automaton_t a =
boolean_automaton::make_automaton(first_alphabet_t());
IOAUT_CONTEXT::automaton_t a =
IOAUT_CONTEXT::make_automaton(first_alphabet_t());
# ifdef GLOBAL_RESULT
switch (GLOBAL_RESULT.input_type)
......
......@@ -2,7 +2,7 @@
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2006, 2007 The Vaucanson Group.
// Copyright (C) 2006, 2007, 2008 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
......@@ -43,12 +43,14 @@
# include <boost/variant.hpp>
# ifdef WITH_TWO_ALPHABETS
// For boolean_transducer namespace.
// Make sure this is not supposed to be included from somewhere else
// (e.g. CONTEXT_HEADER).
# include <vaucanson/boolean_transducer.hh>
# endif // !WITH_TWO_ALPHABETS
# ifdef IOAUT_CONTEXT
# define IOAUT_CONTEXT_HEADER <vaucanson/IOAUT_CONTEXT.hh>
# include IOAUT_CONTEXT_HEADER
# endif
# ifdef RW_CONTEXT
# define RW_CONTEXT_HEADER <vaucanson/RW_CONTEXT.hh>
# include RW_CONTEXT_HEADER
# endif
using namespace CONTEXT_NAMESPACE;
using namespace vcsn;
......@@ -64,11 +66,13 @@ typedef boost::variant<command_output_status,
automaton_t,
# ifndef WITH_TWO_ALPHABETS
rat_exp_t,
# endif // !WITH_TWO_ALPHABETS
# ifdef WITH_TWO_ALPHABETS
boolean_automaton::automaton_t,
boolean_transducer::automaton_t,
# endif // !WITH_TWO_ALPHABETS
# endif
# ifdef IOAUT_CONTEXT
IOAUT_CONTEXT::automaton_t,
# endif
# ifdef RW_CONTEXT
RW_CONTEXT::automaton_t,
# endif
std::string> command_output_variant;
// i/o types for automaton_loader and automaton_saver.
......
......@@ -71,21 +71,21 @@ public:
# ifdef WITH_TWO_ALPHABETS
class boolean_automaton_getter
: public boost::static_visitor<boolean_automaton::automaton_t>
: public boost::static_visitor<IOAUT_CONTEXT::automaton_t>
{
public:
boolean_automaton_getter (std::string& command, input_format_t);
boolean_automaton::automaton_t
operator() (boolean_automaton::automaton_t& a) const;
IOAUT_CONTEXT::automaton_t
operator() (IOAUT_CONTEXT::automaton_t& a) const;
boolean_automaton::automaton_t
IOAUT_CONTEXT::automaton_t
operator() (std::string& str) const;
boolean_automaton::automaton_t operator() (command_output_status& i) const;
IOAUT_CONTEXT::automaton_t operator() (command_output_status& i) const;
template<typename T>
boolean_automaton::automaton_t operator() (T&) const;
IOAUT_CONTEXT::automaton_t operator() (T&) const;
std::string command;
input_format_t f;
......
......@@ -2,7 +2,7 @@
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2006, 2007 The Vaucanson Group.
// Copyright (C) 2006, 2007, 2008 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
......@@ -184,20 +184,19 @@ boolean_automaton_getter::boolean_automaton_getter (std::string& cmd,
{
}
boolean_automaton::automaton_t
boolean_automaton_getter::operator()
(boolean_automaton::automaton_t& a) const
IOAUT_CONTEXT::automaton_t
boolean_automaton_getter::operator() (IOAUT_CONTEXT::automaton_t& a) const
{
return a;
}
boolean_automaton::automaton_t
IOAUT_CONTEXT::automaton_t
boolean_automaton_getter::operator() (std::string& str) const
{
std::istringstream is (str);
boolean_automaton::automaton_t a =
boolean_automaton::make_automaton (first_alphabet_t());
IOAUT_CONTEXT::automaton_t a =
IOAUT_CONTEXT::make_automaton (first_alphabet_t());
switch (f)
{
......@@ -214,7 +213,7 @@ boolean_automaton_getter::operator() (std::string& str) const
return a;
}
boolean_automaton::automaton_t
IOAUT_CONTEXT::automaton_t
boolean_automaton_getter::operator() (command_output_status& i) const
{
if (i != PIPE_GET_FROM_STDIN)
......@@ -225,8 +224,8 @@ boolean_automaton_getter::operator() (command_output_status& i) const
exit (1);
}
boolean_automaton::automaton_t a =
boolean_automaton::make_automaton (first_alphabet_t ());
IOAUT_CONTEXT::automaton_t a =
IOAUT_CONTEXT::make_automaton (first_alphabet_t ());
switch (f)
{
......@@ -244,7 +243,7 @@ boolean_automaton_getter::operator() (command_output_status& i) const
}
template<typename T>
boolean_automaton::automaton_t
IOAUT_CONTEXT::automaton_t
boolean_automaton_getter::operator() (T&) const
{
std::cerr << command
......
......@@ -2,7 +2,7 @@
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2006, 2007 The Vaucanson Group.
// Copyright (C) 2006, 2007, 2008 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
......@@ -54,10 +54,12 @@ public:
void operator() (rat_exp_t& a) const;
# endif // !WITH_TWO_ALPHABETS
# ifdef WITH_TWO_ALPHABETS
void operator() (boolean_transducer::automaton_t& a) const;
void operator() (boolean_automaton::automaton_t& a) const;
# endif // !WITH_TWO_ALPHABETS
# ifdef IOAUT_CONTEXT
void operator() (IOAUT_CONTEXT::automaton_t& a) const;
# endif
# ifdef RW_CONTEXT
void operator() (RW_CONTEXT::automaton_t& a) const;
# endif
template<typename T>
void operator() (T&) const;
......
......@@ -2,7 +2,7 @@
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2006, 2007 The Vaucanson Group.
// Copyright (C) 2006, 2007, 2008 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
......@@ -79,10 +79,10 @@ pipe_stream_writer::operator() (rat_exp_t& a) const
}
# endif // !WITH_TWO_ALPHABETS
# ifdef WITH_TWO_ALPHABETS
# ifdef RW_CONTEXT
void
pipe_stream_writer::operator()
(boolean_transducer::automaton_t& a) const
(RW_CONTEXT::automaton_t& a) const
{
switch (f)
{
......@@ -99,10 +99,12 @@ pipe_stream_writer::operator()
std::cerr << "Could not save automaton." << std::endl;
}
}
# endif // RW_CONTEXT
# ifdef IOAUT_CONTEXT
void
pipe_stream_writer::operator()
(boolean_automaton::automaton_t& a) const
(IOAUT_CONTEXT::automaton_t& a) const
{
switch (f)
{
......@@ -119,7 +121,7 @@ pipe_stream_writer::operator()
std::cerr << "Could not save automaton." << std::endl;
}
}
# endif // !WITH_TWO_ALPHABETS
# endif // IOAUT_CONTEXT
template<typename T>
void
......
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