]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/metadata/create_V7_mowgli/METADATA/lex.yy.c
New metadata for sort and rel.
[helm.git] / helm / metadata / create_V7_mowgli / METADATA / lex.yy.c
index 2931c7406160f0812f2585a68d87bc2f37c2daf6..a2f806d52914f354f86d1fd8387762dbbaba74d6 100644 (file)
@@ -290,22 +290,24 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
        *yy_cp = '\0'; \
        yy_c_buf_p = yy_cp;
 
-#define YY_NUM_RULES 20
-#define YY_END_OF_BUFFER 21
-static yyconst short int yy_accept[110] =
+#define YY_NUM_RULES 21
+#define YY_END_OF_BUFFER 22
+static yyconst short int yy_accept[123] =
     {   0,
-        0,    0,   21,    7,    7,    7,    7,    0,    0,    0,
+        0,    0,   22,    7,    7,    7,    7,    0,    0,    0,
         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-        0,    0,    0,    0,   11,    0,    0,    9,   13,    0,
-        0,    4,    0,    0,    0,    0,    0,    6,    0,    0,
-        0,    0,    0,    0,    3,    0,    0,    0,    0,    0,
-       12,   14,    0,    0,    0,    0,    0,    0,    0,   17,
-        0,    5,    8,    0,    0,   15,    0,    0,    0,    0,
-        0,   10,    0,    0,    0,    0,    0,    0,    0,    0,
-       18,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-
-       19,    2,    0,    0,   16,    0,    0,    1,    0
+        0,    0,    0,    0,    0,    0,   10,    0,    0,   12,
+        0,   14,    0,    0,    4,    0,    0,    0,    0,    0,
+        6,    0,    0,    0,    0,    0,    0,    0,    3,    0,
+        0,    0,    0,    0,   11,   15,    0,    0,    0,    0,
+        0,    0,    0,    0,   18,    0,    5,    8,    0,    0,
+       16,    0,    0,    0,    0,    0,    0,    9,    0,    0,
+        0,    0,    0,    0,    0,    0,    0,    0,   19,    0,
+
+        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+       20,    2,    0,    0,    0,   17,    0,    0,   13,    0,
+        1,    0
     } ;
 
 static yyconst int yy_ec[256] =
@@ -322,8 +324,8 @@ static yyconst int yy_ec[256] =
         1,    1,    1,    1,    1,    1,   27,   28,   29,   30,
 
        31,   32,    1,    1,   33,    1,    1,   34,    1,   35,
-       36,   37,    1,   38,   39,   40,   41,    1,    1,    1,
-       42,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+       36,   37,    1,   38,   39,   40,   41,   42,    1,    1,
+       43,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -340,93 +342,101 @@ static yyconst int yy_ec[256] =
         1,    1,    1,    1,    1
     } ;
 
-static yyconst int yy_meta[43] =
+static yyconst int yy_meta[44] =
     {   0,
         1,    1,    1,    2,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1
+        1,    1,    1
     } ;
 
-static yyconst short int yy_base[113] =
+static yyconst short int yy_base[127] =
     {   0,
-        0,    1,  136,  137,   38,   99,   96,    0,  113,  116,
-      121,  106,  115,    0,   97,    0,   94,   90,   94,    0,
-       98,  105,   99,  104,   99,   81,    0,   82,   75,  108,
-       85,    2,   98,   91,  137,  101,    1,  137,  137,   78,
-       76,  137,   74,   71,  103,   64,   71,  137,   78,   80,
-       89,    1,   82,   73,  137,   60,   67,    0,   88,   87,
-      137,  137,   85,   72,   74,   79,   63,   50,   81,    0,
-        2,  137,  137,   74,   65,  137,   52,   47,   80,   37,
-       43,  137,   59,   50,   72,   73,   36,   56,   67,   71,
-       68,   36,   43,   57,   44,   59,   33,   49,   55,   32,
-
-       48,  137,   29,   13,  137,   18,    3,  137,  137,   68,
-        0,   70
+        0,    1,  152,  153,   38,  115,  112,    0,  129,  132,
+      137,  122,  131,  124,    0,  112,    0,  109,  105,  109,
+        0,  113,  120,  114,  119,  114,  113,   95,    0,   96,
+       88,  122,   99,    2,  112,  105,  153,  115,    1,  153,
+      102,  153,   91,   89,  153,   87,   84,  116,   76,   84,
+      153,   91,   93,  102,    1,   95,    0,   86,  153,   73,
+       80,    0,  101,  100,  153,  153,   98,   85,   87,   92,
+        2,   76,   63,   94,    0,   44,  153,  153,   87,   78,
+      153,   72,   64,   59,   92,   55,   55,  153,   71,   59,
+       61,   83,   84,   46,   67,   46,   77,   81,   78,   46,
+
+       58,   50,   71,   62,   73,   47,   65,   68,   64,   42,
+       55,  153,   31,   48,   13,  153,    0,   18,    0,    2,
+      153,  153,   71,    5,   73,    0
     } ;
 
