]> matita.cs.unibo.it Git - helm.git/commitdiff
New metadata for sort and rel.
authorAndrea Asperti <andrea.asperti@unibo.it>
Tue, 19 Nov 2002 15:47:20 +0000 (15:47 +0000)
committerAndrea Asperti <andrea.asperti@unibo.it>
Tue, 19 Nov 2002 15:47:20 +0000 (15:47 +0000)
New metadata schemas.

helm/metadata/create_V7_mowgli/METADATA/lex.yy.c
helm/metadata/create_V7_mowgli/METADATA/lex.yy_ind.c
helm/metadata/create_V7_mowgli/METADATA/meta_lex.l
helm/metadata/create_V7_mowgli/METADATA/meta_lex_ind.l
helm/metadata/create_V7_mowgli/METADATA/sthandler.c
helm/metadata/create_V7_mowgli/METADATA/sthandler.h
helm/metadata/create_V7_mowgli/METADATA/sthandler_ind.c
helm/metadata/create_V7_mowgli/METADATA/sthandler_ind.h

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;
              }
+
index 643ff9f1fe067fc3340d840fedca268c5842ecfa..c233e427a7e3f15ff3068e4a0f8aeb4f9006987e 100644 (file)
@@ -291,24 +291,25 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
        *yy_cp = '\0'; \
        yy_c_buf_p = yy_cp;
 
-#define YY_NUM_RULES 22
-#define YY_END_OF_BUFFER 23
-static yyconst short int yy_accept[125] =
+#define YY_NUM_RULES 23
+#define YY_END_OF_BUFFER 24
+static yyconst short int yy_accept[138] =
     {   0,
-        0,    0,   23,    9,    9,    9,    9,    0,    0,    0,
+        0,    0,   24,    9,    9,    9,    9,    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,    0,    0,    0,    0,    0,   13,
-        0,    0,    0,   11,   15,    0,    6,    0,    0,    0,
-        0,    0,    0,    8,    0,    0,    0,    0,    0,    0,
-        0,    5,    0,    0,    0,    0,    0,    0,   14,   16,
-        0,    0,    0,    0,    0,    0,    0,    0,   19,    0,
-        0,    7,    0,    0,   10,    0,    0,   17,    0,    0,
-        0,    2,    0,    0,   12,    0,    0,    0,    0,    0,
-
-        0,    0,    0,   20,    0,    0,    0,    0,    0,    0,
-        0,    0,    0,   21,    0,    3,    0,    0,    0,    0,
-       18,    4,    1,    0
+        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,   12,    0,    0,    0,   14,    0,   16,    0,    6,
+        0,    0,    0,    0,    0,    0,    8,    0,    0,    0,
+        0,    0,    0,    0,    0,    5,    0,    0,    0,    0,
+        0,    0,   13,   17,    0,    0,    0,    0,    0,    0,
+        0,    0,    0,   20,    0,    0,    7,    0,    0,   10,
+        0,    0,   18,    0,    0,    0,    0,    2,    0,    0,
+
+       11,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,   21,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,    0,   22,    0,    3,    0,    0,    0,    0,
+        0,   19,    0,    4,    1,   15,    0
     } ;
 
 static yyconst int yy_ec[256] =
@@ -316,17 +317,17 @@ static yyconst int yy_ec[256] =
         1,    1,    1,    1,    1,    1,    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,    3,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    4,    5,    5,    5,
-        5,    5,    5,    5,    5,    5,    5,    1,    1,    6,
-        7,    8,    1,    1,    9,   10,   11,   12,   13,   14,
-        1,    1,   15,    1,    1,   16,   17,   18,   19,    1,
-        1,   20,   21,   22,   23,   24,    1,   25,    1,    1,
-        1,    1,    1,    1,    1,    1,   26,    1,   27,   28,
-
-       29,   30,    1,    1,   31,    1,    1,   32,    1,   33,
-       34,   35,    1,   36,   37,   38,   39,   40,    1,    1,
-       41,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    3,    1,    4,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    5,    6,    6,    6,
+        6,    6,    6,    6,    6,    6,    6,    1,    1,    7,
+        8,    9,    1,    1,   10,   11,   12,   13,   14,   15,
+        1,    1,   16,    1,    1,   17,   18,   19,   20,    1,
+        1,   21,   22,   23,   24,   25,    1,   26,    1,    1,
+        1,    1,    1,    1,    1,    1,   27,    1,   28,   29,
+
+       30,   31,    1,    1,   32,    1,    1,   33,    1,   34,
+       35,   36,    1,   37,   38,   39,   40,   41,    1,    1,
+       42,    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,
@@ -343,97 +344,103 @@ static yyconst int yy_ec[256] =
         1,    1,    1,    1,    1
     } ;
 
-static yyconst int yy_meta[42] =
+static yyconst int yy_meta[43] =
     {   0,
-        1,    1,    2,    1,    1,    1,    1,    1,    1,    1,
+        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
     } ;
 
-static yyconst short int yy_base[127] =
+static yyconst short int yy_base[141] =
     {   0,
-        0,    1,  139,  140,   37,  104,  101,    0,    1,  121,
-      102,  125,  110,  119,  122,  101,    1,   98,   94,   91,
-       97,    0,   92,   99,   95,  105,   99,  104,   99,    0,
-       84,   76,  109,   82,   83,    2,   98,   91,   74,  140,
-       71,   99,    2,  140,  140,   76,  140,   74,   71,  102,
-       67,   65,   70,  140,   76,   78,   61,   71,   85,    0,
-       78,  140,   58,   65,    0,   55,   51,   83,  140,  140,
-       54,   51,   79,   66,   68,   73,   46,   76,    0,   46,
-       73,  140,   41,   48,  140,   65,   56,  140,   40,   72,
-       35,  140,   46,   32,  140,   49,   63,   64,   41,   26,
-
-       34,   42,   57,   54,   20,   22,   33,   27,   44,   13,
-       10,    4,   33,   38,    6,  140,    3,   15,   28,    2,
-      140,  140,  140,  140,   65,    0
+        0,    1,  151,  152,   37,  115,  112,    0,    1,  132,
+      113,  136,  121,  130,  123,  132,  111,    1,  108,  104,
+      101,  107,    0,  102,  109,  105,  115,  109,  114,  109,
+      108,    0,   93,   85,  118,   91,   92,    2,  107,  100,
+       83,  152,   80,  108,    2,  152,   95,  152,   84,  152,
+       82,   79,  110,   75,   73,   78,  152,   84,   86,   69,
+       79,   93,    0,   86,    0,  152,   66,   73,    0,   63,
+       59,   91,  152,  152,   62,   59,   87,   74,   76,   81,
+        2,   54,   84,    0,   54,   81,  152,   49,   56,  152,
+       73,   64,  152,   58,   47,   79,   42,  152,   53,   39,
+
+      152,   56,   45,   69,   70,   47,   35,   43,   51,   31,
+       66,   63,   26,   29,   40,   37,   30,   51,   21,   14,
+        8,   36,   39,   40,    8,  152,    8,   16,   34,   28,
+        2,  152,    0,  152,  152,    0,  152,   66,    5,    0
     } ;
 
