laplante@IRO.UMONTREAL.CA (Pierre Laplante) (06/09/89)
One of our user got a problem with his bison file. I got the following output when I run bison with the following file: -- output -- Script started on Fri Jun 9 09:05:31 1989 laplante has logged on console. [richelieu:101] bison xxx xxx contains 23 useless nonterminals and 72 useless rules. internal error, map_goto IOT trap (core dumped) [richelieu:102] exit script done on Fri Jun 9 09:05:40 1989 -- file -- %{ # include "stdio.h" # include "ctype.h" # include "math.h" /* NOM : decl_type.h --- FONCTION : Contient des definitions de structures. -------- DEPEND DE : Rien. --------- CREATION : Ete 84. -------- AUTEUR : Michel Deslauriers (groupe de recherche sur les protocoles, ------ de l'Universite de Montreal). PROJET : Developpement d'outils ASN1. ------ */ struct generated_number { int first_value, second_value; }; typedef struct noeud_type /* Cette structure sert pour les */ { unsigned nt_classe:2; /* noeuds qui constituent l'ar- */ unsigned nt_bidon:1; /* bre des types */ unsigned nt_primitif:1; unsigned nt_constructor:1; unsigned nt_idnt_genere:1; unsigned outside_type:1; unsigned nt_implicit:1; unsigned nt_optionnel:1; char nt_vers_type[41]; char nt_identif[41]; char nt_type[41]; char nt_type_affiche[41]; char *nt_pt_presentation; char *nt_pt_explication; char *nt_pt_valeur_defaut; unsigned nt_standard:1; int nt_code_id; int test; struct generated_number *generated_number; struct noeud_type *nt_pt_fils; struct noeud_type *nt_pt_affiche; struct noeud_type *nt_pt_frere; struct sur_pere *nt_pt_sur_pere; struct liste_association *nt_pt_association; } NOEUD_TYPE, *PTE_NOEUD_TYPE; struct noeud_valeur /* Cette structure sert pour les */ { unsigned nv_rattache:1; /* noeuds qui constituent l'arbre */ unsigned nv_erreur:1; /* des valeurs */ unsigned nv_marque:1; long nv_longueur; long nv_lng_tot; short ligne; short niveau; unsigned nv_en_erreur:1; char *nv_pt_contenu; struct noeud_type *nv_pt_type; struct noeud_valeur *nv_pt_fils; struct noeud_valeur *nv_pt_frere; }; typedef struct liste_association /* Sert a empiler une liste */ { int la_valeur; /* d'associations du genre */ char la_interpretation[41]; /* {haut (1),bas (0)} */ struct liste_association *pt_frere; } PILE_ASSOC, *PTE_ASSOC; # undef YYMAXDEPTH # define YYMAXDEPTH 99999 struct pt_type_stack { struct pt_type_stack *next; struct noeud_type *pt_type; int son_done; struct pt_type_stack *previous; }; struct pt_type_stack *pt_type_stack_top; struct noeud_valeur *la_pdu, *pt_val, *pt_val_1, *save_pt, *pt_1, *pt_2, *pt_3; extern struct noeud_valeur *par_valeur_ptr; struct noeud_type *pt_type; static short compteur, option = 1, a_first, son; extern short pushable; extern struct noeud_type *root_pt_type; extern long par_1long_chaine; extern char *par_1chaine_ptr; %} %start T_PDU %union { char text_1[80]; char *text_2; int integer; struct noeud_valeur *pointer; } %type <pointer> T_Bool T_OCTETSTRING T_Bitstring T_Integer T_Null T_Not_Present T_NumericString T_PrintableString T_TeletexString T_T61String T_VideotexString T_VisibleString T_IA5String T_GeneralString T_GraphicString T_GeneralizedTime T_UTCTime T_PDU T_Type1 %type <text_2> T_DecString T_OctetString T_DecimalDigit T_Boolean T_Octet T_BitStringPlusThOf T_Bit %type <integer> T_DecNatRepr T_Nat T_NatNumberPlusNeg %token <text_1> Null Not_Present PDU Dec String Reverse NatNum Pred thof Succ Length Octet Bit Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit8 and eq ne not or true false xor implies iff %% T_Bitstring : T_BitStringPlusThOf { push_pt_type_stack ("Bitstring"); packbit ($1); valeur (pt_type_stack_top->pt_type,par_1long_chaine,par_1chaine_ptr); $$ = par_valeur_ptr; }; T_Integer : T_NatNumberPlusNeg { push_pt_type_stack ("Integer"); valeur (pt_type_stack_top->pt_type,1,&$1); $$ = par_valeur_ptr; }; T_Null : Null { push_pt_type_stack ("NULL"); noeudval (pt_type_stack_top->pt_type); $$ = par_valeur_ptr; } ; T_Not_Present : Not_Present { $$ = NULL; } ; T_NumericString : T_OctetString { push_pt_type_stack ("NumericString"); valeur (pt_type_stack_top->pt_type,strlen ($1),$1); $$ = par_valeur_ptr; }; T_PrintableString : T_OctetString { push_pt_type_stack ("PrintableString"); valeur (pt_type_stack_top->pt_type,strlen ($1),$1); $$ = par_valeur_ptr; }; T_TeletexString : T_OctetString { push_pt_type_stack ("TeletexString"); valeur (pt_type_stack_top->pt_type,strlen ($1),$1); $$ = par_valeur_ptr; }; T_T61String : T_OctetString { push_pt_type_stack ("T61String"); valeur (pt_type_stack_top->pt_type,strlen ($1),$1); $$ = par_valeur_ptr; }; T_VideotexString : T_OctetString { push_pt_type_stack ("VideotexString"); valeur (pt_type_stack_top->pt_type,strlen ($1),$1); $$ = par_valeur_ptr; }; T_VisibleString : T_OctetString { push_pt_type_stack ("VisibleString"); valeur (pt_type_stack_top->pt_type,strlen ($1),$1); $$ = par_valeur_ptr; }; T_IA5String : T_OctetString { push_pt_type_stack ("IA5String"); valeur (pt_type_stack_top->pt_type,strlen ($1),$1); $$ = par_valeur_ptr; }; T_GeneralString : T_OctetString { push_pt_type_stack ("GeneralString"); valeur (pt_type_stack_top->pt_type,strlen ($1),$1); $$ = par_valeur_ptr; }; T_GraphicString : T_OctetString { push_pt_type_stack ("GraphicString"); valeur (pt_type_stack_top->pt_type,strlen ($1),$1); $$ = par_valeur_ptr; }; T_GeneralizedTime : T_OctetString { push_pt_type_stack ("GeneralizedTime"); valeur (pt_type_stack_top->pt_type,strlen ($1),$1); $$ = par_valeur_ptr; }; T_UTCTime : T_OctetString { push_pt_type_stack ("UTCTime"); valeur (pt_type_stack_top->pt_type,strlen ($1),$1); $$ = par_valeur_ptr; }; T_PDU : PDU '(' { push_pt_type_stack ("PDU"); } T_Integer ',' T_Bool ',' T_Type1 ')' { pop_pt_type_stack (3); pt_type = pt_type_stack_top->pt_type; pt_val = $4; pt_val_1 = pt_val; son = 0; a_first = 0; if (!pere_bidon ()) { noeudval (pt_type); $$ = par_valeur_ptr; if (node_in_between (pt_type,pt_val)) { noeudval (pt_type->nt_pt_fils); par_valeur_ptr->nv_pt_fils = pt_val; $$->nv_pt_fils = par_valeur_ptr; } else { $$->nv_pt_fils = pt_val; if (pt_val == NULL) { pt_val_1 = par_valeur_ptr; son = 1; } } } else if (node_in_between (pt_type,pt_val)) { noeudval (pt_type->nt_pt_fils); par_valeur_ptr->nv_pt_fils = pt_val; $$ = par_valeur_ptr; } else if (pt_val != NULL) $$ = pt_val; else { son = 1; a_first = 1; } if ($6 != NULL) { if (son) if (a_first) { a_first = 0; son = 0; if (node_in_between (pt_type,$6)) { noeudval (pt_type->nt_pt_fils); $$ = par_valeur_ptr; $$->nv_pt_fils = $6; } else $$ = $6; pt_val_1 = $$; } else { son = 0; if (pt_val == NULL && node_in_between (pt_type,$6) ) { noeudval (pt_type->nt_pt_fils); par_valeur_ptr->nv_pt_fils = $6; $$->nv_pt_fils = par_valeur_ptr; pt_val = par_valeur_ptr; pt_val_1 = $6; } else { pt_val_1->nv_pt_fils = $6; pt_val_1 = pt_val_1->nv_pt_fils; } } else { pt_val_1->nv_pt_frere = $6; pt_val_1=pt_val_1->nv_pt_frere; } } if ($8 != NULL) { if (son) if (a_first) { a_first = 0; son = 0; if (node_in_between (pt_type,$8)) { noeudval (pt_type->nt_pt_fils); $$ = par_valeur_ptr; $$->nv_pt_fils = $8; } else $$ = $8; pt_val_1 = $$; } else { son = 0; if (pt_val == NULL && node_in_between (pt_type,$8) ) { noeudval (pt_type->nt_pt_fils); par_valeur_ptr->nv_pt_fils = $8; $$->nv_pt_fils = par_valeur_ptr; pt_val = par_valeur_ptr; pt_val_1 = $8; } else { pt_val_1->nv_pt_fils = $8; pt_val_1 = pt_val_1->nv_pt_fils; } } else { pt_val_1->nv_pt_frere = $8; pt_val_1=pt_val_1->nv_pt_frere; } } la_pdu = $$; } ; T_Type1 : { push_pt_type_stack ("Type1"); if ((pt_type_stack_top->pt_type->nt_pt_fils == NULL && pt_type_stack_top->pt_type->nt_pt_frere == NULL ) || (pt_type_stack_top->pt_type->nt_bidon && terminal_type (pt_type_stack_top->pt_type->nt_pt_fils->nt_type) ) ) { option = 2; pushable = 0; } } T_Integer {switch (option) { case 1 : pop_pt_type_stack (1); pt_type = pt_type_stack_top->pt_type; if (!pere_bidon ()) { noeudval (pt_type); $$ = par_valeur_ptr; if (node_in_between (pt_type,$2)) { noeudval (pt_type->nt_pt_fils); par_valeur_ptr->nv_pt_fils = $2; $$->nv_pt_fils = par_valeur_ptr; } else $$->nv_pt_fils = $2; } else if (node_in_between (pt_type,$2)) { noeudval (pt_type->nt_pt_fils); par_valeur_ptr->nv_pt_fils = $2; $$ = par_valeur_ptr; } else $$ = $2; break; case 2 : $$ = $2; option = 1; break; } }; /* NAME : yacc.rest ---- FUNCTION : - Contains predined Yacc rules for librairy's types -------- such Boolean, NaturalNumber etc ... - Contains an inclusion of the file generated_lex.c which contains the lexical analyser generated from the Lex specification which has been generated by the generator. - The content of this file is used to complete the Yacc specification that the generator module generates. DEPENDS ON : Nothing. ---------- CREATION : November '88 (last revised February '89). -------- AUTHOR : Michel Deslauriers ------ (protocol research group of Universite de Montreal). PROJECT : For Lotos research. ------- */ T_Bool : T_Boolean { push_pt_type_stack ("BOOLEAN"); valeur (pt_type_stack_top->pt_type,1,$1); $$ = par_valeur_ptr; }; T_Boolean : true { F_1 (&$$,"","V"); } | false { F_1 (&$$,"",""); } | not '(' T_Boolean ')' { if ($3[0] == 'V') F_1 (&$$,"",""); else F_1 (&$$,"","V"); } | and '(' T_Boolean ',' T_Boolean ')' { if ($3[0] == 'V' && $5[0] == 'V' ) F_1 (&$$,"","V"); else F_1 (&$$,"",""); } | or '(' T_Boolean ',' T_Boolean ')' { if ($3[0] != 'V' && $5[0] != 'V' ) F_1 (&$$,"",""); else F_1 (&$$,"","V"); } | xor '(' T_Boolean ',' T_Boolean ')' { if ($3[0] != $5[0]) F_1 (&$$,"","V"); else F_1 (&$$,"",""); } | implies '(' T_Boolean ',' T_Boolean ')' { if ($3[0] == 'V' && $5[0] != 'V' ) F_1 (&$$,"",""); else F_1 (&$$,"","V"); } | iff '(' T_Boolean ',' T_Boolean ')' { if ($3[0] != $5[0]) F_1 (&$$,"",""); else F_1 (&$$,"","V"); } | eq '(' T_Boolean ',' T_Boolean ')' { if ($3[0] != $5[0]) F_1 (&$$,"",""); else F_1 (&$$,"","V"); } | ne '(' T_Boolean ',' T_Boolean ')' { if ($3[0] != $5[0]) F_1 (&$$,"","V"); else F_1 (&$$,"",""); }; T_DecNatRepr : T_Nat ; T_Nat : '*' '(' T_Nat ',' T_Nat ')' { $$ = $3 * $5; } | '*' '*' '(' T_Nat ',' T_Nat ')' { $$ = power ($4,$6); } | '+' '(' T_Nat ',' T_Nat ')' { $$ = $3 + $5; } | '-' '(' T_Nat ',' T_Nat ')' { $$ = $3 - $5; } | '0' { $$ = 0; } | Length '(' T_DecString ')' { $$ = strlen ($3); } | Succ '(' T_Nat ')' { $$ = $3 + 1; } | NatNum '(' T_DecString ')' { $$ = atoi ($3); }; T_NatNumberPlusNeg : '*' '(' T_NatNumberPlusNeg ',' T_NatNumberPlusNeg ')' { $$ = $3 * $5; } | '*' '*' '(' T_NatNumberPlusNeg ',' T_NatNumberPlusNeg ')' { $$ = power ($4,$6); } | '+' '(' T_NatNumberPlusNeg ',' T_NatNumberPlusNeg ')' { $$ = $3 + $5; } | '-' '(' T_NatNumberPlusNeg ',' T_NatNumberPlusNeg ')' { $$ = $3 - $5; } | '0' { $$ = 0; } | Succ '(' T_NatNumberPlusNeg ')' { $$ = $3 + 1; } | Pred '(' T_NatNumberPlusNeg ')' { $$ = $3 - 1; }; T_DecString : '+' '(' T_DecimalDigit ',' T_DecString ')' { F_1 (&$$,$3,$5); } | '+' '+' '(' T_DecString ',' T_DecString ')' { F_1 (&$$,$4,$6); } | Dec '(' T_DecimalDigit ')' { F_1 (&$$,"",$3); } | Reverse '(' T_DecString ')' { F_2 (&$$,$3); }; T_DecimalDigit : '0' { F_1 (&$$,"","0"); } | '1' { F_1 (&$$,"","1"); } | '2' { F_1 (&$$,"","2"); } | '3' { F_1 (&$$,"","3"); } | '4' { F_1 (&$$,"","4"); } | '5' { F_1 (&$$,"","5"); } | '6' { F_1 (&$$,"","6"); } | '7' { F_1 (&$$,"","7"); } | '8' { F_1 (&$$,"","8"); } | '9' { F_1 (&$$,"","9"); } | Succ '(' T_DecimalDigit ')' { F_3 (&$$,$3); }; T_OCTETSTRING : T_OctetString { push_pt_type_stack ("OCTETSTRING"); valeur (pt_type_stack_top->pt_type,strlen ($1),$1); $$ = par_valeur_ptr; }; T_OctetString : '+' '(' T_Octet ',' T_OctetString ')' { F_1 (&$$,$3,$5); } | '+' '+' '(' T_OctetString ',' T_OctetString ')' { F_1 (&$$,$4,$6); } | '<' '>' { F_1 (&$$,"",""); } | Octet '(' T_Octet ')' { F_1 (&$$,"",$3); } | Reverse '(' T_OctetString ')' { F_2 (&$$,$3); }; T_Octet : Octet '(' T_Bit ',' T_Bit ',' T_Bit ',' T_Bit ',' T_Bit ',' T_Bit ',' T_Bit ',' T_Bit ')' { F_5 (&$$,$3,$5,$7,$9,$11,$13,$15,$17); }; T_BitStringPlusThOf :'+' '(' T_Bit ',' T_BitStringPlusThOf ')' { F_1 (&$$,$3,$5); } | '+' '+' '(' T_BitStringPlusThOf ',' T_BitStringPlusThOf ')' { F_1 (&$$,$4,$6); } | Bit '(' T_Bit ')' { F_1 (&$$,"",$3); } | Reverse '(' T_BitStringPlusThOf ')' { F_2 (&$$,$3); }; T_Bit : '0' { F_1 (&$$,"","0"); } | '1' { F_1 (&$$,"","1"); } | '<' '(' T_Bit ',' T_Bit ')' { F_6 (&$$,$3,$5,1); } | '<' '>' '(' T_Bit ',' T_Bit ')' { F_6 (&$$,$4,$6,2); } | '=' '<' '(' T_Bit ',' T_Bit ')' { F_6 (&$$,$4,$6,3); } | '=' '=' '(' T_Bit ',' T_Bit ')' { F_6 (&$$,$4,$6,4); } | '>' '(' T_Bit ',' T_Bit ')' { F_6 (&$$,$3,$5,5); } | '>' '=' '(' T_Bit ',' T_Bit ')' { F_6 (&$$,$4,$6,6); } | Bit1 '(' T_Octet ')' { F_7 (&$$,$3,1); } | Bit2 '(' T_Octet ')' { F_7 (&$$,$3,2); } | Bit3 '(' T_Octet ')' { F_7 (&$$,$3,3); } | Bit4 '(' T_Octet ')' { F_7 (&$$,$3,4); } | Bit5 '(' T_Octet ')' { F_7 (&$$,$3,5); } | Bit6 '(' T_Octet ')' { F_7 (&$$,$3,6); } | Bit7 '(' T_Octet ')' { F_7 (&$$,$3,7); } | Bit8 '(' T_Octet ')' { F_7 (&$$,$3,8); } | Succ '(' T_Bit ')' { F_8 (&$$,$3); } | and '(' T_Bit ',' T_Bit ')' { F_6 (&$$,$3,$5,7); } | eq '(' T_Bit ',' T_Bit ')' { F_6 (&$$,$3,$5,4); } | ne '(' T_Bit ',' T_Bit ')' { F_6 (&$$,$3,$5,2); } | not '(' T_Bit ')' { F_8 (&$$,$3); } | or '(' T_Bit ',' T_Bit ')' { F_6 (&$$,$3,$5,8); } | thof '(' T_Nat ',' T_BitStringPlusThOf ')' { F_9 (&$$,$3,$5); }; %% # include "generated_lex.c" -- Pierre Laplante Universite de Montreal, Dep. I.R.O. X-220, C.P. 6128, succursale A Montreal (Quebec) H3C 3J7, (514) 343-6830, laplante@iro.umontreal.ca