-static yyconst short int yy_def[113] =
+static yyconst short int yy_def[127] =
     {   0,
-      110,  110,  109,  109,  109,  109,  109,  109,  109,  109,
-      109,  109,  109,  109,  109,  109,  109,  109,  109,  109,
-      109,  109,  109,  109,  109,  109,  109,  109,  109,  109,
-      109,  109,  109,  109,  109,  109,  109,  109,  109,  109,
-      109,  109,  109,  109,  109,  109,  109,  109,  109,  109,
-      109,  109,  109,  109,  109,  109,  109,  111,  109,  109,
-      109,  109,  109,  109,  109,  109,  109,  109,  109,  111,
-      109,  109,  109,  109,  109,  109,  109,  109,  109,  109,
-      109,  109,  109,  109,  109,  109,  109,  109,  112,  109,
-      109,  109,  109,  112,  109,  109,  109,  109,  109,  109,
-
-      109,  109,  109,  109,  109,  109,  109,  109,    0,  109,
-      109,  109
+      123,  123,  122,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122,  122,  122,  122,  122,
+      122,  124,  122,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  124,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122,  125,  122,  122,  122,
+
+      122,  122,  125,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122,  126,  122,  126,  122,
+      122,    0,  122,  122,  122,  122
     } ;
 
-static yyconst short int yy_nxt[180] =
+static yyconst short int yy_nxt[197] =
     {   0,
-       70,  109,  109,   80,   80,  109,    5,    5,   81,   25,
-       64,   28,   52,  109,   33,  109,   53,  109,   34,  109,
-       65,  109,   29,  109,  109,  109,   26,   18,   41,   19,
-       47,   42,  109,   48,    6,    6,  109,  109,   80,   80,
-        7,    7,    8,   81,  108,   99,   99,  107,  106,    9,
-      100,  105,   10,  101,   11,   12,   99,   99,   13,  104,
-      103,  100,   14,  102,  101,   95,   98,   15,    4,    4,
-       94,   94,   97,   91,   96,   95,   93,   92,   91,   90,
-       89,   88,   87,   86,   85,   84,   83,   82,   79,   78,
-       77,   76,   75,   74,   73,   72,   71,   69,   68,   67,
-
-       66,   63,   62,   61,   60,   59,   58,   57,   56,   55,
-       54,   51,   50,   49,   46,   45,   44,   43,   40,   39,
-       38,   37,   36,   35,   32,   31,   30,   27,   24,   23,
-       22,   21,   20,   17,   16,  109,    3,  109,  109,  109,
-      109,  109,  109,  109,  109,  109,  109,  109,  109,  109,
-      109,  109,  109,  109,  109,  109,  109,  109,  109,  109,
-      109,  109,  109,  109,  109,  109,  109,  109,  109,  109,
-      109,  109,  109,  109,  109,  109,  109,  109,  109
+      119,   71,   71,   71,   71,   75,    5,    5,  122,   27,
+       68,   30,   55,  122,   35,  122,   56,  122,   36,  122,
+       69,  122,   31,  122,  122,  122,   28,   19,   44,   20,
+       50,   45,  122,   51,    6,    6,  122,  122,  122,  122,
+        7,    7,    8,   82,  121,   86,   86,  120,  118,    9,
+       87,  117,   10,  116,   11,   12,   86,   86,   13,   14,
+      111,   87,   15,  109,  109,  109,  109,   16,  110,  115,
+      110,    4,    4,  103,  103,  114,  113,  112,  111,  104,
+      108,  107,  106,   99,  105,  104,  102,  101,  100,   99,
+       98,   97,   96,   95,   94,   93,   92,   91,   90,   89,
+
+       88,   85,   84,   83,   81,   80,   79,   78,   77,   76,
+       74,   73,   72,   70,   67,   66,   65,   64,   63,   62,
+       61,   60,   59,   58,   57,   54,   53,   52,   49,   48,
+       47,   46,   43,   42,   41,   40,   39,   38,   37,   34,
+       33,   32,   29,   26,   25,   24,   23,   22,   21,   18,
+       17,  122,    3,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122
+
     } ;
 
