PIPS
solpip_parse.y
Go to the documentation of this file.
1 /*
2 
3  $Id: solpip_parse.y 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 /* Name : solpip_parse.y
26  * Package : paf-util
27  * Author : F. Lamour, F. Dumontet
28  * Date : 25 march 1993
29  * Historic : 2 august 93, moved into (package) paf-util, AP
30  * Documents:
31  *
32  * Comments :
33  * Grammaire Yacc pour interpreter une solution fournie par PIP en un "quast
34  * newgen".
35  */
36 
37 %{
38 #ifdef HAVE_CONFIG_H
39  #include "pips_config.h"
40 #endif
41 #include <stdio.h>
42 #include <string.h>
43 #include <errno.h>
44 
45 /* Newgen includes */
46 #include "genC.h"
47 
48 /* C3 includes */
49 #include "boolean.h"
50 #include "arithmetique.h"
51 #include "vecteur.h"
52 #include "contrainte.h"
53 #include "ray_dte.h"
54 #include "sommet.h"
55 #include "sg.h"
56 #include "sc.h"
57 #include "polyedre.h"
58 #include "matrix.h"
59 
60 /* Pips includes */
61 #include "ri.h"
62 #include "constants.h"
63 #include "ri-util.h"
64 #include "misc.h"
65 #include "bootstrap.h"
66 #include "graph.h"
67 #include "paf_ri.h"
68 #include "paf-util.h"
69 
70 %}
71 
72 %union{
73 int valeur;
74 char identificateur;
75 char *blabla;
76 }
77 
78 %start quast_sol
79 %token <valeur> ENTIER
80 %token <blabla> TEXTE
81 %token LST LPAR RPAR LCRO RCRO DIES IF NEWPARM DIV DIV_OP MOINS_OP
82 %type <valeur> coefficient
83 
84 %left DIV_OP
85 %right MOINS_OP
86 
87 
88 %%
89 
90 
91 /* Les regles de grammaire definissant une solution de PIP */
92 
93 
94 quast_sol : LPAR LPAR commentaire RPAR
95  {
96  init_new_base ();
97  }
98  super_quast RPAR
99  ;
100 
101 commentaire :
102  |
103  TEXTE {}
104  |
105  commentaire TEXTE
106  |
107  commentaire LPAR commentaire RPAR commentaire
108  ;
109 
110 
111 super_quast : LPAR
112  {
113  init_quast();
114  }
115  quast RPAR
116  {
117  fait_quast();
118  }
119 
120  | nouveau_parametre super_quast
121  {
122  retire_par_de_pile();
123  }
124  ;
125 
126 
127 quast : forme
128  {
129  creer_quast_value ();
130  }
131  | IF vecteur1
132  {
133  creer_predicat();
134  }
135  super_quast
136  {
137  creer_true_quast ();
138  }
139  super_quast
140  {
141  fait_quast_value ();
142  }
143  ;
144 
145 
146 forme :
147  | LST
148  {
149  init_liste_vecteur ();
150  }
151  liste_vecteur
152  ;
153 
154 
155 nouveau_parametre : NEWPARM ENTIER LPAR DIV vecteur2 ENTIER RPAR RPAR
156  {
157  printf("nouveau_parametre1");
158  ajoute_new_var( $6 , $2 );
159  }
160  ;
161 
162 
163 liste_vecteur : vecteur
164  | liste_vecteur vecteur
165  ;
166 
167 
168 vecteur : DIES LCRO
169  {
170  init_vecteur ();
171  }
172  liste_coefficient RCRO
173  {
174  ecrit_liste_vecteur();
175  }
176  ;
177 
178 liste_coefficient : coefficient {}
179  | liste_coefficient coefficient
180  ;
181 
182 
183 coefficient : MOINS_OP ENTIER
184  {
185  ecrit_une_var_neg( $2 );
186  }
187  | ENTIER
188  {
189  ecrit_une_var( $1 );
190  }
191  ;
192 
193 vecteur2 : DIES LCRO
194  {
195  init_vecteur ();
196  }
197  liste_coefficient2 RCRO
198  ;
199 
200 liste_coefficient2: coefficient2
201  | liste_coefficient2 coefficient2
202  ;
203 
204 
205 coefficient2 : MOINS_OP ENTIER
206  {
207  ecrit_coeff_neg2 ( $2 );
208  }
209  | ENTIER {}
210  ;
211 
212 vecteur1 : DIES LCRO
213  {
214  creer_Psysteme();
215  }
216  liste_coefficient1 RCRO
217  ;
218 
219 liste_coefficient1: coefficient1
220  | liste_coefficient1 coefficient1
221  ;
222 
223 
224 coefficient1 : MOINS_OP ENTIER
225  {
226  ecrit_coeff1 ( -$2 );
227  }
228  | ENTIER
229  {
230  ecrit_coeff1 ( $1 );
231  }
232 
233  ;
234 
235 %%
236 
237 void yyerror(char* s)
238 {
239  fputs(s,stderr);
240  putc('\n',stderr);
241 }
242 
243