Index: app/src/dgp/const.hh
===================================================================
--- app/src/dgp/const.hh	(revision 0214596e4d70b25df913a24f19d50cb0f1b4a69f)
+++ app/src/dgp/const.hh	(revision 9ace5d204d63628901f9f128d3f99ce5f7c973c0)
@@ -3,4 +3,5 @@
 
 #define MAXTYPES 32
+#define MAXFLAGS 64
 #define MAXNODES 1024
 #define MAXCONSTRS 32
Index: app/src/dgp/dgc
===================================================================
--- app/src/dgp/dgc	(revision 3748bd1db46143a281581cb44dc804da0190cbc2)
+++ app/src/dgp/dgc	(revision 9ace5d204d63628901f9f128d3f99ce5f7c973c0)
@@ -98,4 +98,5 @@
 my $nreq=0;
 my $nlink=0;
+my $nflag=0;
 
 my %cats;
@@ -113,5 +114,4 @@
 	open(OUTPUT, ">$outputfile") or die("Can't open output file: $outputfile!");
 }
-
 
 
@@ -192,4 +192,9 @@
 	    }
 	}
+    }
+    elsif(/^FLAG\s+\S+$/)
+    {
+	++$nflag;
+	print OUTPUT "$_\n"
     }
     elsif(/^$/) {
@@ -249,4 +254,5 @@
 printf STDERR "%6d RIGHT statements\n", $nright;
 printf STDERR "%6d LINK  statements\n", $nlink;
+printf STDERR "%6d FLAG  statements\n", $nflag;
 
 
Index: app/src/dgp/grammar.cc
===================================================================
--- app/src/dgp/grammar.cc	(revision 0214596e4d70b25df913a24f19d50cb0f1b4a69f)
+++ app/src/dgp/grammar.cc	(revision 9ace5d204d63628901f9f128d3f99ce5f7c973c0)
@@ -44,4 +44,14 @@
     lt.resize(types_sz);
     gt.resize(types_sz);
+  }
+}
+
+void Grammar::add_flag(const char* s)
+{  
+  Flag::add(s);
+  if(Flag::count()>flags_sz)
+  {
+    flags_sz += 16;
+    pass.resize(flags_sz);
   }
 }
@@ -124,4 +134,9 @@
         set_connect(arg1,arg2,arg3);
     }
+    // FLAG DECLARATION
+    else if(strcmp(key,"FLAG")==0 && fields>=2)
+    { 
+      add_flag(arg1);
+    }
 
     else fprintf(stderr,"Invalid line %d. Ignored.\n", lineno);
@@ -160,4 +175,7 @@
 	if(connect[c][d].count(t))
           fprintf(f,"LINK\t%s\t%s\t%s\n",c.str(),d.str(),t.str());
+
+  for(Flag i=1; i<Flag::count(); ++i)
+    fprintf(f,"FLAG\t%s\n",i.str());
 }
 
Index: app/src/dgp/grammar.hh
===================================================================
--- app/src/dgp/grammar.hh	(revision 3748bd1db46143a281581cb44dc804da0190cbc2)
+++ app/src/dgp/grammar.hh	(revision 9ace5d204d63628901f9f128d3f99ce5f7c973c0)
@@ -11,4 +11,13 @@
 #include "sgraph.hh"
 
+
+class Link
+{
+  Role role;
+  FlagSet hflags;
+  FlagSet dflags;
+}
+
+
 class Grammar
 {
@@ -18,8 +27,9 @@
   //  enum CONSTR { SGL, OBL, LEFT, RIGHT, INIT, NONINIT, FIN, NONFIN };
 
-  Grammar() : types_sz(0), cats_sz(0) {} ;
+  Grammar() : types_sz(0), cats_sz(0), flags_sz(0) {} ;
   
   int types_sz;
   int cats_sz;
+  int flags_sz;
 
   vector< vector< Roles > >    connect;
@@ -31,4 +41,9 @@
   vector< RoleSet >            gt;
 
+
+  //  vector< vector< vector<
+  vector< FlagSet >            set;
+  vector< FlagSet >            pass;
+
   bool read(FILE* f);
   void write(FILE* f);
@@ -36,4 +51,5 @@
   void add_category(const char* s);
   void add_type(const char* s);
+  void add_flag(const char* s);
 
   void set_sgl(Role r)           { sgl.set(r); }
Index: app/src/dgp/sgraph.cc
===================================================================
--- app/src/dgp/sgraph.cc	(revision 0214596e4d70b25df913a24f19d50cb0f1b4a69f)
+++ app/src/dgp/sgraph.cc	(revision 9ace5d204d63628901f9f128d3f99ce5f7c973c0)
@@ -128,8 +128,9 @@
   {
     buf+=sprintf(buf,";");
+    int cont=0;
     for(Role i=1; i<=Role::count(); ++i)
-      if(node.prop.forbidden[i]) buf+=sprintf(buf,"!%s",i.str());
+      if(node.prop.forbidden[i]) buf+=sprintf(buf,"%s!%s",(cont++)?",":"",i.str());
     for(Role i=1; i<=Role::count(); ++i)
-      if(node.prop.required[i]) buf+=sprintf(buf,"&%s",i.str());
+      if(node.prop.required[i]) buf+=sprintf(buf,"%s&%s",(cont++)?",":"",i.str());
   }
   
@@ -140,5 +141,5 @@
 
 
-int SGraph::sprint_node_debug(char* buf, char* pref, int n)
+int SGraph::sprint_node_debug(char* buf, const char* pref, int n)
 {
   char *buf0 = buf;
@@ -149,5 +150,5 @@
 }
 
-int SGraph::print_node_debug(FILE* f, char* pref, int n)
+int SGraph::print_node_debug(FILE* f, const char* pref, int n)
 {
   char buf[1000];
Index: app/src/dgp/sgraph.hh
===================================================================
--- app/src/dgp/sgraph.hh	(revision 0214596e4d70b25df913a24f19d50cb0f1b4a69f)
+++ app/src/dgp/sgraph.hh	(revision 9ace5d204d63628901f9f128d3f99ce5f7c973c0)
@@ -88,6 +88,6 @@
   int sprint_node(char* buf, int n, unsigned int info);
   int print_node(FILE* f, int n, unsigned int info);
-  int sprint_node_debug(char* buf, char* pref, int n);
-  int print_node_debug(FILE* f, char* pref, int n);
+  int sprint_node_debug(char* buf, const char* pref, int n);
+  int print_node_debug(FILE* f, const char* pref, int n);
 
   void print_arc(FILE* f, int left, int right, Role role, int dir); // 0 - left, 1 - right
Index: app/src/dgp/thesymbols.hh
===================================================================
--- app/src/dgp/thesymbols.hh	(revision 0214596e4d70b25df913a24f19d50cb0f1b4a69f)
+++ app/src/dgp/thesymbols.hh	(revision 9ace5d204d63628901f9f128d3f99ce5f7c973c0)
@@ -23,5 +23,7 @@
 
 typedef Symbol<4> Rel;
+
 typedef Symbol<5> Flag;
+typedef bitset<MAXFLAGS> FlagSet;
 
 #endif