-static yyconst short int yy_chk[180] =
+static yyconst short int yy_chk[197] =
     {   0,
-      111,    0,    0,   71,   71,    0,    1,    2,   71,   14,
-       52,   16,   37,    0,   20,    0,   37,    0,   20,    0,
-       52,    0,   16,    0,    0,    0,   14,    8,   27,    8,
-       32,   27,    0,   32,    1,    2,    0,    0,   80,   80,
-        1,    2,    5,   80,  107,   95,   95,  106,  104,    5,
-       95,  103,    5,  101,    5,    5,   99,   99,    5,  100,
-       98,   99,    5,   97,   96,   94,   93,    5,  110,  110,
-      112,  112,   92,   91,   90,   89,   88,   87,   86,   85,
-       84,   83,   81,   79,   78,   77,   75,   74,   69,   68,
-       67,   66,   65,   64,   63,   60,   59,   57,   56,   54,
-
-       53,   51,   50,   49,   47,   46,   45,   44,   43,   41,
-       40,   36,   34,   33,   31,   30,   29,   28,   26,   25,
-       24,   23,   22,   21,   19,   18,   17,   15,   13,   12,
-       11,   10,    9,    7,    6,    3,  109,  109,  109,  109,
-      109,  109,  109,  109,  109,  109,  109,  109,  109,  109,
-      109,  109,  109,  109,  109,  109,  109,  109,  109,  109,
-      109,  109,  109,  109,  109,  109,  109,  109,  109,  109,
-      109,  109,  109,  109,  109,  109,  109,  109,  109
+      126,   57,   57,   71,   71,  124,    1,    2,    0,   15,
+       55,   17,   39,    0,   21,    0,   39,    0,   21,    0,
+       55,    0,   17,    0,    0,    0,   15,    8,   29,    8,
+       34,   29,    0,   34,    1,    2,    0,    0,    0,    0,
+        1,    2,    5,   71,  120,   76,   76,  118,  115,    5,
+       76,  114,    5,  113,    5,    5,   86,   86,    5,    5,
+      111,   86,    5,  104,  104,  109,  109,    5,  104,  110,
+      109,  123,  123,  125,  125,  108,  107,  106,  105,  103,
+      102,  101,  100,   99,   98,   97,   96,   95,   94,   93,
+       92,   91,   90,   89,   87,   85,   84,   83,   82,   80,
+
+       79,   74,   73,   72,   70,   69,   68,   67,   64,   63,
+       61,   60,   58,   56,   54,   53,   52,   50,   49,   48,
+       47,   46,   44,   43,   41,   38,   36,   35,   33,   32,
+       31,   30,   28,   27,   26,   25,   24,   23,   22,   20,
+       19,   18,   16,   14,   13,   12,   11,   10,    9,    7,
+        6,    3,  122,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122,  122,  122,  122,  122,
+      122,  122,  122,  122,  122,  122
+
     } ;
 
 static yy_state_type yy_last_accepting_state;
@@ -489,6 +499,7 @@ char *yytext;
 #define                 CONST     1
 #define                 MUTIND    2
 #define                 MUTCONSTRUCT  3
+#define                 SORT      4
 
 #define                 INBODY    0
 #define                 MAINHYP   1
@@ -508,6 +519,8 @@ int                     position = INBODY;
 int                     first_child = HERE;
 int                    skip = 0;     // boolean to skip the insertion of a URI
 int                     no_open_source =0;
+int                     spine_depth = 0;
+int                     depth = 0;
 int                     tmp_n;
 char                    sep = '"';
 char                    *xpointer = "#xpointer(1/";
@@ -519,7 +532,7 @@ char                    *tmp;
 /***************************************************************/
 /* 4. Rules.                                                   */
 /***************************************************************/
-#line 523 "lex.yy.c"
+#line 536 "lex.yy.c"
 
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
@@ -681,10 +694,10 @@ YY_DECL
        register char *yy_cp, *yy_bp;
        register int yy_act;
 