-static yyconst short int yy_def[127] =
+static yyconst short int yy_def[141] =
     {   0,
-      125,  125,  124,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  126,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  126,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,    0,  124,  124
+      138,  138,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  139,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  139,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  140,  137,  137,  140,    0,  137,  137,  137
     } ;
 
-static yyconst short int yy_nxt[182] =
+static yyconst short int yy_nxt[195] =
     {   0,
-       79,  124,  124,  124,  124,    5,    5,  124,   74,  124,
-       19,   31,   60,   37,  124,  124,   61,   38,   75,   22,
-      124,  124,   32,  124,  124,   20,   46,   21,   53,   47,
-      123,   54,    6,    6,   23,  122,  121,  120,    7,    7,
-        8,  119,  114,  118,  117,  116,  115,    9,  114,  113,
-       10,   11,   12,   13,  112,  111,   14,  110,  104,  109,
-       15,  108,  107,  106,   16,    4,    4,  105,  104,  103,
-      102,  101,  100,   99,   98,   97,   96,   95,   94,   93,
-       92,   91,   90,   89,   88,   87,   86,   85,   84,   83,
-       82,   81,   80,   78,   77,   76,   73,   72,   71,   70,
-
-       69,   68,   67,   66,   65,   64,   63,   62,   59,   58,
-       57,   56,   55,   52,   51,   50,   49,   48,   45,   44,
-       43,   42,   41,   40,   39,   36,   35,   34,   33,   30,
-       29,   28,   27,   26,   25,   24,   18,   17,  124,    3,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124
+      136,   81,   81,   81,   81,   84,    5,    5,  137,   78,
+      137,   20,   33,   63,   39,  137,  137,   64,   40,   79,
+       23,  137,  137,   34,  137,  137,   21,   49,   22,   56,
+       50,  135,   57,    6,    6,   24,  134,  133,  132,    7,
+        7,    8,   94,  131,  130,  124,  129,  128,    9,  127,
+      126,   10,   11,   12,   13,  125,  124,   14,   15,  123,
+      122,   16,  121,  120,  119,   17,    4,    4,  112,  118,
+      117,  116,  115,  114,  113,  112,  111,  110,  109,  108,
+      107,  106,  105,  104,  103,  102,  101,  100,   99,   98,
+       97,   96,   95,   93,   92,   91,   90,   89,   88,   87,
+
+       86,   85,   83,   82,   80,   77,   76,   75,   74,   73,
+       72,   71,   70,   69,   68,   67,   66,   65,   62,   61,
+       60,   59,   58,   55,   54,   53,   52,   51,   48,   47,
+       46,   45,   44,   43,   42,   41,   38,   37,   36,   35,
+       32,   31,   30,   29,   28,   27,   26,   25,   19,   18,
+      137,    3,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137
+
     } ;
 
-static yyconst short int yy_chk[182] =
+static yyconst short int yy_chk[195] =
     {   0,
-      126,    0,    0,    0,    0,    1,    2,    0,   60,    0,
-        8,   17,   43,   22,    0,    0,   43,   22,   60,    9,
-        0,    0,   17,    0,    0,    8,   30,    8,   36,   30,
-      120,   36,    1,    2,    9,  119,  118,  117,    1,    2,
-        5,  115,  114,  113,  112,  111,  110,    5,  109,  108,
-        5,    5,    5,    5,  107,  106,    5,  105,  104,  103,
-        5,  102,  101,  100,    5,  125,  125,   99,   98,   97,
-       96,   94,   93,   91,   90,   89,   87,   86,   84,   83,
-       81,   80,   78,   77,   76,   75,   74,   73,   72,   71,
-       68,   67,   66,   64,   63,   61,   59,   58,   57,   56,
-
-       55,   53,   52,   51,   50,   49,   48,   46,   42,   41,
-       39,   38,   37,   35,   34,   33,   32,   31,   29,   28,
-       27,   26,   25,   24,   23,   21,   20,   19,   18,   16,
-       15,   14,   13,   12,   11,   10,    7,    6,    3,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
-      124
+      140,   65,   65,   81,   81,  139,    1,    2,    0,   63,
+        0,    8,   18,   45,   23,    0,    0,   45,   23,   63,
+        9,    0,    0,   18,    0,    0,    8,   32,    8,   38,
+       32,  131,   38,    1,    2,    9,  130,  129,  128,    1,
+        2,    5,   81,  127,  125,  124,  123,  122,    5,  121,
+      120,    5,    5,    5,    5,  119,  118,    5,    5,  117,
+      116,    5,  115,  114,  113,    5,  138,  138,  112,  111,
+      110,  109,  108,  107,  106,  105,  104,  103,  102,  100,
+       99,   97,   96,   95,   94,   92,   91,   89,   88,   86,
+       85,   83,   82,   80,   79,   78,   77,   76,   75,   72,
+
+       71,   70,   68,   67,   64,   62,   61,   60,   59,   58,
+       56,   55,   54,   53,   52,   51,   49,   47,   44,   43,
+       41,   40,   39,   37,   36,   35,   34,   33,   31,   30,
+       29,   28,   27,   26,   25,   24,   22,   21,   20,   19,
+       17,   16,   15,   14,   13,   12,   11,   10,    7,    6,
+        3,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  137,
+      137,  137,  137,  137
+
     } ;
 
 static yy_state_type yy_last_accepting_state;
@@ -486,15 +493,17 @@ char *yytext;
 #line 39 "meta_lex_ind.l"
 #include                <string.h>
 #include                <stdlib.h>
+#include                <sys/stat.h>
 #include                "sthandler_ind.h"
 /***************************************************************/
 /* 2. Constants and Variables Definitions                      */
 /***************************************************************/
-#line 49 "meta_lex_ind.l"
+#line 50 "meta_lex_ind.l"
 #define                 NOWHERE   0
 #define                 CONST     1
 #define                 MUTIND    2
 #define                 MUTCONSTRUCT  3
+#define                 SORT      4
 
 #define                 INBODY    0
 #define                 MAINHYP   1
@@ -510,12 +519,14 @@ char *yytext;
 
 int                    where = NOWHERE;
 int                     found = NOTFOUND;
-int                     position = INTYPE;
+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;
-int                     inductive_type =0;
+int                     inductive_type = 0;
 int                     constructor = 0;
 int                     deep_type = 0;
 char                    sep = '"';
@@ -527,33 +538,13 @@ char                    *file_uri;
 char                    *inductive_uri;
 char                    *filename_prefix;
 char                    *file_uri_prefix;
-
-/*%x deeptype*/
 /***************************************************************/
 /* 3. Regular definitions.                                     */
 /***************************************************************/
 /***************************************************************/
 /* 4. Rules.                                                   */
 /***************************************************************/
-/*
-"<type>"           {
-                     BEGIN(deeptype);
-                     deep_type++;
-                   }
-
-<deeptype>"<type>" {
-                     deep_type++;
-                   }
-
-<deeptype>"</type>" {
-                     deep_type--;
-                     if (deeptype == 0) BEGIN(0);
-                   }
-
-<deeptype>.|\n     {
-                   }
-*/
-#line 557 "lex.yy_ind.c"
+#line 548 "lex.yy_ind.c"
 
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
@@ -715,10 +706,10 @@ YY_DECL
        register char *yy_cp, *yy_bp;
        register int yy_act;
 
