some unnecessary variables/functions deleted

This commit is contained in:
Tomasz Obrebski 2014-10-24 13:07:15 +02:00
parent 56c300bb33
commit d484a3254b
7 changed files with 38 additions and 62 deletions

View File

@ -10,7 +10,7 @@ CMDLINE_FILE='"../dgp/cmdline.h"'
#vpath %.o .
CXXFLAGS = -g -static
CXXFLAGS = -g -Wno-deprecated -static
sources = main.cc grammar.cc symbol.cc mgraph.cc sgraph.cc dgp1.cc cmdline.cc \
$(COMMON_PATH)/common.cc global.cc
@ -46,6 +46,7 @@ cmdline.ggo: cmdline_dgp.ggo ../common/cmdline_common.ggo
clean:
rm -f ${bin} ${objs} cmdline.*
rm -f *.d
rm -f *~
.PHONY: prof
prof: dgp

View File

@ -81,11 +81,11 @@ int find_existing_node(int mnodeind, NodeProp p, bitset<MAXNODES>& newheadLH, bi
if(sgraph[*ps].LH==newheadLH && sgraph[*ps].LV==newheadLV)
{
ret = *ps;
fprintf(stderr,"#\tsucceeded because of LH/LV equality ()\n");
if(debug) fprintf(stderr,"#\tsucceeded because of LH/LV equality ()\n");
}
else
{
fprintf(stderr,"#\tfailed beacause of LH/LV inequality\n");
if(debug) fprintf(stderr,"#\tfailed beacause of LH/LV inequality\n");
}
}
@ -516,6 +516,7 @@ void try_connect_dependents(int j)
{
if(debug) fprintf(stderr," ...SUCCESS!\n");
connect_left( j, i, **ri, new_head_boubbles, new_dep_boubbles);
lvi.update_edge(sgraph,i);
}
else
{ if(debug) fprintf(stderr," ...boubbles failed\n"); }

View File