-#line 92 "meta_lex.l"
+#line 96 "meta_lex.l"
 
 
-#line 688 "lex.yy.c"
+#line 701 "lex.yy.c"
 
        if ( yy_init )
                {
@@ -735,13 +748,13 @@ yy_match:
                        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                                {
                                yy_current_state = (int) yy_def[yy_current_state];
-                               if ( yy_current_state >= 110 )
+                               if ( yy_current_state >= 123 )
                                        yy_c = yy_meta[(unsigned int) yy_c];
                                }
                        yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
                        ++yy_cp;
                        }
-               while ( yy_base[yy_current_state] != 137 );
+               while ( yy_base[yy_current_state] != 153 );
 
 yy_find_action:
                yy_act = yy_accept[yy_current_state];
@@ -769,122 +782,169 @@ do_action:      /* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 94 "meta_lex.l"
+#line 98 "meta_lex.l"
 {
                     position = INBODY; // Variables have both a body and a type
                    }
        YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 98 "meta_lex.l"
+#line 102 "meta_lex.l"
 {
                     position = INTYPE; // Variables have both a body and a type
                    }
        YY_BREAK
 case 3:
-#line 103 "meta_lex.l"
+#line 107 "meta_lex.l"
 case 4:
 YY_RULE_SETUP
-#line 103 "meta_lex.l"
+#line 107 "meta_lex.l"
 {
-                    if ((position == INTYPE) ||
-                        (position == INHYP))
+                    if (position == INTYPE)
+                       position = MAINHYP;
+                    else if (position == MAINHYP)
                         { position = INHYP;
                           no_open_source++;};
                    }
        YY_BREAK
 case 5:
-#line 111 "meta_lex.l"
+#line 116 "meta_lex.l"
 case 6:
 YY_RULE_SETUP
-#line 111 "meta_lex.l"
+#line 116 "meta_lex.l"
 {
                     if (position == INHYP)
                      {
                       no_open_source--;
                       if (no_open_source == 0) 
-                       { position = INTYPE;
-                         first_child = HERE; };
-                     };
+                        {
+                         position = MAINHYP;
+                         depth++;
+                         first_child = HERE;
+                        }
+                     }
+                    else if (position == MAINHYP)
+                      {
+                       position = INTYPE;
+                       spine_depth++;
+                       depth = 0;
+                      }
+                    first_child = HERE;
                    }
        YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 122 "meta_lex.l"
+#line 137 "meta_lex.l"
 {
                    }
        YY_BREAK
 case 8:
-#line 126 "meta_lex.l"
+#line 141 "meta_lex.l"
 case 9:
-#line 127 "meta_lex.l"
+#line 142 "meta_lex.l"
 case 10:
-#line 128 "meta_lex.l"
+#line 143 "meta_lex.l"
 case 11:
-#line 129 "meta_lex.l"
-case 12:
 YY_RULE_SETUP
-#line 129 "meta_lex.l"
+#line 143 "meta_lex.l"
 { 
                           first_child = AFTER;
                    }
        YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 147 "meta_lex.l"
+{
+                    if (((position == INTYPE) | (position == MAINHYP)) &&
+                       (first_child == HERE))
+                     {
+                       if (position == INTYPE) /* REL on the spine */
+                         {
+                           position = INCONCL;
+                           search("Rel",first_child,position,spine_depth);
+                         }
+                       else search("Rel",first_child,position,depth);
+                       first_child = AFTER;
+                     }
+                   }
+       YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 133 "meta_lex.l"
+#line 161 "meta_lex.l"
+{         
+                    if ((position == INTYPE) | (position == MAINHYP))
+                     {
+                       tmp=(char *)malloc((sizeof('a')*200)); 
+                       strcpy(tmp,yytext);
+                       strsep(&tmp,&sep); 
+                       if (position == INTYPE) /* SORT on the spine */
+                         { 
+                           position = INCONCL;
+                           search(tmp,first_child,position,spine_depth);
+                         }
+                       else search(tmp,first_child,position,depth);
+                       first_child = AFTER;
+                     }
+                   }
+       YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 177 "meta_lex.l"
 {
                      skip = 1;
                      first_child = AFTER;
                    }
        YY_BREAK
-case 14:
+case 15:
 YY_RULE_SETUP
-#line 138 "meta_lex.l"
+#line 182 "meta_lex.l"
 { 
                      if (position == INTYPE) /* CONST on the spine */
                         position = INCONCL;
                      where = CONST;
                    }
        YY_BREAK