-#line 121 "meta_lex_ind.l"
+#line 104 "meta_lex_ind.l"
 
 
-#line 722 "lex.yy_ind.c"
+#line 713 "lex.yy_ind.c"
 
        if ( yy_init )
                {
@@ -769,13 +760,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 >= 125 )
+                               if ( yy_current_state >= 138 )
                                        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] != 140 );
+               while ( yy_base[yy_current_state] != 152 );
 
 yy_find_action:
                yy_act = yy_accept[yy_current_state];
@@ -803,11 +794,14 @@ do_action:        /* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 123 "meta_lex_ind.l"
+#line 106 "meta_lex_ind.l"
 { 
-                     fprintf(stderr,"uno");
+                     /* fprintf(stderr,"uno"); */
                      init_symbol_table();
-                     fprintf(stderr,"due");
+                     no_open_source = 0;
+                     depth = 0;
+                     spine_depth = 0;
+                     /* fprintf(stderr,"due"); */
                      inductive_type++;
                      constructor=0;
                      position = INTYPE;
@@ -816,25 +810,28 @@ YY_RULE_SETUP
        YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 133 "meta_lex_ind.l"
+#line 119 "meta_lex_ind.l"
 { tmp = (char *)malloc(sizeof('a')*128);
                      strcpy(filename,filename_prefix);
-                     fprintf(stderr,"tre");
+                     /* fprintf(stderr,"tre"); */
                      strcpy(file_uri,file_uri_prefix);
                      sprintf(tmp,",%d.xml", inductive_type);
-                     fprintf(stderr,"quattro");
+                     /* fprintf(stderr,"quattro"); */
                      strcat(filename,tmp);
                      sprintf(tmp,"#xpointer(1/%d)", inductive_type);
                      strcat(file_uri,tmp);
-                     fprintf(stderr,"cinque");
+                     /* fprintf(stderr,"cinque"); */
                      free(tmp);
                      print_file();
                    }
        YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 147 "meta_lex_ind.l"
+#line 133 "meta_lex_ind.l"
 { init_symbol_table();
+                     no_open_source = 0;
+                     depth = 0;
+                     spine_depth = 0;
                      constructor++;
                      strcpy(inductive_uri,file_uri_prefix);
                      position = INTYPE;
@@ -843,7 +840,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 154 "meta_lex_ind.l"
+#line 143 "meta_lex_ind.l"
 { tmp = (char *)malloc(sizeof('a')*128);
                      strcpy(filename,filename_prefix);
                      strcpy(file_uri,file_uri_prefix);
@@ -857,109 +854,156 @@ YY_RULE_SETUP
                    }
        YY_BREAK
 case 5:
-#line 167 "meta_lex_ind.l"
+#line 156 "meta_lex_ind.l"
 case 6:
 YY_RULE_SETUP
-#line 167 "meta_lex_ind.l"
+#line 156 "meta_lex_ind.l"
 {
-                    if ((position == INTYPE) ||
-                        (position == INHYP))
+                    if (position == INTYPE)
+                       position = MAINHYP;
+                    else if (position == MAINHYP)
                         { position = INHYP;
                           no_open_source++;};
                    }
        YY_BREAK
 case 7:
-#line 175 "meta_lex_ind.l"
+#line 165 "meta_lex_ind.l"
 case 8:
 YY_RULE_SETUP
-#line 175 "meta_lex_ind.l"
+#line 165 "meta_lex_ind.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 9:
 YY_RULE_SETUP
-#line 185 "meta_lex_ind.l"
+#line 186 "meta_lex_ind.l"
 {
                    }
        YY_BREAK
 case 10:
-#line 189 "meta_lex_ind.l"
-case 11:
 #line 190 "meta_lex_ind.l"
-case 12:
+case 11:
 #line 191 "meta_lex_ind.l"
-case 13:
+case 12:
 #line 192 "meta_lex_ind.l"
-case 14:
+case 13:
 YY_RULE_SETUP
 #line 192 "meta_lex_ind.l"
 { 
                           first_child = AFTER;
                    }
        YY_BREAK
-case 15:
+case 14:
 YY_RULE_SETUP
 #line 196 "meta_lex_ind.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 15:
+YY_RULE_SETUP
+#line 210 "meta_lex_ind.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 16:
+YY_RULE_SETUP
+#line 226 "meta_lex_ind.l"
 {
                      skip = 1;
                      first_child = AFTER;
                    }
        YY_BREAK
-case 16:
+case 17:
 YY_RULE_SETUP
-#line 201 "meta_lex_ind.l"
+#line 231 "meta_lex_ind.l"
 { 
                      if (position == INTYPE) /* CONST on the spine */
                         position = INCONCL;
                      where = CONST;
                    }
        YY_BREAK
-case 17:
+case 18:
 YY_RULE_SETUP
-#line 207 "meta_lex_ind.l"
+#line 237 "meta_lex_ind.l"
 { 
                      if (position == INTYPE) /* MUTIND on the spine */
                         position = INCONCL;
                      where = MUTIND;
                    }
        YY_BREAK
-case 18:
+case 19:
 YY_RULE_SETUP
-#line 213 "meta_lex_ind.l"
+#line 243 "meta_lex_ind.l"
 { 
                      if (position == INTYPE) /* MUTCONSTRUCT on the spine */
                         position = INCONCL;
                      where = MUTCONSTRUCT;
                    }
        YY_BREAK
-case 19:
+case 20:
 YY_RULE_SETUP
-#line 219 "meta_lex_ind.l"
+#line 249 "meta_lex_ind.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 20:
+case 21:
 YY_RULE_SETUP
-#line 234 "meta_lex_ind.l"
+#line 266 "meta_lex_ind.l"
 {
                          if ((where == MUTIND) || (where == MUTCONSTRUCT))
                           { strsep(&yytext,&sep);
@@ -973,16 +1017,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 21:
+case 22:
 YY_RULE_SETUP
-#line 254 "meta_lex_ind.l"
+#line 288 "meta_lex_ind.l"
 {
                          if (where == MUTCONSTRUCT)
                           { strsep(&yytext,&sep);
@@ -991,19 +1037,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 22:
+case 23:
 YY_RULE_SETUP
-#line 270 "meta_lex_ind.l"
+#line 307 "meta_lex_ind.l"
 ECHO;
        YY_BREAK
-#line 1007 "lex.yy_ind.c"
+#line 1055 "lex.yy_ind.c"
 case YY_STATE_EOF(INITIAL):
        yyterminate();
 
@@ -1295,7 +1343,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 >= 125 )
+                       if ( yy_current_state >= 138 )
                                yy_c = yy_meta[(unsigned int) yy_c];
                        }
                yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1330,11 +1378,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 >= 125 )
+               if ( yy_current_state >= 138 )
                        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 == 124);
+       yy_is_jam = (yy_current_state == 137);
 
        return yy_is_jam ? 0 : yy_current_state;
        }
