Commit b080170c authored by Vivien Delmon's avatar Vivien Delmon
Browse files

Fix some errors introduced in patch 1976.

	* lib/krat_exp/krat_exp_bison.yy:
	    Adapt structure using PIMPL pattern.
	* include/vaucanson/algebra/implementation/series/krat_exp_parser.hxx: 
	    Remove bad include and replaced it by a forward declaration.
	* data/automata/b/Makefile.am:
	    Fix CPPFLAGS error introduced in patch 1976.
	* data/automata/tdc/Makefile.am:
	    Fix CPPFLAGS error introduced in patch 1976.
	* data/automata/z/Makefile.am:
	    Fix CPPFLAGS error introduced in patch 1976.
	* lib/generate_libvcsn.rb:
	    Fix CPPFLAGS error introduced in patch 1976.
	* src/tests/sanity/Makefile.am:
	    Fix CPPFLAGS error introduced in patch 1976.
	* src/tests/test-suites/test-suite.mk:
	    Fix CPPFLAGS error introduced in patch 1976.
	* src/tests/xml/Makefile.am:
	    Fix CPPFLAGS error introduced in patch 1976.
	* taf-kit/src/Makefile.am:
	    Fix CPPFLAGS error introduced in patch 1976.
parent a9b853f0
2008-06-07 Vivien Delmon <vivien.delmon@lrde.epita.fr>
Fix some errors introduced in patch 1976.
* lib/krat_exp/krat_exp_bison.yy:
Adapt structure using PIMPL pattern.
* include/vaucanson/algebra/implementation/series/krat_exp_parser.hxx:
Remove bad include and replaced it by a forward declaration.
* data/automata/b/Makefile.am:
Fix CPPFLAGS error introduced in patch 1976.
* data/automata/tdc/Makefile.am:
Fix CPPFLAGS error introduced in patch 1976.
* data/automata/z/Makefile.am:
Fix CPPFLAGS error introduced in patch 1976.
* lib/generate_libvcsn.rb:
Fix CPPFLAGS error introduced in patch 1976.
* src/tests/sanity/Makefile.am:
Fix CPPFLAGS error introduced in patch 1976.
* src/tests/test-suites/test-suite.mk:
Fix CPPFLAGS error introduced in patch 1976.
* src/tests/xml/Makefile.am:
Fix CPPFLAGS error introduced in patch 1976.
* taf-kit/src/Makefile.am:
Fix CPPFLAGS error introduced in patch 1976.
2008-06-02 Alexandre Duret-Lutz <adl@lrde.epita.fr>
* src/benchs/generate_benchs.sh (EXTRA_DIST): Generate
......
......@@ -25,7 +25,7 @@ dist_b_automata_DATA = \
EXTRA_DIST = $(XML_SAMPLES)
MAINTAINERCLEANFILES = $(dist_b_automata_DATA)
a1_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/lib/krat_exp
a1_CPPFLAGS = $(AM_CPPFLAGS)
a1_LDADD = $(top_builddir)/lib/libkrat_exp.la
a1_SOURCES = a1.cc
......@@ -36,7 +36,7 @@ $(srcdir)/a1.xml: a1.cc $(top_srcdir)/configure.ac
# Accepts words with a `b'.
# See ETA Fig. III.2.3, p. 434.
b1_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/lib/krat_exp
b1_CPPFLAGS = $(AM_CPPFLAGS)
b1_LDADD = $(top_builddir)/lib/libkrat_exp.la
b1_SOURCES = b1.cc
$(srcdir)/b1.xml: b1.cc $(top_srcdir)/configure.ac
......@@ -44,7 +44,7 @@ $(srcdir)/b1.xml: b1.cc $(top_srcdir)/configure.ac
./b1$(EXEEXT) xml >$@.tmp
mv $@.tmp $@
divkbaseb_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/lib/krat_exp
divkbaseb_CPPFLAGS = $(AM_CPPFLAGS)
divkbaseb_LDADD = $(top_builddir)/lib/libkrat_exp.la
divkbaseb_SOURCES = divkbaseb.cc
$(srcdir)/div3base2.xml: divkbaseb.cc $(top_srcdir)/configure.ac
......@@ -52,7 +52,7 @@ $(srcdir)/div3base2.xml: divkbaseb.cc $(top_srcdir)/configure.ac
./divkbaseb$(EXEEXT) 3 2 xml >$@.tmp
mv $@.tmp $@
ladybird_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/lib/krat_exp
ladybird_CPPFLAGS = $(AM_CPPFLAGS)
ladybird_LDADD = $(top_builddir)/lib/libkrat_exp.la
ladybird_SOURCES = ladybird.cc
$(srcdir)/ladybird-6.xml: ladybird.cc $(top_srcdir)/configure.ac
......@@ -60,7 +60,7 @@ $(srcdir)/ladybird-6.xml: ladybird.cc $(top_srcdir)/configure.ac
./ladybird$(EXEEXT) 6 xml >$@.tmp
mv $@.tmp $@
double_ring_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/lib/krat_exp
double_ring_CPPFLAGS = $(AM_CPPFLAGS)
double_ring_LDADD = $(top_builddir)/lib/libkrat_exp.la
double_ring_SOURCES = double_ring.cc
$(srcdir)/double-3-1.xml: double_ring.cc $(top_srcdir)/configure.ac
......
......@@ -22,7 +22,7 @@ dist_tdc_automata_DATA = \
EXTRA_DIST = $(XML_SAMPLES)
MAINTAINERCLEANFILES = $(dist_tdc_automata_DATA)
t1_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/lib/krat_exp
t1_CPPFLAGS = $(AM_CPPFLAGS)
t1_LDADD = $(top_builddir)/lib/libkrat_exp.la
t1_SOURCES = t1.cc
......@@ -31,7 +31,7 @@ $(srcdir)/t1.xml: t1.cc $(top_srcdir)/configure.ac
./t1$(EXEEXT) >$@.tmp
mv $@.tmp $@
u1_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/lib/krat_exp
u1_CPPFLAGS = $(AM_CPPFLAGS)
u1_LDADD = $(top_builddir)/lib/libkrat_exp.la
u1_SOURCES = u1.cc
......
......@@ -27,7 +27,7 @@ $(srcdir)/b1.xml: $(top_srcdir)/data/automata/b/b1.xml
sed -e 's/set="B"/set="Z"/g' $< >$@.tmp
mv $@.tmp $@
c1_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/lib/krat_exp
c1_CPPFLAGS = $(AM_CPPFLAGS)
c1_LDADD = $(top_builddir)/lib/libkrat_exp.la
c1_SOURCES = c1.cc
$(srcdir)/c1.xml: c1.cc $(top_srcdir)/configure.ac
......
......@@ -21,20 +21,34 @@
# include <vector>
# include <map>
# include <queue>
# include <set>
# include <vaucanson/algebra/implementation/series/krat_exp_parser.hh>
# include <krat_exp_bison.tab.hh>
# include <vaucanson/algebra/implementation/series/krat_exp_proxy.hh>
# include <vaucanson/algebra/concept/monoid_base.hh>
# include <vaucanson/misc/usual_escaped_characters.hh>
namespace vcsn
// Declaration to link with libkrat_exp
namespace yy
{
namespace algebra
struct token_queue;
struct krat_exp_parser
{
using namespace yy; // bison doesn't allow me to put my parser in vcsn::algebra
krat_exp_parser();
void insert_word(vcsn::algebra::krat_exp_virtual* rexp);
void insert_weight(vcsn::algebra::semiring_virtual* sem);
void insert_one(vcsn::algebra::krat_exp_virtual* rexp);
void insert_zero(vcsn::algebra::krat_exp_virtual* rexp);
void insert_token(int i, std::string* str);
int parse(vcsn::algebra::krat_exp_virtual& rexp);
typedef std::queue<std::pair<krat_exp_parser::token_type, krat_exp_parser::semantic_type> > tok_queue_t;
// Attributs
token_queue* tok_q_;
}; // krat_exp_parser
} // yy
namespace vcsn
{
namespace algebra
{
template <class S, class T>
struct Lexer
{
......@@ -42,11 +56,11 @@ namespace vcsn
typedef typename Element<S, T>::semiring_elt_t semiring_elt_t;
Lexer(const std::string& from,
Element<S, T>& e,
tok_queue_t& tok_q,
yy::krat_exp_parser& parser,
bool lex_trace) :
from_(from),
e_(e),
tok_q_(tok_q),
parser_(parser),
lex_trace_(lex_trace),
end_weight_("}"),
token_tab_(9)
......@@ -105,10 +119,9 @@ namespace vcsn
std::string::const_iterator sit = s.begin();
if (parse_word(w, s, sit, escaped))
{
krat_exp_parser::semantic_type rexp;
Element<S, T> ww = Element<S, T>(e_.structure(), w.value());
rexp.rexp = new krat_exp_proxy<S, T>(ww);
tok_q_.push(std::make_pair(krat_exp_parser::token::WORD, rexp));
krat_exp_proxy<S, T>* rexp = new krat_exp_proxy<S, T>(ww);
parser_.insert_word(rexp);
}
else
{
......@@ -131,9 +144,8 @@ namespace vcsn
std::string::const_iterator sit = s.begin();
if (parse_weight(w, s, sit))
{
krat_exp_parser::semantic_type rexp;
rexp.sem = new semiring_proxy<S, T>(w);
tok_q_.push(std::make_pair(krat_exp_parser::token::WEIGHT, rexp));
semiring_proxy<S, T>* sem = new semiring_proxy<S, T>(w);
parser_.insert_weight(sem);
}
else
{
......@@ -147,46 +159,29 @@ namespace vcsn
void
insert_token(int i)
{
krat_exp_parser::token_type tmp;
if (i < 4)
if (i < 2)
if (i == 0)
tmp = krat_exp_parser::token::OPAR;
else
tmp = krat_exp_parser::token::CPAR;
else
if (i == 2)
tmp = krat_exp_parser::token::PLUS;
else
tmp = krat_exp_parser::token::TIMES;
else
if (i < 6)
if (i == 4)
tmp = krat_exp_parser::token::STAR;
else
tmp = krat_exp_parser::token::ONE;
else
tmp = krat_exp_parser::token::ZERO;
krat_exp_parser::semantic_type rexp;
if (i == 5)
{
Element<S, T> w = identity_as<T>::of(e_.structure());
rexp.rexp = new krat_exp_proxy<S, T>(w);
krat_exp_proxy<S, T>* rexp = new krat_exp_proxy<S, T>(w);
parser_.insert_one(rexp);
}
else
if (i == 6)
{
Element<S, T> w = zero_as<T>::of(e_.structure());
rexp.rexp = new krat_exp_proxy<S, T>(w);
krat_exp_proxy<S, T>* rexp = new krat_exp_proxy<S, T>(w);
parser_.insert_zero(rexp);
}
else
rexp.str = new std::string(token_tab_[i]);
tok_q_.push(std::make_pair(tmp, rexp));
{
std::string* str = new std::string(token_tab_[i]);
parser_.insert_token(i, str);
}
}
const std::string& from_;
Element<S, T>& e_;
tok_queue_t& tok_q_;
yy::krat_exp_parser& parser_;
bool lex_trace_;
std::string end_weight_;
std::vector<std::string> token_tab_;
......@@ -201,12 +196,11 @@ namespace vcsn
{
parse_trace = parse_trace;
int res;
tok_queue_t tok_q;
Lexer<S, T> lex(from, exp, tok_q, lex_trace);
yy::krat_exp_parser parser;
Lexer<S, T> lex(from, exp, parser, lex_trace);
lex.lex();
krat_exp_proxy<S, T> rexp(exp);
yy::krat_exp_parser parser(tok_q, rexp);
res = parser.parse();
res = parser.parse(rexp);
exp = rexp.self;
return std::make_pair(res, "");
}
......
......@@ -115,7 +115,7 @@ def write_makefile(type, context)
"##",
"",
"lib_LTLIBRARIES\t+= lib" + type + ".la",
"lib" + type.gsub(/-/, "_") + "_la_CXXFLAGS\t= $(CXXFLAGS) -I$(top_srcdir)/lib/krat_exp/ -DVCSN_CONTEXT=" + context,
"lib" + type.gsub(/-/, "_") + "_la_CXXFLAGS\t= $(CXXFLAGS) -DVCSN_CONTEXT=" + context,
"lib" + type.gsub(/-/, "_") + "_la_LIBADD\t= $(LIBOBJS)")
out.print "lib" + type.gsub(/-/, "_") + "_la_SOURCES\t= "
files = Dir.glob(type + "/*cc").sort!
......
%skeleton "lalr1.cc"
%defines
%define "parser_class_name" "krat_exp_parser"
%define "parser_class_name" "krat_exp_bison"
%error-verbose
%{
......@@ -11,9 +11,9 @@
# include <iostream>
%}
%parse-param { std::queue<std::pair<krat_exp_parser::token_type, krat_exp_parser::semantic_type> >& tok_q }
%parse-param { std::queue<std::pair<krat_exp_bison::token_type, krat_exp_bison::semantic_type> >& tok_q }
%parse-param { vcsn::algebra::krat_exp_virtual& exp }
%lex-param { std::queue<std::pair<krat_exp_parser::token_type, krat_exp_parser::semantic_type> >& tok_q }
%lex-param { std::queue<std::pair<krat_exp_bison::token_type, krat_exp_bison::semantic_type> >& tok_q }
%union
{
......@@ -24,8 +24,8 @@
%{
int
yylex(yy::krat_exp_parser::semantic_type* yylval,
std::queue<std::pair<yy::krat_exp_parser::token_type, yy::krat_exp_parser::semantic_type> >& tok_q);
yylex(yy::krat_exp_bison::semantic_type* yylval,
std::queue<std::pair<yy::krat_exp_bison::token_type, yy::krat_exp_bison::semantic_type> >& tok_q);
%}
%token <str> OPAR
......@@ -59,11 +59,11 @@ exp :
;
rexp :
OPAR rexp CPAR {$$ = $2}
| rexp PLUS rexp {$$ = *$1 + $3; delete $1; delete $3}
| rexp TIMES rexp {$$ = *$1 * $3; delete $1; delete $3}
OPAR rexp CPAR {$$ = $2 ; delete $1; delete $3}
| rexp PLUS rexp {$$ = *$1 + $3; delete $1; delete $2; delete $3}
| rexp TIMES rexp {$$ = *$1 * $3; delete $1; delete $2; delete $3}
| rexp rexp %prec TIMES2{$$ = *$1 * $2; delete $1; delete $2}
| rexp STAR {$1->star(); $$ = $1}
| rexp STAR {$1->star(); $$ = $1; delete $2}
| WEIGHT rexp %prec LPROD {$2->left_weight($1); delete $1; $$ = $2}
| rexp WEIGHT {$1->right_weight($2); delete $2;$$ = $1}
| ONE {$$ = $1}
......@@ -73,11 +73,112 @@ rexp :
%%
namespace yy
{
struct token_queue
{
std::queue
<
std::pair
<
krat_exp_bison::token_type,
krat_exp_bison::semantic_type
>
> self;
};
struct krat_exp_parser
{
krat_exp_parser();
void insert_word(vcsn::algebra::krat_exp_virtual* rexp);
void insert_weight(vcsn::algebra::semiring_virtual* sem);
void insert_one(vcsn::algebra::krat_exp_virtual* rexp);
void insert_zero(vcsn::algebra::krat_exp_virtual* rexp);
void insert_token(int i, std::string* str);
int parse(vcsn::algebra::krat_exp_virtual& rexp);
// Attributs
token_queue* tok_q_;
}; // krat_exp_parser
} // yy
yy::krat_exp_parser::krat_exp_parser()
{
tok_q_ = new token_queue;
}
void
yy::krat_exp_parser::insert_word(vcsn::algebra::krat_exp_virtual* rexp)
{
krat_exp_bison::semantic_type tmp;
tmp.rexp = rexp;
tok_q_->self.push(std::make_pair(krat_exp_bison::token::WORD, tmp));
}
void
yy::krat_exp_parser::insert_weight(vcsn::algebra::semiring_virtual* sem)
{
krat_exp_bison::semantic_type tmp;
tmp.sem = sem;
tok_q_->self.push(std::make_pair(krat_exp_bison::token::WEIGHT, tmp));
}
void
yy::krat_exp_parser::insert_one(vcsn::algebra::krat_exp_virtual* rexp)
{
krat_exp_bison::semantic_type tmp;
tmp.rexp = rexp;
tok_q_->self.push(std::make_pair(krat_exp_bison::token::ONE, tmp));
}
void
yy::krat_exp_parser::insert_zero(vcsn::algebra::krat_exp_virtual* rexp)
{
krat_exp_bison::semantic_type tmp;
tmp.rexp = rexp;
tok_q_->self.push(std::make_pair(krat_exp_bison::token::ZERO, tmp));
}
void
yy::krat_exp_parser::insert_token(int i, std::string* str)
{
krat_exp_bison::semantic_type tmp;
tmp.str = str;
switch (i)
{
case 0 :
tok_q_->self.push(std::make_pair(krat_exp_bison::token::OPAR, tmp));
break;
case 1 :
tok_q_->self.push(std::make_pair(krat_exp_bison::token::CPAR, tmp));
break;
case 2 :
tok_q_->self.push(std::make_pair(krat_exp_bison::token::PLUS, tmp));
break;
case 3 :
tok_q_->self.push(std::make_pair(krat_exp_bison::token::TIMES, tmp));
break;
case 4 :
tok_q_->self.push(std::make_pair(krat_exp_bison::token::STAR, tmp));
break;
default : // this sted should never append
std::cout << "Error in insert_token" << std::endl;
break;
}
}
int
yy::krat_exp_parser::parse(vcsn::algebra::krat_exp_virtual& rexp_)
{
yy::krat_exp_bison parser(tok_q_->self , rexp_);
return parser.parse();
}
int
yylex(yy::krat_exp_parser::semantic_type* yylval,
std::queue<std::pair<yy::krat_exp_parser::token_type, yy::krat_exp_parser::semantic_type> >& tok_q)
yylex(yy::krat_exp_bison::semantic_type* yylval,
std::queue<std::pair<yy::krat_exp_bison::token_type, yy::krat_exp_bison::semantic_type> >& tok_q)
{
yy::krat_exp_parser::token_type res;
yy::krat_exp_bison::token_type res;
if (tok_q.empty())
return 0;
else
......@@ -90,7 +191,7 @@ yylex(yy::krat_exp_parser::semantic_type* yylval,
}
void
yy::krat_exp_parser::error(const yy::krat_exp_parser::location_type& loc, const std::string& s)
yy::krat_exp_bison::error(const yy::krat_exp_bison::location_type& loc, const std::string& s)
{
std::cout << s << std::endl;
}
......@@ -14,7 +14,7 @@
EXTRA_DIST = generate_files.sh hhck.pl
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include \
-I$(top_srcdir)/lib/krat_exp -DVCSN_SANITY_CHECK
-DVCSN_SANITY_CHECK
AM_CXXFLAGS = $(CXXFLAGS_STRICT)
# Currently files are generated in srcdir, they should be in builddir,
......
......@@ -17,8 +17,8 @@ include $(top_srcdir)/src/tests/check/check.mk
TESTS += failcomp.sh
EXTRA_DIST = failcomp.sh
AM_CPPFLAGS += -DEXCEPTION_TRAPS -DVCSN_SRC_DIR=\"'$(top_srcdir)'\" \
-I$(top_srcdir)/lib/krat_exp
AM_CPPFLAGS += -DEXCEPTION_TRAPS -DVCSN_SRC_DIR=\"'$(top_srcdir)'\"
LDADD += $(top_builddir)/lib/libkrat_exp.la
TESTS_ENVIRONMENT = CXX="$(CXX)" \
......
......@@ -14,7 +14,7 @@
include $(top_srcdir)/vaucanson.mk
include $(top_srcdir)/build-aux/check.mk
AM_CPPFLAGS += $(XSD_CPPFLAGS) -I$(top_srcdir)/lib/krat_exp
AM_CPPFLAGS += $(XSD_CPPFLAGS)
LDADD = $(top_builddir)/lib/libkrat_exp.la
TESTS_ENVIRONMENT = srcdir=$(srcdir)
......
......@@ -43,25 +43,28 @@ COMMON_SOURCES = commands.hh \
vcsn_b_SOURCES = $(COMMON_SOURCES) \
ratexp_commands.hh common_automaton_commands.hh b_commands.cc
vcsn_b_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/lib/krat_exp \
vcsn_b_CPPFLAGS = $(AM_CPPFLAGS) \
-DCONTEXT=boolean_automaton -DVCSN_USE_LIB
vcsn_b_LDADD = $(top_builddir)/lib/libvcsn-b.la \
vcsn_b_LDADD = $(LDADD) \
$(top_builddir)/lib/libvcsn-b.la \
$(top_builddir)/lib/libkrat_exp.la
vcsn_z_SOURCES = $(COMMON_SOURCES) \
ratexp_commands.hh common_automaton_commands.hh z_commands.cc
vcsn_z_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/lib/krat_exp \
vcsn_z_CPPFLAGS = $(AM_CPPFLAGS) \
-DCONTEXT=z_automaton -DVCSN_USE_LIB
vcsn_z_LDADD = $(top_builddir)/lib/libvcsn-z.la \
vcsn_z_LDADD = $(LDADD) \
$(top_builddir)/lib/libvcsn-z.la \
$(top_builddir)/lib/libkrat_exp.la
vcsn_tdc_SOURCES = $(COMMON_SOURCES) \
tdc_commands.cc
#vcsn_tdc_CPPFLAGS = $(AM_CPPFLAGS) -DCONTEXT=fmp_transducer \
# -DWITH_TWO_ALPHABETS -DVCSN_USE_LIB
vcsn_tdc_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/lib/krat_exp \
vcsn_tdc_CPPFLAGS = $(AM_CPPFLAGS) \
-DCONTEXT=fmp_transducer -DWITH_TWO_ALPHABETS
vcsn_tdc_LDADD = $(top_builddir)/lib/libvcsn-tdc.la \
vcsn_tdc_LDADD = $(LDADD) \
$(top_builddir)/lib/libvcsn-tdc.la \
$(top_builddir)/lib/libkrat_exp.la
......
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