-case 15:
+case 16:
 YY_RULE_SETUP
-#line 144 "meta_lex.l"
+#line 188 "meta_lex.l"
 { 
                      if (position == INTYPE) /* MUTIND on the spine */
                         position = INCONCL;
                      where = MUTIND;
                    }
        YY_BREAK
-case 16:
+case 17:
 YY_RULE_SETUP
-#line 150 "meta_lex.l"
+#line 194 "meta_lex.l"
 { 
                      if (position == INTYPE) /* MUTCONSTRUCT on the spine */
                         position = INCONCL;
                      where = MUTCONSTRUCT;
                    }
        YY_BREAK
-case 17:
+case 18:
 YY_RULE_SETUP
-#line 156 "meta_lex.l"
+#line 200 "meta_lex.l"
 {     
                          if (!skip) {
                             uri=(char *)malloc((sizeof('a')*200)); 
                             strcpy(uri,yytext);
                             strsep(&uri,&sep);
                             if (where == CONST)
-                                {
-                                   search(uri,first_child,position); 
-                                   where = NOWHERE;
-                                   first_child = AFTER;
-                                   free(uri); 
-                                 };
+                              {
+                                if (position == INCONCL)
+                                  search(uri,first_child,position,spine_depth);
+                                else search(uri,first_child,position,depth);
+                                where = NOWHERE;
+                                first_child = AFTER;
+                                free(uri); 
+                              };
                          } else skip = 0;
                    } 
        YY_BREAK
-case 18:
+case 19:
 YY_RULE_SETUP
-#line 171 "meta_lex.l"
+#line 217 "meta_lex.l"
 {
                          if ((where == MUTIND) || (where == MUTCONSTRUCT))
                           { strsep(&yytext,&sep);
@@ -898,16 +958,18 @@ YY_RULE_SETUP
                          if (where == MUTIND) 
                              { 
                                strcat(uri,")");
-                               search(uri,first_child,position); 
+                               if (position == INCONCL)
+                                  search(uri,first_child,position,spine_depth);
+                               else search(uri,first_child,position,depth);
                                free(uri);
                                free(tmp);
                                where = NOWHERE; 
                                first_child = AFTER;};
                    } 
        YY_BREAK
-case 19:
+case 20:
 YY_RULE_SETUP
-#line 191 "meta_lex.l"
+#line 239 "meta_lex.l"
 {
                          if (where == MUTCONSTRUCT)
                           { strsep(&yytext,&sep);
@@ -916,19 +978,21 @@ YY_RULE_SETUP
                             strcat(uri,"/");
                             strcat(uri,tmp);
                             strcat(uri,")");
-                            search(uri,first_child,position);
+                            if (position == INCONCL)
+                              search(uri,first_child,position,spine_depth);
+                            else search(uri,first_child,position,depth);
                             free(uri);
                             free(tmp);
                             where = NOWHERE; 
                             first_child = AFTER;};
                    } 
        YY_BREAK
-case 20:
+case 21:
 YY_RULE_SETUP
-#line 208 "meta_lex.l"
+#line 258 "meta_lex.l"
 ECHO;
        YY_BREAK
-#line 932 "lex.yy.c"
+#line 996 "lex.yy.c"
 case YY_STATE_EOF(INITIAL):
        yyterminate();
 
@@ -1220,7 +1284,7 @@ static yy_state_type yy_get_previous_state()
                while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                        {
                        yy_current_state = (int) yy_def[yy_current_state];
-                       if ( yy_current_state >= 110 )
+                       if ( yy_current_state >= 123 )
                                yy_c = yy_meta[(unsigned int) yy_c];
                        }
                yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1255,11 +1319,11 @@ yy_state_type yy_current_state;
        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                {
                yy_current_state = (int) yy_def[yy_current_state];
-               if ( yy_current_state >= 110 )
+               if ( yy_current_state >= 123 )
                        yy_c = yy_meta[(unsigned int) yy_c];
                }
        yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-       yy_is_jam = (yy_current_state == 109);
+       yy_is_jam = (yy_current_state == 122);
 
        return yy_is_jam ? 0 : yy_current_state;
        }
@@ -1818,7 +1882,7 @@ int main()
        return 0;
        }
 #endif
-#line 208 "meta_lex.l"
+#line 258 "meta_lex.l"
 
 
  /***************************************************************/
