Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
f4c913280e6c11c02cbe9c262ad19a8b9ef8ca7a
[simgrid.git] / src / xbt / automaton / parserPromela.lex
1 %option noyywrap
2
3 %{
4
5
6 #include <stdio.h>
7 #include "y.tab.h"
8   
9   extern YYSTYPE yylval;
10  
11 %}
12
13 blancs       [ \t]+
14 espace       [ ]+
15 nouv_ligne   [ \n]
16
17 chiffre      [0-9]
18 entier       {chiffre}+
19 reel         {entier}("."{entier})
20 caractere    [a-zA-Z0-9_]
21
22 numl         \n
23
24 chaine       \"({caractere}*|\n|\\|\"|{espace}*)*\"
25
26 commentaire  "/*"([^\*\/]*{nouv_ligne}*[^\*\/]*)*"*/"
27
28 %%
29
30 "never"      { printf("%s", yytext); return (NEVER); }
31 "if"         { printf("%s", yytext); return (IF); }
32 "fi"         { printf("%s", yytext); 
33                return (FI); }
34 "->"         { printf("%s", yytext); return (IMPLIES); }
35 "goto"       { printf("%s", yytext); return (GOTO); }
36 "&&"         { printf("%s", yytext); return (AND); }
37 "||"         { printf("%s", yytext); return (OR); }
38 "!"          { printf("%s", yytext); return (NOT); }
39 "("          { printf("%s", yytext); return (LEFT_PAR); }
40 ")"          { printf("%s", yytext); return (RIGHT_PAR); }
41 "::"         { printf("%s", yytext); return (CASE); }
42 ":"          { printf("%s", yytext); return (COLON); }
43 ";"          { printf("%s", yytext); return (SEMI_COLON); }
44 "1"          { printf("%s", yytext); return (CASE_TRUE); }
45 "{"          { printf("%s", yytext); return (LEFT_BRACE); }
46 "}"          { printf("%s", yytext); return (RIGHT_BRACE); }
47
48
49 {commentaire}             { printf(" ");}
50
51 {blancs}                  { printf("%s",yytext); }
52
53
54 {reel}                    { printf("%s",yytext); 
55                             sscanf(yytext,"%lf",&yylval.real); 
56                             return (LITT_REEL); }
57
58 {entier}                  { printf("%s",yytext); 
59                             sscanf(yytext,"%d",&yylval.integer); 
60                             return (LITT_ENT); }
61
62 {chaine}                  { printf("%s",yytext);  
63                             yylval.string=(char *)malloc(strlen(yytext)+1);
64                             sscanf(yytext,"%s",yylval.string); 
65                             return (LITT_CHAINE); }
66
67 [a-zA-Z]{caractere}*      { printf("%s",yytext); 
68                             yylval.string=(char *)malloc(strlen(yytext)+1);
69                             sscanf(yytext,"%s",yylval.string);
70                             return (ID); }
71                    
72 {numl}                    { printf("\n"); }
73
74 .                         { printf("caractère inconnu\n"); }
75
76 %%
77
78