Subversion Repositories wimsdev

Rev

Rev 6906 | Rev 12963 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6906 Rev 8206
Line 9... Line 9...
9
#include "chemeq.h"
9
#include "chemeq.h"
10
  //#include <FlexLexer.h>
10
  //#include <FlexLexer.h>
11
#include <sstream>
11
#include <sstream>
12
 
12
 
13
  int yylex();
13
  int yylex();
14
  int yyerror(char * msg);
14
  int yyerror(const char * msg);
15
 
15
 
16
typedef struct{
16
typedef struct{
17
  int i, d; /* integer numerator, denominator */
17
  int i, d; /* integer numerator, denominator */
18
  double r;
18
  double r;
19
  AtomeListe * al;
19
  AtomeListe * al;
Line 23... Line 23...
23
  char symb[4];
23
  char symb[4];
24
  moltype t;
24
  moltype t;
25
  std::string s;
25
  std::string s;
26
} yystype;
26
} yystype;
27
 
27
 
28
#define YYSTYPE yystype 
28
#define YYSTYPE yystype
29
 
29
 
30
/* variables globales */
30
/* variables globales */
31
 
31
 
32
 yystype result;
32
 yystype result;
33
 extern char * yytext;
33
 extern char * yytext;
Line 61... Line 61...
61
%token AntiCompose
61
%token AntiCompose
62
 
62
 
63
%%
63
%%
64
 
64
 
65
/* les règles */
65
/* les règles */
66
but : chcompose { 
66
but : chcompose {
67
  result=$1;
67
  result=$1;
68
  isequation=1;
68
  isequation=1;
69
}
69
}
70
| molec {
70
| molec {
71
  result=$1;
71
  result=$1;
Line 76... Line 76...
76
chcompose : chc {$$=$1;}
76
chcompose : chc {$$=$1;}
77
| chcompose spc01 Compose spc01 chc {
77
| chcompose spc01 Compose spc01 chc {
78
  $1.cq->addChemeq($5.cq);
78
  $1.cq->addChemeq($5.cq);
79
  $$=$1;
79
  $$=$1;
80
}
80
}
81
| chcompose spc01 AntiCompose spc01 chc { 
81
| chcompose spc01 AntiCompose spc01 chc {
82
  $1.cq->subChemeq($5.cq);
82
  $1.cq->subChemeq($5.cq);
83
  $$=$1;
83
  $$=$1;
84
}
84
}
85
;
85
;
86
 
86
 
Line 141... Line 141...
141
| Frac spc01 molec {
141
| Frac spc01 molec {
142
  $$ = $3;
142
  $$ = $3;
143
  $$.m->nombre($1.i,$1.d);
143
  $$.m->nombre($1.i,$1.d);
144
}
144
}
145
| molec{
145
| molec{
146
  $$ = $1; 
146
  $$ = $1;
147
}
147
}
148
;
148
;
149
 
149
 
150
spc01 : /*rien*/
150
spc01 : /*rien*/
151
| Spc
151
| Spc
Line 176... Line 176...
176
| Moins{$$.i=-1;}
176
| Moins{$$.i=-1;}
177
| Haut  Moins{$$.i=-1;}
177
| Haut  Moins{$$.i=-1;}
178
;
178
;
179
 
179
 
180
groupe : Lpar composition Rpar {
180
groupe : Lpar composition Rpar {
181
  $$=$2; 
181
  $$=$2;
182
}
182
}
183
;
183
;
184
 
184
 
185
atome_general : groupe {
185
atome_general : groupe {
186
  $$.al = new AtomeListe("",0,0,$1.al);
186
  $$.al = new AtomeListe("",0,0,$1.al);
Line 208... Line 208...
208
 
208
 
209
molecularite : /*rien*/{
209
molecularite : /*rien*/{
210
  $$.i=1;
210
  $$.i=1;
211
}
211
}
212
| Int {
212
| Int {
213
  $$=$1; 
213
  $$=$1;
214
}
214
}
215
;
215
;
216
 
216
 
217
%%
217
%%
218
#include "chemlex.cc"
218
#include "chemlex.cc"
219
 
219
 
220
yyFlexLexer lexer;
220
yyFlexLexer lexer;
221
yyFlexLexer * thelexer = &lexer;
221
yyFlexLexer * thelexer = &lexer;
Line 224... Line 224...
224
  return thelexer->yylex();
224
  return thelexer->yylex();
225
}
225
}
226
 
226
 
227
/* le programme lui-même */
227
/* le programme lui-même */
228
 
228
 
229
inline int yyerror(char * msg){
229
inline int yyerror(const char * msg){
230
  fprintf(stderr, "ERROR %s at %d\n ", msg, position);
230
  fprintf(stderr, "ERROR %s at %d\n ", msg, position);
231
  exit(1);
231
  exit(1);
232
}
232
}
233
 
233
 
234
void printVersion(){
234
void printVersion(){
Line 281... Line 281...
281
    printVersion(); return 0;
281
    printVersion(); return 0;
282
  }
282
  }
283
  if (envinput !=NULL){
283
  if (envinput !=NULL){
284
    std::istringstream iss(envinput);
284
    std::istringstream iss(envinput);
285
    thelexer= new yyFlexLexer (&iss);
285
    thelexer= new yyFlexLexer (&iss);
286
  } 
286
  }
287
  yyparse();
287
  yyparse();
288
 
288
 
289
  bool wantedlatex=(strchr(asked,'l')!=NULL);
289
  bool wantedlatex=(strchr(asked,'l')!=NULL);
290
  if (isequation) {
290
  if (isequation) {
291
    for(i=0; i<strlen(asked); i++){
291
    for(i=0; i<strlen(asked); i++){