Rev 10 | Rev 12963 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 10 | Rev 104 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | /* -*- coding: utf-8 -*- */ |
|
1 | %option noyywrap |
2 | %option noyywrap |
2 | %option c++ |
3 | %option c++ |
3 | 4 | ||
4 | #include <stdlib.h> |
5 | #include <stdlib.h> |
5 | #include "chemeq.h" |
6 | #include "chemeq.h" |
Line 13... | Line 14... | ||
13 | digits [0-9] |
14 | digits [0-9] |
14 | spc [ \t]+ |
15 | spc [ \t]+ |
15 | int {digits}+ |
16 | int {digits}+ |
16 | frac {int}{spc}?[/]{spc}?{int} |
17 | frac {int}{spc}?[/]{spc}?{int} |
17 | mantisse {digits}+ |
18 | mantisse {digits}+ |
18 | real {int}([.]{mantisse})?([Ee][+-]?{int})? |
19 | real -?{int}([.]{mantisse})?([Ee][+-]?{int})? |
19 | eol \n.* |
20 | eol \n.* |
20 | 21 | ||
21 | /* la flèche */ |
22 | /* la flèche */ |
22 | fleche [-]+> |
23 | fleche [-]+> |
23 | 24 | ||
24 | %% |
25 | %% |
25 | /* les règles */ |
26 | /* les règles */ |
26 | 27 | ||
27 | /* pour les atomes */ |
28 | /* pour les atomes */ |
28 | Uu[a-z]|[A-Z][a-z]? { /* |
29 | Uu[a-z]|[A-Z][a-z]? { /* éléments Uux : transuraniens après le N° 109 |
29 | les autres sont les éléments ordinaires */ |
30 | les autres sont les éléments ordinaires */ |
30 | int i = 0; |
31 | int i = 0; |
31 | position += strlen(yytext); |
32 | position += strlen(yytext); |
32 | while (lesatomes[i].Zed != 0 && strcmp(yytext, lesatomes[i].symb)) i++; |
33 | while (lesatomes[i].Zed != 0 && strcmp(yytext, lesatomes[i].symb)) i++; |
33 | if (lesatomes[i].Zed == 0){ |
34 | if (lesatomes[i].Zed == 0){ |
34 | yylval.i=-2; /* -2 est le n° pour les éléments non définis */ |
35 | yylval.i=-2; /* -2 est le n° pour les éléments non définis */ |
35 | strncpy(yylval.symb, yytext,3); |
36 | strncpy(yylval.symb, yytext,3); |
36 | } |
37 | } |
37 | else { |
38 | else { |
38 | yylval.i=i; |
39 | yylval.i=i; |
39 | strcpy(yylval.symb, lesatomes[i].symb); |
40 | strcpy(yylval.symb, lesatomes[i].symb); |
Line 66... | Line 67... | ||
66 | \-[\-]+ { position += strlen(yytext); yylval.i = -strlen(yytext); |
67 | \-[\-]+ { position += strlen(yytext); yylval.i = -strlen(yytext); |
67 | return Charge; |
68 | return Charge; |
68 | } |
69 | } |
69 | {int}\+ { position += strlen(yytext); yytext[strlen(yytext)]=0; |
70 | {int}\+ { position += strlen(yytext); yytext[strlen(yytext)]=0; |
70 | yylval.i = atoi(yytext); return Charge; |
71 | yylval.i = atoi(yytext); return Charge; |
71 | } |
- | |
72 | \-{int} { position += strlen(yytext); yylval.i = -atoi(yytext+1); |
- | |
73 | return Charge; |
- | |
74 | } |
72 | } |
75 | {int}\- { position += strlen(yytext); yytext[strlen(yytext)]=0; |
73 | {int}\- { position += strlen(yytext); yytext[strlen(yytext)]=0; |
76 | yylval.i = -atoi(yytext); return Charge; |
74 | yylval.i = -atoi(yytext); return Charge; |
77 | } |
75 | } |
78 | {spc}+\+ {position += strlen(yytext); return SpcPlus;} |
76 | {spc}+\+ {position += strlen(yytext); return SpcPlus;} |
79 | \- {position += strlen(yytext); return Moins;} |
77 | \- {position += strlen(yytext); return Moins;} |
80 | \+ { |
78 | \+ {position ++; return Plus;} |
- | 79 | \* {position ++; return Mul;} |
|
81 | {fleche} {position += strlen(yytext); return Fleche;} |
80 | {fleche} {position += strlen(yytext); return Fleche;} |
82 | {spc} {position += strlen(yytext); return Spc;} |
81 | {spc} {position += strlen(yytext); return Spc;} |
83 | \^ {position ++; return Haut;} |
82 | \^ {position ++; return Haut;} |
84 | _s|s {position += strlen(yytext); return Sol;} |
83 | _s|s {position += strlen(yytext); return Sol;} |
85 | _g|g {position += strlen(yytext); return Gas;} |
84 | _g|g {position += strlen(yytext); return Gas;} |
86 | _ag|aq {position += strlen(yytext); return Aqueous;} |
85 | _ag|aq {position += strlen(yytext); return Aqueous;} |
87 | = {position ++; return Egal;} |
86 | = {position ++; return Egal;} |
- | 87 | # {position ++; return Compose;} |
|
- | 88 | ~ {position+=2; return AntiCompose;} |
|
88 | {eol} {/* rien c'est la fin des entrées */} |
89 | {eol} {/* rien c'est la fin des entrées */} |
89 | .|\n {position += strlen(yytext); /* rien */} |
90 | .|\n {position += strlen(yytext); /* rien */} |