@@ -1893,7 +1941,7 @@ int main()
        return 0;
        }
 #endif
-#line 270 "meta_lex_ind.l"
+#line 307 "meta_lex_ind.l"
 
 
  /***************************************************************/
@@ -1901,58 +1949,89 @@ int main()
  /***************************************************************/
 
 main(int argc, char *argv[])
-{                  
+{
                    filename = malloc((sizeof('a')*2000));
                    file_uri = malloc((sizeof('a')*2000));
                    inductive_uri = malloc((sizeof('a')*2000));
                    filename_prefix=argv[1];
                    file_uri_prefix=argv[2];
-                   fprintf(stderr,"qua");
+                   /* fprintf(stderr,"qua"); */
                    yyin = fopen("tmp/inductive_type.xml", "r");
                    yylex();
-                   } 
+}
 
 print_file()
-{
-                   FILE *out;
+{                  
+                   FILE *out, *outrel, *outsort;
+
                    if (!(out = fopen(filename,"w"))) 
                      {
                      fprintf(stderr, "error in openinf file %s\n", filename);
                       exit(-1);
+                     } 
+                   if (!(outrel = fopen("forward_rel.rdf","a"))) 
+                     {
+                     fprintf(stderr, "error in openinf file forward_rel.rdf\n");
+                      exit(-1);
                      }
-                   else
+                   if (!(outsort = fopen("forward_sort.rdf","a"))) 
                      {
-                      fprintf(out,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n");
-                      fprintf(out,"<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");
-                      fprintf(out,"\t<h:Object rdf:about=\"");
-                      fprintf(out,"%s",file_uri);
-                      fprintf(out,"\">\n");
-                      print_all(out);
-                      fprintf(out,"\t</h:Object>\n");
-                      fprintf(out,"</rdf:RDF>\n");
-                      fclose(out);
+                     fprintf(stderr, "error in openinf file forward_rel.rdf\n");
+                      exit(-1);
                      }
+                 
+                   // We process the type
+
+                   fprintf(out,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n");
+fprintf(out,"<!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");
+                   fprintf(out,"<rdf:RDF xml:lang=\"en\" xmlns:rdf=\"&rdfns;\" xmlns:h=\"&hns;\" xmlns:hth=\"&hthns;\">\n");
+                   fprintf(out,"\t<h:Object rdf:about=\"");
+                   fprintf(out,"%s",file_uri);
+                   fprintf(out,"\">\n");
+                   print_all(file_uri,out,outrel,outsort);
+                   fprintf(out,"\t</h:Object>\n");
+                   fprintf(out,"</rdf:RDF>\n");
+                   fclose(out);
+                   fclose(outrel);
+                   fclose(outsort);
 }
 
-search(uri,first_child,position)
+search(uri,first_child,position,depth)
 char               *uri;
 int                first_child;
 int                position; 
 {                  
-                   if (first_child == HERE)
-                      {
-                       if (position == INHYP)
-                          found = search_bucket(uri,MAINHYP);
-                       else if (position == INCONCL)
-                          found = search_bucket(uri,MAINCONCL);
-                       /* 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); */
-                    }
+                   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)
+                         printf( "pos = %d, uri = %s\n", position, uri); */
+}
+
 
 int yywrap() {
                return 1;
              }
+
+
+
+
index 4f654bc37d2c78d154c914a0224dd2feebec3c92..df0977f6caba90f8db1c620ff77a1f8f437f0a44 100644 (file)
@@ -51,6 +51,7 @@
 #define                 CONST     1
 #define                 MUTIND    2
 #define                 MUTCONSTRUCT  3
+#define                 SORT      4
 
 #define                 INBODY    0
 #define                 MAINHYP   1
@@ -70,6 +71,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/";
@@ -82,7 +85,8 @@ char                    *tmp;
  /***************************************************************/
 
 uri                     [^"]+
-digits                  [0-9]+                   
+digits                  [0-9]+ 
+value                   [^"]+                  
 
  /***************************************************************/
  /* 4. Rules.                                                  */
@@ -101,8 +105,9 @@ digits                  [0-9]+
 
 "<decl"            |
 "<def"             {
-                    if ((position == INTYPE) ||
-                        (position == INHYP))
+                    if (position == INTYPE)
+                       position = MAINHYP;
+                    else if (position == MAINHYP)
                         { position = INHYP;
                           no_open_source++;};
                    }
@@ -113,9 +118,19 @@ digits                  [0-9]+
                      {
                       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;
                    }
 
 
@@ -123,13 +138,42 @@ digits                  [0-9]+
                    }
 
 "<LAMBDA"          |
-"<REL"             |
 "<MUTCASE"         |
 "<FIX"             |
 "<COFIX"           { 
                           first_child = AFTER;
                    }
 
+"<REL"             {
+                    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;
+                     }
+                   }
+
+"<SORT"(" "|\n)+"value=\""{value}   {         
+                    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;
+                     }
+                   }
+
 "<VAR"             {
                      skip = 1;
                      first_child = AFTER;
@@ -159,12 +203,14 @@ digits                  [0-9]+
                             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;
                    } 
 
@@ -181,7 +227,9 @@ digits                  [0-9]+
                          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; 
@@ -196,7 +244,9 @@ digits                  [0-9]+
                             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; 
@@ -214,8 +264,19 @@ digits                  [0-9]+
 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");
@@ -228,38 +289,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;
              }
+
index 7fd23b21aa936a6f9293976685befe2947189b63..a7a62666f64219d6ea4ea293935f50645e2682e2 100644 (file)
@@ -38,6 +38,7 @@
 %{
 #include                <string.h>
 #include                <stdlib.h>
+#include                <sys/stat.h>
 #include                "sthandler_ind.h"
 %}
 
@@ -50,6 +51,7 @@
 #define                 CONST     1
 #define                 MUTIND    2
 #define                 MUTCONSTRUCT  3
+#define                 SORT      4
 
 #define                 INBODY    0
 #define                 MAINHYP   1
 
 int                    where = NOWHERE;
 int                     found = NOTFOUND;
-int                     position = INTYPE;
+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;
-int                     inductive_type =0;
+int                     inductive_type = 0;
 int                     constructor = 0;
 int                     deep_type = 0;
 char                    sep = '"';
@@ -82,48 +86,30 @@ char                    *file_uri;
 char                    *inductive_uri;
 char                    *filename_prefix;
 char                    *file_uri_prefix;
-
 %}
 
