Rev 13325 | Rev 17747 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 13325 | Rev 13327 | ||
---|---|---|---|
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 |
14 | int chemerror(char * msg); |
- | 15 | int yyerror(const char * msg); |
|
15 | 16 | ||
16 | typedef struct{ |
17 | typedef struct{ |
17 | int i, d; /* integer numerator, denominator */ |
18 | int i, d; /* integer numerator, denominator */ |
18 | double r; |
19 | double r; |
19 | AtomeListe * al; |
20 | AtomeListe * al; |
Line 114... | Line 115... | ||
114 | | Plus spc01 Int{$$.r=1.0*$3.i;} |
115 | | Plus spc01 Int{$$.r=1.0*$3.i;} |
115 | | Moins spc01 Int{$$.r=-1.0*$3.i;} |
116 | | Moins spc01 Int{$$.r=-1.0*$3.i;} |
116 | ; |
117 | ; |
117 | 118 | ||
118 | volt : /* rien */ |
119 | volt : /* rien */ |
119 | | spc01 Atome {if ($2.s.compare("V")!=0) |
120 | | spc01 Atome {if ($2.s.compare("V")!=0) chemerror (strdup("only 'V' allowed as unit")); } |
120 | ; |
121 | ; |
121 | 122 | ||
122 | id : Atome {/* $$.s contient le nom */} |
123 | id : Atome {/* $$.s contient le nom */} |
123 | ; |
124 | ; |
124 | 125 | ||
Line 193... | Line 194... | ||
193 | } |
194 | } |
194 | | Atome{ |
195 | | Atome{ |
195 | char buffer[25]; |
196 | char buffer[25]; |
196 | if ($1.i==-2) { /* ce n'est pas un atome recensé */ |
197 | if ($1.i==-2) { /* ce n'est pas un atome recensé */ |
197 | sprintf(buffer,"nonexistent atom : %s", $1.symb); |
198 | sprintf(buffer,"nonexistent atom : %s", $1.symb); |
198 |
|
199 | chemerror(buffer); |
199 | } |
200 | } |
200 | $$.al = new AtomeListe($1.symb,$1.i); |
201 | $$.al = new AtomeListe($1.symb,$1.i); |
201 | } |
202 | } |
202 | ; |
203 | ; |
203 | 204 | ||
Line 230... | Line 231... | ||
230 | return thelexer->yylex(); |
231 | return thelexer->yylex(); |
231 | } |
232 | } |
232 | 233 | ||
233 | /* le programme lui-même */ |
234 | /* le programme lui-même */ |
234 | 235 | ||
235 | inline int |
236 | inline int chemerror(char * msg){ |
236 | fprintf(stderr, "ERROR %s at %d\n ", msg, position); |
237 | fprintf(stderr, "ERROR %s at %d\n ", msg, position); |
- | 238 | exit(1); |
|
- | 239 | } |
|
- | 240 | ||
- | 241 | inline int yyerror(const char * msg){ |
|
- | 242 | printf("ERROR: %s at %d\n", msg, position); |
|
237 | exit(1); |
243 | exit(1); |
238 | } |
244 | } |
239 | 245 | ||
240 | void printVersion(){ |
246 | void printVersion(){ |
241 | std::cout << "Chemeq version " << VERSION << "\n(c) Georges Khaznadar <georgesk@debian.org>."; |
247 | std::cout << "Chemeq version " << VERSION << "\n(c) Georges Khaznadar <georgesk@debian.org>."; |