C:/Users/Dennis/src/lang/russell.orig/src/pass1/parser/initids.c

Go to the documentation of this file.
00001 # include "parm.h"
00002 # include "stree/ststructs.mh"
00003 # include "../stt/sttdefs.h"
00004 
00005 # include "../applinfer/precedence.h"
00006 
00007 /*
00008  *   Initialize the string table to contain various identifiers with
00009  * builtin meanings and/or precedences.  Then build trees to correspond
00010  * to default signatures, as well as certain other standard subtrees.
00011  */
00012 
00013  
00014 sttrelptr  indx_assign,      /* precedence 0 */
00015            indx_passign,
00016            indx_massign,
00017            /*   cor             precedence 1 */
00018            /*   cand            precedence 2 */
00019            /* other operators   precedence 3 */
00020            indx_or,          /* precedence 4 */
00021            indx_and,         /* precedence 5 */
00022            indx_not,         /* precedence 6 */
00023            indx_equals,      /* precedence 7 */
00024            indx_less,
00025            indx_le,
00026            indx_ge,
00027            indx_ne,
00028            indx_greater,
00029            indx_plus,        /* precedence 8 */
00030            indx_minus,
00031            indx_times,       /* precedence 9 */
00032            indx_divide,      
00033            indx_mod,
00034            indx_pconc,       /* precedence 10 */
00035            indx_sconc,
00036            indx_exp,         /* precedence 11 */
00037            indx_deref,       /* precedence 12 */
00038            indx_subscr,      /* precedence 13 */
00039            indx_New,         /* no precedence */
00040            indx_ValueOf,
00041            indx_First,
00042            indx_Last,
00043            indx_Pred,
00044            indx_Succ,
00045            indx_Ord,
00046            indx_OrdInv,
00047            indx_Card,
00048            indx_In,
00049            indx_Out,
00050            indx_put,
00051            indx_Callcc,
00052            indx_size,
00053            indx_ptr_New,
00054            indx_init_New,
00055            indx_empty,
00056            indx_standard,
00057            indx_inline;
00058 
00059 int     pend[NLEVELS];   /* pend[n] = last string table entry with precedence */
00060                          /* level n                                           */
00061 sttrelptr indx_Boolean,
00062           indx_Void,
00063           indx_true,
00064           indx_false;
00065           indx_simple,
00066           indx_Null,
00067           indx_Mk;
00068 sttrelptr indx_Integer,
00069           indx_Void,
00070           indx_Array;
00071 
00072 extern   NODE  * sig_assign,
00073                * sig_equals,
00074                * sig_less,
00075                * sig_greater,
00076                * sig_New,
00077                * sig_const,
00078                * sig_ValueOf,
00079                * sig_pconc,
00080                * sig_sconc,
00081                * sig_Signature;
00082 NODE           * val_Boolean,
00083                * val_Integer,
00084                * val_Void;
00085 NODE           * var_Void;
00086 NODE   * sel_true,  /* Trees for Boolean$true[] and Boolean$false[] */
00087        * sel_false,
00088        * id_Boolean, /* Note that the last definition field needs to be */
00089                      /* set later */
00090        * id_Integer,
00091        * id_Void,
00092        * id_put,
00093        * id_ValueOf,
00094        * id_New,
00095        * id_size,
00096        * id_Null,
00097        * id_times,
00098        * id_plus,
00099        * appl_Null;
00100 
00101 extern int  yyvline;  /* initialized here since it is incorporated into */
00102                       /* the structures created here.                   */
00103 
00104 initids()
00105 {
00106     NODE *   var_param,
00107          *   val_param,
00108          *   as_params,
00109          *   two_params,
00110          *   al_params;
00111 
00112     yyvline = 9999;
00113 
00114     /* initialize string table indicees */
00115         stt_enter("?",2);   /* Make sure index 0 is not used */
00116         indx_passign = stt_enter("+=",3);
00117         indx_massign = stt_enter("-=",3);
00118         indx_assign = pend[0] = stt_enter(":=",3);
00119         indx_or = pend[1] = pend[2] = pend[3] = pend[4] = stt_enter("or",3);
00120         indx_and = pend[5] = stt_enter("and",4);
00121         indx_not = pend[6] = stt_enter("not",4);
00122         indx_equals = stt_enter("=",2);
00123         indx_less = stt_enter("<",2);
00124         indx_le = stt_enter("<=",3);
00125         indx_ge = stt_enter(">=",3);
00126         indx_ne = stt_enter("<>",3);
00127         indx_greater = pend[7] = stt_enter(">",2);
00128         indx_plus = stt_enter("+",2);
00129         indx_minus = pend[8] = stt_enter("-",2);
00130         indx_times = stt_enter("*",2);
00131         indx_divide = stt_enter("/",2);
00132         indx_mod = pend[9] = stt_enter("%",2);
00133         indx_pconc = stt_enter("^+",3);
00134         indx_sconc = pend[10] = stt_enter("^*",3);
00135         indx_exp = pend[11] = stt_enter("**",3);
00136         indx_deref = pend[12] = stt_enter("^",2);
00137         indx_subscr = pend[13] = stt_enter(".",2);
00138         indx_New = stt_enter("New",4);
00139         indx_ptr_New = stt_enter("ptr_New",8);
00140         indx_init_New = stt_enter("init_New",9);
00141         indx_ValueOf = stt_enter("V",2);
00142         indx_First = stt_enter("First",6);
00143         indx_Last = stt_enter("Last",5);
00144         indx_Pred = stt_enter("Pred",5);
00145         indx_Succ = stt_enter("Succ",5);
00146         indx_Ord = stt_enter("Ord",4);
00147         indx_OrdInv = stt_enter("OrdInv",7);
00148         indx_Card = stt_enter("Card",5);
00149         indx_In = stt_enter("In",3);
00150         indx_Out = stt_enter("Out",4);
00151         indx_Boolean = stt_enter("Boolean",8);
00152         indx_true = stt_enter("True",5);
00153         indx_false = stt_enter("False",6);
00154         indx_Integer = stt_enter("Short",6);
00155         indx_Void = stt_enter("Void",5);
00156         indx_Array = stt_enter("Array",6);
00157         indx_put = stt_enter("put",4);
00158         indx_Callcc = stt_enter("Callcc",7);
00159         indx_size = stt_enter("size", 5);
00160         indx_empty = stt_enter("''",3);
00161         indx_simple = stt_enter("simple",7);
00162         indx_standard = stt_enter("standard",9);
00163         indx_inline = stt_enter("inline",7);
00164         indx_Mk = stt_enter("Mk",3);
00165         indx_Null = stt_enter("Null",5);
00166 
00167         id_Boolean = mknode(LETTERID, indx_Boolean);
00168         id_Void = mknode(LETTERID, indx_Void);
00169         id_Integer = mknode(LETTERID, indx_Integer);
00170         id_put = mknode(LETTERID, indx_put);
00171         id_ValueOf = mknode(LETTERID, indx_ValueOf);
00172         id_New = mknode(LETTERID, indx_New);
00173         id_size = mknode(LETTERID, indx_size);
00174         id_Null = mknode(LETTERID, indx_Null);
00175         id_times = mknode(LETTERID, indx_times);
00176         id_plus = mknode(LETTERID, indx_plus);
00177 
00178     /* initialize default signatures */
00179         /* Note that since these can and will be shared they should not */
00180         /* be touched by the symbol table routine */
00181         val_Boolean = lock( mknode(VALSIGNATURE,
00182                                    id_Boolean)
00183                           );
00184         val_Integer = lock( mknode(VALSIGNATURE,
00185                                    id_Integer)
00186                           );
00187         val_Void    = lock( mknode(VALSIGNATURE,
00188                                    id_Void)
00189                           );
00190         var_Void    = lock( mknode(VARSIGNATURE,
00191                                    id_Void)
00192                           );
00193 
00194         val_param = lock( mknode(PARAMETER,
00195                                  NIL,
00196                                  mknode(VALSIGNATURE,
00197                                         mknode(LETTERID,-1)
00198                                        )
00199                                  ) );
00200 
00201         var_param = lock( mknode(PARAMETER,
00202                                  NIL,
00203                                  mknode(VARSIGNATURE,
00204                                         mknode(LETTERID,-1)
00205                                        )
00206                                  ) );
00207 
00208         as_params = lock( mklist(var_param, val_param, -1) );
00209         two_params = lock( mklist(val_param, val_param, -1) );
00210         al_params = lock(mklist(var_param, var_param, -1) );
00211 
00212         sig_assign = lock( mknode(FUNCSIGNATURE, NIL /* inline */, as_params,
00213                                   val_param->par_signature) );
00214 
00215         sig_pconc =
00216         sig_sconc =
00217             lock( mknode(FUNCSIGNATURE, NIL, two_params,
00218                          val_param -> par_signature));
00219 
00220         sig_equals =
00221         sig_less =
00222         sig_greater =
00223             lock( mknode(FUNCSIGNATURE, NIL, two_params,val_Boolean) );
00224         sig_New = lock( mknode(FUNCSIGNATURE, NIL, emptylist(),
00225                                var_param -> par_signature) );
00226         sig_const = lock( mknode(FUNCSIGNATURE, NIL, emptylist(),
00227                                 val_param -> par_signature) );
00228         sig_ValueOf = lock( mknode(FUNCSIGNATURE, NIL,
00229                              mklist(var_param, -1),
00230                              val_param -> par_signature) );
00231         sig_Signature = lock(mknode(SIGNATURESIG));
00232 
00233         sel_true = mknode(LETTERID,indx_true);
00234         initfld(&(sel_true->sel_type),id_Boolean);
00235         sel_true = mknode(APPLICATION, sel_true, emptylist());
00236         lock( sel_true );
00237 
00238         sel_false = mknode(LETTERID,indx_false);
00239         initfld(&(sel_false->sel_type),id_Boolean);
00240         sel_false = mknode(APPLICATION, sel_false, emptylist());
00241         lock( sel_false );
00242 
00243         appl_Null = mknode(APPLICATION, id_Null, emptylist());
00244 
00245         yyvline = 0;
00246 }
00247 

Generated on Fri Jan 25 10:39:46 2008 for russell by  doxygen 1.5.4