-/*%x deeptype*/
-
-
  /***************************************************************/
  /* 3. Regular definitions.                                    */
  /***************************************************************/
 
 uri                     [^"]+
-digits                  [0-9]+                   
+digits                  [0-9]+ 
+value                   [^"]+                  
 
  /***************************************************************/
  /* 4. Rules.                                                  */
  /***************************************************************/
 
-/*
-"<type>"           {
-                     BEGIN(deeptype);
-                     deep_type++;
-                   }
-
-<deeptype>"<type>" {
-                     deep_type++;
-                   }
-
-<deeptype>"</type>" {
-                     deep_type--;
-                     if (deeptype == 0) BEGIN(0);
-                   }
-
-<deeptype>.|\n     {
-                   }
-*/
 
 %%
 
 "<InductiveType"   { 
-                     fprintf(stderr,"uno");
+                     /* fprintf(stderr,"uno"); */
                      init_symbol_table();
-                     fprintf(stderr,"due");
+                     no_open_source = 0;
+                     depth = 0;
+                     spine_depth = 0;
+                     /* fprintf(stderr,"due"); */
                      inductive_type++;
                      constructor=0;
                      position = INTYPE;
@@ -132,19 +118,22 @@ digits                  [0-9]+
 
 "</arity>"         { tmp = (char *)malloc(sizeof('a')*128);
                      strcpy(filename,filename_prefix);
-                     fprintf(stderr,"tre");
+                     /* fprintf(stderr,"tre"); */
                      strcpy(file_uri,file_uri_prefix);
                      sprintf(tmp,",%d.xml", inductive_type);
-                     fprintf(stderr,"quattro");
+                     /* fprintf(stderr,"quattro"); */
                      strcat(filename,tmp);
                      sprintf(tmp,"#xpointer(1/%d)", inductive_type);
                      strcat(file_uri,tmp);
-                     fprintf(stderr,"cinque");
+                     /* fprintf(stderr,"cinque"); */
                      free(tmp);
                      print_file();
                    }
 
 "<Constructor"     { init_symbol_table();
+                     no_open_source = 0;
+                     depth = 0;
+                     spine_depth = 0;
                      constructor++;
                      strcpy(inductive_uri,file_uri_prefix);
                      position = INTYPE;
@@ -165,8 +154,9 @@ digits                  [0-9]+
 
 "<decl"            |
 "<def"             {
-                    if ((position == INTYPE) ||
-                        (position == INHYP))
+                    if (position == INTYPE)
+                       position = MAINHYP;
+                    else if (position == MAINHYP)
                         { position = INHYP;
                           no_open_source++;};
                    }
@@ -177,22 +167,62 @@ digits                  [0-9]+
                      {
                       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;
                    }
 
+
 .|\n               {
                    }
 
 "<LAMBDA"          |
-"<REL"             |
 "<MUTCASE"         |
 "<FIX"             |
 "<COFIX"           { 
                           first_child = AFTER;
                    }
 
+"<REL"             {
+                    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;
+                     }
+                   }
+
+"<SORT"(" "|\n)+"value=\""{value}   {         
+                    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;
+                     }
+                   }
+
 "<VAR"             {
                      skip = 1;
                      first_child = AFTER;
@@ -222,12 +252,14 @@ digits                  [0-9]+
                             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;
                    } 
 
@@ -244,7 +276,9 @@ digits                  [0-9]+
                          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; 
@@ -259,7 +293,9 @@ digits                  [0-9]+
                             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; 
@@ -267,6 +303,7 @@ digits                  [0-9]+
                    } 
 
 
+
 %%
 
  /***************************************************************/
@@ -274,58 +311,89 @@ digits                  [0-9]+
  /***************************************************************/
 
 main(int argc, char *argv[])
-{                  
+{
                    filename = malloc((sizeof('a')*2000));
                    file_uri = malloc((sizeof('a')*2000));
                    inductive_uri = malloc((sizeof('a')*2000));
                    filename_prefix=argv[1];
                    file_uri_prefix=argv[2];
-                   fprintf(stderr,"qua");
+                   /* fprintf(stderr,"qua"); */
                    yyin = fopen("tmp/inductive_type.xml", "r");
                    yylex();
-                   } 
+}
 
 print_file()
-{
-                   FILE *out;
+{                  
+                   FILE *out, *outrel, *outsort;
+
                    if (!(out = fopen(filename,"w"))) 
                      {
                      fprintf(stderr, "error in openinf file %s\n", filename);
                       exit(-1);
+                     } 
+                   if (!(outrel = fopen("forward_rel.rdf","a"))) 
+                     {
+                     fprintf(stderr, "error in openinf file forward_rel.rdf\n");
+                      exit(-1);
                      }
-                   else
+                   if (!(outsort = fopen("forward_sort.rdf","a"))) 
                      {
-                      fprintf(out,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n");
-                      fprintf(out,"<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");
-                      fprintf(out,"\t<h:Object rdf:about=\"");
-                      fprintf(out,"%s",file_uri);
-                      fprintf(out,"\">\n");
-                      print_all(out);
-                      fprintf(out,"\t</h:Object>\n");
-                      fprintf(out,"</rdf:RDF>\n");
-                      fclose(out);
+                     fprintf(stderr, "error in openinf file forward_rel.rdf\n");
+                      exit(-1);
                      }
+                 
+                   // We process the type
+
+                   fprintf(out,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n");
+fprintf(out,"<!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");
+                   fprintf(out,"<rdf:RDF xml:lang=\"en\" xmlns:rdf=\"&rdfns;\" xmlns:h=\"&hns;\" xmlns:hth=\"&hthns;\">\n");
+                   fprintf(out,"\t<h:Object rdf:about=\"");
+                   fprintf(out,"%s",file_uri);
+                   fprintf(out,"\">\n");
+                   print_all(file_uri,out,outrel,outsort);
+                   fprintf(out,"\t</h:Object>\n");
+                   fprintf(out,"</rdf:RDF>\n");
+                   fclose(out);
+                   fclose(outrel);
+                   fclose(outsort);
 }
 
-search(uri,first_child,position)
+search(uri,first_child,position,depth)
 char               *uri;
 int                first_child;
 int                position; 
 {                  
-                   if (first_child == HERE)
-                      {
-                       if (position == INHYP)
-                          found = search_bucket(uri,MAINHYP);
-                       else if (position == INCONCL)
-                          found = search_bucket(uri,MAINCONCL);
-                       /* 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); */
-                    }
+                   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)
+                         printf( "pos = %d, uri = %s\n", position, uri); */
+}
+
 
 int yywrap() {
                return 1;
              }
+
+
+
+
index 963200038beda7a83ff051fd4205f16a9f22cfc0..916d3f13d960029bd9794c922320152e073a8b9e 100644 (file)
 /* 3. Types.                                                   */
 /****************************************************************/
 
+struct int_list {
+               int                     val;
+                struct int_list                *next;
+                  }; 
+
 struct st_bucket {
                char                    *id;
-                                               /* identifier */
+                                                /* identifier */
+                int                     main_depth;
+                struct int_list                *depths;
                struct st_bucket        *next_st_bucket;
                                                /* next bucket in the list */
                 struct st_bucket       *all_next;
@@ -83,7 +90,12 @@ struct st_bucket    *dictionary[DICTSIZE];
                               /* pointers to bucket lists */
 
 /****************************************************************/
-/* 4. Definitions of functions to be exported.                 */
+/* 4. Local functions.                                         */
+/****************************************************************/
+struct int_list  *add(struct int_list  *,int);
+
+/****************************************************************/
+/* 5. Definitions of functions to be exported.                 */
 /****************************************************************/
 
 struct st_bucket       *all;
@@ -105,10 +117,11 @@ void init_symbol_table()
  /* The bucket associated with the given identifier */
  /* becomes the first one in its list. */
 
-search_bucket(id, where)
+search_bucket(id, where, depth)
        char            *id;
                                        /* identifier */
         int             where;
+        int             depth;
 {
        int             dict_index;
                                        /* value returned by the */
@@ -120,8 +133,8 @@ search_bucket(id, where)
         struct st_bucket *st;
 
         /* apply the hash function */
-        dict_index = hash_pjw(id);
-        /* printf( "%d\n", dict_index); */
+        dict_index = hash_pjw(id); 
+        /* fprintf(stderr,"%d\n", dict_index); */
         
         /* scan the bucket list indicated by the hash function */
         prev = curr = dictionary[dict_index];
@@ -134,12 +147,17 @@ search_bucket(id, where)
           /* the identifier is not in the list */
           {
             allocate_bucket(&st,id,where);
+            if (where == MAINCONCL)
+             st->main_depth = depth;
+            else if (where == MAINHYP)
+              st->depths = add(st->depths,depth);
            move_bucket(st,dict_index);
             return NOTFOUND;
           }
        else
-         /* printf("uno=%s\n", id);
-            printf("st=%s\n", curr->id); */
+          /*
+            printf("uno=%s\n", id);
+            printf("st=%s\n", curr->id); fflush(stdout) */
 
           /* the identifier is already in the list */
           {
@@ -147,6 +165,10 @@ search_bucket(id, where)
             curr->pos[where] = 1;
             if (where >= 1) 
              curr->pos[INBODY] = 0; /* it will never be set again to 1 */
+            if (where == MAINHYP)
+              curr->depths=add(curr->depths,depth); 
+           else if (where == MAINCONCL)
+             curr->main_depth = depth; 
             if (prev != curr)
               /* the identifier is not in the first position */
               {
@@ -158,17 +180,28 @@ search_bucket(id, where)
           }
 }
 
-print_all()
+print_all(about,outrel,outsort)
+     char       *about;
+     FILE       *outrel,
+                *outsort;
 {
+
         int i;
         struct st_bucket *curr;
         curr = all;
-
+        printf("printall\n"); fflush(stdout);
         while (curr != NULL)
          {
             for (i = 0; i < 5; ++i)
-             if (curr->pos[i] == 1)
-               print_one(curr->id,i);
+             if ((curr->pos[i]) == 1)
+               {
+                 if (i == MAINHYP)
+                   print_mainhyp(about,outrel,outsort,curr->id,curr->depths);
+                  else if (i == MAINCONCL)
+                    print_mainconcl(about,outrel,outsort,curr->id,curr->main_depth);
+                 else
+                   print_one(curr->id,i);
+               }
             curr = curr->all_next;
           }
 }
@@ -178,13 +211,135 @@ print_all()
 /* 5. Definitions of functions local to the module.            */
 /****************************************************************/
 
+struct int_list  *add(l,m)
+     struct int_list    *l;
+     int               m;
+{
+       struct int_list *curr;
+        /* scan the list looking for m */
+        curr = l;
+        while ((curr != NULL) && (m != (curr->val)))
+            curr = curr->next;
+       if (curr == NULL)
+          /* m is not in the list */
+          {
+            curr = (struct int_list *)malloc(sizeof(struct int_list));
+            curr->val = m;
+           curr->next = l;
+            return curr;
+          }
+       else
+       return l;
+       
+}
+
+print_mainhyp(about,outrel,outsort,uri,l)
+     char                *about;
+     FILE                *outrel,
+                         *outsort;
+     char                *uri;
+     struct int_list     *l;
+{
+    struct int_list *curr;
+    curr = l;
+    if (!strcmp(uri,"Rel"))
+      {
+        fprintf(outrel,"\t<h:Object rdf:about=\"");
+        fprintf(outrel,"%s",about);
+        fprintf(outrel,"\">\n");
+        /* scan the list */
+        while (curr != NULL)
+         {
+           fprintf(outrel,"\t\t<h:refRel rdf:parseType=\"Resource\">");
+            fprintf(outrel,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainHypothesis\"/>");
+            fprintf(outrel,"\n\t\t\t\t<h:depth>%d</h:depth>",curr->val);
+            fprintf(outrel,"\n\t\t</h:refRel>\n");
+            curr = curr->next;
+         }
+       fprintf(outrel,"\t</h:Object>\n");
+      }
+   else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) ||
+            (!strcmp(uri,"Set")))
+      {
+        /* scan the list */
+        fprintf(outsort,"\t<h:Object rdf:about=\"");
+        fprintf(outsort,"%s",about);
+        fprintf(outsort,"\">\n");
+        while (curr != NULL)
+         {
+           fprintf(outsort,"\t\t<h:refSort rdf:parseType=\"Resource\">");
+            fprintf(outsort,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainHypothesis\"/>");
+            fprintf(outsort,"\n\t\t\t\t<h:sort rdf:resource=\"&hns;%s\">",uri);
+            fprintf(outsort,"\n\t\t\t\t<h:depth>%d</h:depth>",curr->val);
+            fprintf(outsort,"\n\t\t</h:refSort>\n");
+            curr = curr->next;
+         }
+       fprintf(outsort,"\t</h:Object>\n");
+      }
+    else 
+     {
+        /* scan the list */
+        while (curr != NULL)
+         {
+           printf("\t\t<h:refObj rdf:parseType=\"Resource\">");
+            printf("\n\t\t\t\t<h:position rdf:resource=\"&hns;MainHypothesis\"/>");
+            printf("\n\t\t\t\t<h:depth>%d</h:depth>",curr->val);
+            printf("\n\t\t\t\t<h:occurrence><h:Object rdf:about=\"%s\"/></h:occurrence>",uri);
+            printf("\n\t\t</h:refObj>\n");
+            curr = curr->next;
+         }
+      }
+}
+
+print_mainconcl(about,outrel,outsort,uri,depth)
+     char    *about;
+     FILE    *outrel,
+             *outsort;
+     char    *uri;
+     int     depth;
+     
+{
+    if (!strcmp(uri,"Rel"))
+      { 
+        fprintf(outrel,"\t<h:Object rdf:about=\"");
+        fprintf(outrel,"%s",about);
+        fprintf(outrel,"\">\n");
+       fprintf(outrel,"\t\t<h:refRel rdf:parseType=\"Resource\">");
+       fprintf(outrel,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainConclusion\"/>");
+       fprintf(outrel,"\n\t\t\t\t<h:depth>%d</h:depth>",depth);
+       fprintf(outrel,"\n\t\t</h:refObj>\n");
+        fprintf(outrel,"\t</h:Object>\n");
+      }
+    else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) ||
+            (!strcmp(uri,"Set")))
+      {
+        fprintf(outsort,"\t<h:Object rdf:about=\"");
+        fprintf(outsort,"%s",about);
+        fprintf(outsort,"\">\n");
+       fprintf(outsort,"\t\t<h:refSort rdf:parseType=\"Resource\">");
+       fprintf(outsort,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainConclusion\"/>");
+       fprintf(outsort,"\n\t\t\t\t<h:sort>%s</h:sort>",uri);
+       fprintf(outsort,"\n\t\t\t\t<h:depth>%d</h:depth>",depth);
+       fprintf(outsort,"\n\t\t</h:refSort>\n");
+        fprintf(outsort,"\t</h:Object>\n");
+      }
+    else
+      {
+       printf("\t\t<h:refObj rdf:parseType=\"Resource\">");
+       printf("\n\t\t\t\t<h:position rdf:resource=\"&hns;MainConclusion\"/>");
+       printf("\n\t\t\t\t<h:occurrence><h:Object rdf:about=\"%s\"/></h:occurrence>",uri);
+       printf("\n\t\t\t\t<h:depth>%d</h:depth>",depth);
+       printf("\n\t\t</h:refObj>\n");
+      }
+}
 
 // dome: cambiata per usare il modello con position
 print_one(uri,pos)
      char    *uri;
      int     pos;
 {
-    printf("\t\t<h:refObj>\n\t\t\t<h:Occurrence>\n\t\t\t\t<h:position>");
+    printf("\t\t<h:refObj rdf:parseType=\"Resource\">");
+    printf("\n\t\t\t\t<h:position rdf:resource=\"&hns;");
     if (pos == INBODY)
        printf("InBody");
     else if (pos == MAINHYP)
@@ -195,7 +350,7 @@ print_one(uri,pos)
        printf("InConclusion");
     else if (pos == MAINCONCL)
        printf("MainConclusion");
-    printf("</h:position>\n\t\t\t\t<h:occurrence>%s</h:occurrence>\n\t\t\t</h:Occurrence>\n\t\t</h:refObj>\n", uri);
+    printf("\"/>\n\t\t\t\t<h:occurrence><h:Object rdf:about=\"%s\"/></h:occurrence>\n\t\t</h:refObj>\n", uri);
 }
 
  /* The following function allocates a bucket for an identifier. */
@@ -213,6 +368,8 @@ allocate_bucket(st, id, where)
        *st = (struct st_bucket *)malloc(sizeof(struct st_bucket));
        (*st)->id = (char *)malloc(sizeof('a')*(strlen(id) + 1));
         strcpy((*st)->id,id);
+        (*st)->main_depth = 0;
+        (*st)->depths = NULL;
        (*st)->next_st_bucket = NULL;
         (*st)->all_next = all;
         all = *st;
@@ -259,3 +416,4 @@ hash_pjw(id)
 
 
 
+
index 9c98992ce4d6f8090e4df30e0e378e5b2dee9879..5a9cd71439c60c407701f46f6d69c461985f9844 100644 (file)
@@ -4,5 +4,5 @@
 
             
 extern  void            init_symbol_table();
-extern  void            print_all();
-extern  int             search_bucket(char *, int);
+extern  void            print_all(char *, FILE *, FILE *);
+extern  int             search_bucket(char *, int, int);
index 07612d6f8115a9e51ad37447a0f1fb395b0cf023..d49863f5bbe33d75b687b678afe3d241ba62f014 100644 (file)
 /* 3. Types.                                                   */
 /****************************************************************/
 
+struct int_list {
+               int                     val;
+                struct int_list                *next;
+                  }; 
+
 struct st_bucket {
                char                    *id;
-                                               /* identifier */
+                                                /* identifier */
+                int                     main_depth;
+                struct int_list                *depths;
                struct st_bucket        *next_st_bucket;
                                                /* next bucket in the list */
                 struct st_bucket       *all_next;
@@ -83,7 +90,12 @@ struct st_bucket    *dictionary[DICTSIZE];
                               /* pointers to bucket lists */
 
 /****************************************************************/
-/* 4. Definitions of functions to be exported.                 */
+/* 4. Local functions.                                         */
+/****************************************************************/
+struct int_list  *add(struct int_list  *,int);
+
+/****************************************************************/
+/* 5. Definitions of functions to be exported.                 */
 /****************************************************************/
 
 struct st_bucket       *all;
@@ -105,10 +117,11 @@ void init_symbol_table()
  /* The bucket associated with the given identifier */
  /* becomes the first one in its list. */
 
-search_bucket(id, where)
+search_bucket(id, where, depth)
        char            *id;
                                        /* identifier */
         int             where;
+        int             depth;
 {
        int             dict_index;
                                        /* value returned by the */
@@ -121,7 +134,7 @@ search_bucket(id, where)
 
         /* apply the hash function */
         dict_index = hash_pjw(id);
-        /* printf( "%d\n", dict_index); */
+        /* fprintf(stderr,"%d\n", dict_index); fflush(stdout); */
         
         /* scan the bucket list indicated by the hash function */
         prev = curr = dictionary[dict_index];
@@ -134,12 +147,17 @@ search_bucket(id, where)
           /* the identifier is not in the list */
           {
             allocate_bucket(&st,id,where);
+            if (where == MAINCONCL)
+             st->main_depth = depth;
+            else if (where == MAINHYP)
+              st->depths = add(st->depths,depth);
            move_bucket(st,dict_index);
             return NOTFOUND;
           }
        else
-         /* printf("uno=%s\n", id);
-            printf("st=%s\n", curr->id); */
+          /*
+            fprintf(stderr,"uno=%s\n", id);
+            fprintf(stderr,"st=%s\n", curr->id); fflush(stdout) */
 
           /* the identifier is already in the list */
           {
@@ -147,6 +165,10 @@ search_bucket(id, where)
             curr->pos[where] = 1;
             if (where >= 1) 
              curr->pos[INBODY] = 0; /* it will never be set again to 1 */
+            if (where == MAINHYP)
+              curr->depths=add(curr->depths,depth); 
+           else if (where == MAINCONCL)
+             curr->main_depth = depth; 
             if (prev != curr)
               /* the identifier is not in the first position */
               {
@@ -158,18 +180,28 @@ search_bucket(id, where)
           }
 }
 
-print_all(out)
-     FILE *out;
+print_all(about,out,outrel,outsort)
+     char       *about;
+     FILE       *out,
+                *outrel,
+                *outsort;
 {
+
         int i;
         struct st_bucket *curr;
         curr = all;
-
         while (curr != NULL)
          {
             for (i = 0; i < 5; ++i)
-             if (curr->pos[i] == 1)
-               print_one(out,curr->id,i);
+             if ((curr->pos[i]) == 1)
+               {
+                 if (i == MAINHYP)
+                   print_mainhyp(about,out,outrel,outsort,curr->id,curr->depths);
+                  else if (i == MAINCONCL)
+                    print_mainconcl(about,out,outrel,outsort,curr->id,curr->main_depth);
+                 else
+                   print_one(out,curr->id,i);
+               }
             curr = curr->all_next;
           }
 }
@@ -179,6 +211,129 @@ print_all(out)
 /* 5. Definitions of functions local to the module.            */
 /****************************************************************/
 
+struct int_list  *add(l,m)
+     struct int_list    *l;
+     int               m;
+{
+       struct int_list *curr;
+        /* scan the list looking for m */
+        curr = l;
+        while ((curr != NULL) && (m != (curr->val)))
+            curr = curr->next;
+       if (curr == NULL)
+          /* m is not in the list */
+          {
+            curr = (struct int_list *)malloc(sizeof(struct int_list));
+            curr->val = m;
+           curr->next = l;
+            return curr;
+          }
+       else
+       return l;
+       
+}
+
+print_mainhyp(about,out,outrel,outsort,uri,l)
+     char                *about;
+     FILE                *out,
+                         *outrel,
+                         *outsort;
+     char                *uri;
+     struct int_list     *l;
+{
+    struct int_list *curr;
+    curr = l;
+    if (!strcmp(uri,"Rel"))
+      {
+        fprintf(outrel,"\t<h:Object rdf:about=\"");
+        fprintf(outrel,"%s",about);
+        fprintf(outrel,"\">\n");
+        /* scan the list */
+        while (curr != NULL)
+         {
+           fprintf(outrel,"\t\t<h:refRel rdf:parseType=\"Resource\">");
+            fprintf(outrel,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainHypothesis\"/>");
+            fprintf(outrel,"\n\t\t\t\t<h:depth>%d</h:depth>",curr->val);
+            fprintf(outrel,"\n\t\t</h:refRel>\n");
+            curr = curr->next;
+         }
+       fprintf(outrel,"\t</h:Object>\n");
+      }
+   else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) ||
+            (!strcmp(uri,"Set")))
+      {
+        /* scan the list */
+        fprintf(outsort,"\t<h:Object rdf:about=\"");
+        fprintf(outsort,"%s",about);
+        fprintf(outsort,"\">\n");
+        while (curr != NULL)
+         {
+            fprintf(outsort,"\t\t<h:refSort rdf:parseType=\"Resource\">");
+            fprintf(outsort,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainHypothesis\"/>");
+            fprintf(outsort,"\n\t\t\t\t<h:sort rdf:resource=\"&hns;%s\">",uri);
+            fprintf(outsort,"\n\t\t\t\t<h:depth>%d</h:depth>",curr->val);
+            fprintf(outsort,"\n\t\t</h:refSort>\n");
+            curr = curr->next;
+         }
+       fprintf(outsort,"\t</h:Object>\n");
+      }
+    else 
+     {
+        /* scan the list */
+        while (curr != NULL)
+         {
+           fprintf(out,"\t\t<h:refObj rdf:parseType=\"Resource\">");
+            fprintf(out,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainHypothesis\"/>");
+            fprintf(out,"\n\t\t\t\t<h:depth>%d</h:depth>",curr->val);
+            fprintf(out,"\n\t\t\t\t<h:occurrence><h:Object rdf:about=\"%s\"/></h:occurrence>",uri);
+            fprintf(out,"\n\t\t</h:refObj>\n");
+            curr = curr->next;
+         }
+      }
+}
+
+print_mainconcl(about,out,outrel,outsort,uri,depth)
+     char    *about;
+     FILE    *out,
+             *outrel,
+             *outsort;
+     char    *uri;
+     int     depth;
+     
+{
+    if (!strcmp(uri,"Rel"))
+      { 
+        fprintf(outrel,"\t<h:Object rdf:about=\"");
+        fprintf(outrel,"%s",about);
+        fprintf(outrel,"\">\n");
+       fprintf(outrel,"\t\t<h:refRel rdf:parseType=\"Resource\">");
+       fprintf(outrel,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainConclusion\"/>");
+       fprintf(outrel,"\n\t\t\t\t<h:depth>%d</h:depth>",depth);
+       fprintf(outrel,"\n\t\t</h:refObj>\n");
+        fprintf(outrel,"\t</h:Object>\n");
+      }
+    else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) ||
+            (!strcmp(uri,"Set")))
+      {
+        fprintf(outsort,"\t<h:Object rdf:about=\"");
+        fprintf(outsort,"%s",about);
+        fprintf(outsort,"\">\n");
+       fprintf(outsort,"\t\t<h:refSort rdf:parseType=\"Resource\">");
+       fprintf(outsort,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainConclusion\"/>");
+       fprintf(outsort,"\n\t\t\t\t<h:sort>%s</h:sort>",uri);
+       fprintf(outsort,"\n\t\t\t\t<h:depth>%d</h:depth>",depth);
+       fprintf(outsort,"\n\t\t</h:refSort>\n");
+        fprintf(outsort,"\t</h:Object>\n");
+      }
+    else
+      {
+       fprintf(out,"\t\t<h:refObj rdf:parseType=\"Resource\">");
+       fprintf(out,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainConclusion\"/>");
+       fprintf(out,"\n\t\t\t\t<h:occurrence><h:Object rdf:about=\"%s\"/></h:occurrence>",uri);
+       fprintf(out,"\n\t\t\t\t<h:depth>%d</h:depth>",depth);
+       fprintf(out,"\n\t\t</h:refObj>\n");
+      }
+}
 
 // dome: cambiata per usare il modello con position
 print_one(out,uri,pos)