@@ -1828,8 +1892,19 @@ int main()
 main(int argc, char *argv[])
 {                  
                    struct stat buf;
-                   init_symbol_table();
+                   FILE *outrel, *outsort;
 
+                   init_symbol_table();
+                   if (!(outrel = fopen("forward_rel.rdf","a"))) 
+                     {
+                     fprintf(stderr, "error in openinf file forward_rel.rdf\n");
+                      exit(-1);
+                     }
+                   if (!(outsort = fopen("forward_sort.rdf","a"))) 
+                     {
+                     fprintf(stderr, "error in openinf file forward_rel.rdf\n");
+                      exit(-1);
+                     }
                    // We process the body
                    if (!stat("tmp/body.xml",&buf)) {
                       yyin = fopen("tmp/body.xml", "r");
@@ -1842,38 +1917,74 @@ main(int argc, char *argv[])
                    yyin = fopen("tmp/type.xml", "r");
                    position = INTYPE;
                    first_child = HERE;
-                   yylex();
+                   no_open_source = 0;
+                   spine_depth = 0;
+                   depth = 0;
+                   yylex(); 
 
                    printf("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n");
-                   printf("<rdf:RDF xml:lang=\"en\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:h=\"http://www.cs.unibo.it/helm/schemas/mattone.rdf#\">\n");
+printf("<!DOCTYPE rdf:RDF [
+        <!ENTITY rdfns 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
+        <!ENTITY hthns 'http://www.cs.unibo.it/helm/schemas/schema-helmth#'>
+        <!ENTITY hns 'http://www.cs.unibo.it/helm/schemas/schema-helm#'>
+
+   ]>\n");
+
+                   printf("<rdf:RDF xml:lang=\"en\" xmlns:rdf=\"&rdfns;\" xmlns:h=\"&hns;\" xmlns:hth=\"&hthns;\">\n");
                    printf("\t<h:Object rdf:about=\"");
                    printf("%s",argv[1]);
                    printf("\">\n");
-                   print_all();
+                   print_all(argv[1],outrel,outsort);
                    printf("\t</h:Object>\n");
                    printf("</rdf:RDF>\n");
                    fclose(yyin);
                    } 
 
-search(uri,first_child,position)
+search(uri,first_child,position,depth)
 char               *uri;
 int                first_child;
 int                position; 
 {                  
-                   if (first_child == HERE)
+                   if (position == MAINHYP)
+                      { 
+                       if (first_child == HERE) 
+                           found = search_bucket(uri,MAINHYP,depth);
+                       else 
+                           found = search_bucket(uri,INHYP,0);
+                      }
+                   else if (position == INCONCL)
+                      { 
+                       if (first_child == HERE) 
+                           found = search_bucket(uri,MAINCONCL,depth);
+                       else
+                           found = search_bucket(uri,INCONCL,0);
+                      }
+                        
+                   else 
+                      found = search_bucket(uri,position,depth);
+                   /* if (found == NOTFOUND)
+                         fprintf(stderr,"pos = %d, uri = %s\n", position, uri); */
+} 
+/*                  
+                      (first_child == HERE) 
                       {
-                       if (position == INHYP)
-                          found = search_bucket(uri,MAINHYP);
+                       if (position == MAINHYP)
+                          found = search_bucket(uri,MAINHYP,depth);
                        else if (position == INCONCL)
-                          found = search_bucket(uri,MAINCONCL);
-                       /* if (found == NOTFOUND)
-                          printf( "pos = %d, uri = %s\n", MAINCONCL, uri); */
+                          found = search_bucket(uri,MAINCONCL,0);
+                       else if (position == INHYP)
+                          found = search_bucket(uri,INHYP,0);
+                          if (found == NOTFOUND)
+                          printf( "pos = %d, uri = %s\n", MAINCONCL, uri); 
                        }
-                    else found = search_bucket(uri,position);
-                    /* if (found == NOTFOUND)
-                          printf( "pos = %d, uri = %s\n", position, uri); */
-                    }
+                   else if ((position == MAINHYP) && (first_child == AFTER))
+                        found = search_bucket(uri,INHYP,0);
+                   else found = search_bucket(uri,position,0);
+                   if (found == NOTFOUND)
+                         printf( "pos = %d, uri = %s\n", position, uri); 
+                   } */
 
 int yywrap() {
                return 1;
              }
+