@ -30,12 +30,12 @@ void Grammar::add_category(const char* s)
{
Cat::add(s);
if(connect.size() <= Cat::count())
{
connect.resize(Cat::count()+RESIZE_DELTA);
for(int i=0; i<connect.size(); ++i)
if(connect[i].size() <= Cat::count()) connect[i].resize(Cat::count()+RESIZE_DELTA);
}
// if(connect.size() <= Cat::count())
// {
// connect.resize(Cat::count()+RESIZE_DELTA);
// for(int i=0; i<connect.size(); ++i)
// if(connect[i].size() <= Cat::count()) connect[i].resize(Cat::count()+RESIZE_DELTA);
// }
if(connect1.size() <= Cat::count())
{
connect1.resize(Cat::count()+RESIZE_DELTA);
@ -330,7 +330,7 @@ bool Grammar::read(FILE* f)
// printf("line=%s\n\tcat1=<%s> flags1=%s cat2=<%s> flags2=%s type=<%s> props=%s\n",line,cat1,flags1,cat2,flags2,type,props);
if( chk_cat(cat1) && chk_cat(cat2) && chk_type(type) )
set_connect(cat1,parse_flags(flags1,"+"),parse_flags(flags1,"-"),cat2,parse_flags(flags2,"+"),parse_flags(flags2,"-"),type,parse_props(props));
set_connect(cat1,parse_flags(flags1,"+"),parse_flags(flags1,"-"),cat2,parse_flags(flags2,"+"),parse_flags(flags2,"-"),type,parse_props(props),lineno);
else if( chk_cat(cat1) && chk_cat(cat2) && chk_long(type) )
{
set_longrel(cat1,cat2,type);
@ -503,11 +503,11 @@ void Grammar::write(FILE* f)
for(Role r=1; r<Role::count(); ++r)
if(obl[c].test(r)) fprintf(f,"REQ\t%s\t%s\n",c.str(),r.str());
for(Cat c=1; c<Cat::count(); ++c)
for(Cat d=1; d<Cat::count(); ++d)
for(Role t=1; t<Role::count(); ++t)
if(connect[c][d].count(t))
fprintf(f,"LINK\t%s\t%s\t%s\n",c.str(),d.str(),t.str());
// for(Cat c=1; c<Cat::count(); ++c)
// for(Cat d=1; d<Cat::count(); ++d)
// for(Role t=1; t<Role::count(); ++t)
// if(connect[c][d].count(t))
// fprintf(f,"LINK\t%s\t%s\t%s\n",c.str(),d.str(),t.str());
for(LongRel i=1; i<LongRel::count(); ++i)
fprintf(f,"LONG\t%s\n",i.str());

View File

@ -26,8 +26,8 @@ const FlagSet EmptyFlagSet = FlagSet();
struct Link
{
Link(Role r, Flag dfplus="NULL", Flag dfminus="NULL") : role(r), dflagplus(dfplus), dflagminus(dfminus) { }
Link(Role r, PropSet ps=EmptyPropSet, Flag hfp="NULL", Flag hfm="NULL", Flag dfp="NULL", Flag dfm="NULL")
// Link(Role r, Flag dfplus="NULL", Flag dfminus="NULL") : role(r), dflagplus(dfplus), dflagminus(dfminus) { }
Link(Role r, PropSet ps=EmptyPropSet, Flag hfp="NULL", Flag hfm="NULL", Flag dfp="NULL", Flag dfm="NULL", int lineno=0)
: role(r), props(ps), hflagplus(hfp), hflagminus(hfm), dflagplus(dfp), dflagminus(dfm) { }
//Link(Role r) : role(r), dflagplus("NULL") { }
@ -37,6 +37,7 @@ struct Link
Flag dflagplus;
Flag dflagminus;
PropSet props;
int lineno;
bool operator<(const Link& l) const
{
@ -66,9 +67,6 @@ class Grammar
Grammar() {} ;
Roles& connectable(Cat h, Cat d);
Roles connectable(Cat h, Cat d, FlagSet f, FlagSet df);
list<const Link*> connectable2(Cat h, Cat d, FlagSet hfs, FlagSet dfs);
bool check_constr(NodeProp& hprop, NodeProp& dprop, int dir, Role role);
@ -108,7 +106,7 @@ private:
// vector< FlagSet > rset; //[Role]
vector< FlagSet > pass; //[Role]
vector< vector< Roles > > connect; //[Cat][Cat]
// vector< vector< Roles > > connect; //[Cat][Cat]
vector< vector< Links > > connect1; //[Cat][Cat]
@ -142,7 +140,7 @@ private:
// void set_connect(Cat c, Cat d, Role r) { connect[c][d].insert(r); }
// void set_connect(Cat c, Cat d, Flag f, Role r) { connect1[c][d].insert(Link(r,f)); }
void set_connect(Cat h, Flag hfp, Flag hfm, Cat d, Flag dfp, Flag dfm, Role r, PropSet ps ) { connect1[h][d].insert(Link(r,ps,hfp,hfm,dfp,dfm)); }
void set_connect(Cat h, Flag hfp, Flag hfm, Cat d, Flag dfp, Flag dfm, Role r, PropSet ps, int lineno ) { connect1[h][d].insert(Link(r,ps,hfp,hfm,dfp,dfm,lineno)); }
void set_include(Role r, Role s) { include[r].set(s); }
void set_exclude(Role r, Role s) { exclude[r].set(s); }
@ -158,27 +156,6 @@ private:
//----------------------------------------------------------------------------------------------------
inline
Roles& Grammar::connectable(Cat h, Cat d)
{
return connect[h][d];
}
//----------------------------------------------------------------------------------------------------
inline
Roles Grammar::connectable(Cat h, Cat d, FlagSet hfs, FlagSet dfs) // ZBYT WOLNE!!!!!!!!!!!!!!!!!!!!!!!!!! (-> Roles&)
{
Roles ret;
for(Links::const_iterator l = connect1[h][d].begin(); l != connect1[h][d].end(); l++)
if( (l->hflagplus==0 || hfs[l->hflagplus]) && (l->hflagminus==0 || !hfs[l->hflagminus]) )
if( (l->dflagplus==0 || dfs[l->dflagplus]) && (l->dflagminus==0 || !dfs[l->dflagminus]) )
ret.insert(l->role);
return ret;
}
//----------------------------------------------------------------------------------------------------
inline
list<const Link*> Grammar::connectable2(Cat h, Cat d, FlagSet hfs, FlagSet dfs) // ZBYT WOLNE!!!!!!!!!!!!!!!!!!!!!!!!!! (-> Roles&)
{
@ -192,20 +169,6 @@ list<const Link*> Grammar::connectable2(Cat h, Cat d, FlagSet hfs, FlagSet dfs)
//----------------------------------------------------------------------------------------------------
// inline
// bool Grammar::check_constr(NodeProp& hprop, NodeProp& dprop, int dir, Role role) // dir: 0-left 1-right
// {
// return
// !hprop.forbidden[role] &&
// ( dir==1 || !right[role] ) &&
// ( dir==0 || !left[role] ) &&
// ( dir==1 || (hprop.attached&init).none() ) &&
// ( dir==0 || (hprop.attached&fin).none() )
// ;
// }
//----------------------------------------------------------------------------------------------------
inline
bool Grammar::check_constr2(NodeProp& hprop, NodeProp& dprop, int dir, const Link& link) // dir: 0-left 1-right
{

View File

@ -178,9 +178,9 @@ int SGraph::sprint_node_debug(char* buf, const char* pref, int n, int anc)
while(buf-buf0<40) buf+=sprintf(buf," ");
buf+=sprint_node(buf,n,anc,HEADS|DEPS|SETS|CONSTRAINTS);
// buf+=sprintf(buf,"/");
// for(vector<int>::iterator e = nodes[n].edge.begin(); e != nodes[n].edge.end(); e++ )
// buf += sprintf(buf,"%d ", *e);
buf+=sprintf(buf,"/");
for(vector<int>::iterator e = nodes[n].edge.begin(); e != nodes[n].edge.end(); e++ )
buf += sprintf(buf,"%d ", *e);
buf+=sprintf(buf,"\n");
return buf-buf0;

View File

@ -295,6 +295,7 @@ class LViterator : public XXiterator
public:
LViterator(SGraph& sg, int n, bool s);
int next();
void update_edge(SGraph& sg, int e);
private:
@ -307,6 +308,7 @@ private:
void push_ld(int i);
void push_lh(int i);
void push_ln(int i);
};
inline LViterator::LViterator(SGraph& sg, int n, bool s=true) : sgraph(sg), mgraph(sg.mgraph), strict(s)
@ -328,6 +330,15 @@ inline LViterator::LViterator(SGraph& sg, int n, bool s=true) : sgraph(sg), mgra
}
}
inline void LViterator::update_edge(SGraph& sg, int n)
{
for(vector<int>::iterator i=sg[n].edge.begin(); i!=sg[n].edge.end(); ++i)
{
push_ld(*i);
push_ln(*i);
}
}
inline int LViterator::next()
{
if(wayup.empty())

View File

@ -17,8 +17,8 @@ typedef Symbol<2> Role;
typedef list<Role> RoleList;
typedef list<Role>::iterator RoleListIter;
typedef bitset<MAXTYPES> RoleSet;
typedef set<Role> Roles;
typedef Roles::iterator RolesIter;
// typedef set<Role> Roles;
// typedef Roles::iterator RolesIter;
typedef Symbol<3> Constr;
typedef list<Constr> ConstrList;