@@ -186,7 +341,8 @@ print_one(out,uri,pos)
      char    *uri;
      int     pos;
 {
-    fprintf(out,"\t\t<h:refObj>\n\t\t\t<h:Occurrence>\n\t\t\t\t<h:position>");
+    fprintf(out,"\t\t<h:refObj df:parseType=\"Resource\">");
+    fprintf(out,"\n\t\t\t\t<h:position rdf:resource=\"&hns;");
     if (pos == INBODY)
        fprintf(out,"InBody");
     else if (pos == MAINHYP)
@@ -197,7 +353,8 @@ print_one(out,uri,pos)
        fprintf(out,"InConclusion");
     else if (pos == MAINCONCL)
        fprintf(out,"MainConclusion");
-    fprintf(out,"</h:position>\n\t\t\t\t<h:occurrence>%s</h:occurrence>\n\t\t\t</h:Occurrence>\n\t\t</h:refObj>\n", uri);
+    fprintf(out,"\"/>\n\t\t\t\t<h:occurrence><h:Object rdf:about=\"%s\"/></h:occurrence>\n\t\t</h:refObj>\n", uri);
+    
 }
 
  /* The following function allocates a bucket for an identifier. */
@@ -215,6 +372,8 @@ allocate_bucket(st, id, where)
        *st = (struct st_bucket *)malloc(sizeof(struct st_bucket));
        (*st)->id = (char *)malloc(sizeof('a')*(strlen(id) + 1));
         strcpy((*st)->id,id);
+        (*st)->main_depth = 0;
+        (*st)->depths = NULL;
        (*st)->next_st_bucket = NULL;
         (*st)->all_next = all;
         all = *st;
@@ -261,3 +420,4 @@ hash_pjw(id)
 
 
 
+
index 24d944706c0fc01f04457e3666c37e7d26d3332f..2536b0f603f64eade1f9f7c3628122dd8aa0dd78 100644 (file)
@@ -4,5 +4,5 @@
 
             
 extern  void            init_symbol_table();
-extern  void            print_all(FILE *out);
-extern  int             search_bucket(char *, int);
+extern  void            print_all(char *, FILE *, FILE *, FILE *);
+extern  int             search_bucket(char *, int, int);