Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Extend xbt_propositional_symbols
[simgrid.git] / src / xbt / automaton / parserPromela.lex
1 /* Copyright (c) 2012, 2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 %option noyywrap
8
9 %{
10
11
12 #include <stdio.h>
13 #include "parserPromela.tab.hacc"
14   
15   extern YYSTYPE yylval;
16  
17 %}
18
19 blancs       [ \t]+
20 espace       [ ]+
21 nouv_ligne   [ \n]
22
23 chiffre      [0-9]
24 entier       {chiffre}+
25 reel         {entier}("."{entier})
26 caractere    [a-zA-Z0-9_]
27
28 numl         \n
29
30 chaine       \"({caractere}*|\n|\\|\"|{espace}*)*\"
31
32 commentaire  "/*"([^\*\/]*{nouv_ligne}*[^\*\/]*)*"*/"
33
34 %%
35
36 "never"      { return (NEVER); }
37 "if"         { return (IF); }
38 "fi"         { return (FI); }
39 "->"         { return (IMPLIES); }
40 "goto"       { return (GOTO); }
41 "&&"         { return (AND); }
42 "||"         { return (OR); }
43 "!"          { return (NOT); }
44 "("          { return (LEFT_PAR); }
45 ")"          { return (RIGHT_PAR); }
46 "::"         { return (CASE); }
47 ":"          { return (COLON); }
48 ";"          { return (SEMI_COLON); }
49 "1"          { return (CASE_TRUE); }
50 "{"          { return (LEFT_BRACE); }
51 "}"          { return (RIGHT_BRACE); }
52
53
54 {commentaire}             { }
55
56 {blancs}                  { }
57
58
59 {reel}                    { sscanf(yytext,"%lf",&yylval.real); 
60                             return (LITT_REEL); }
61
62 {entier}                  { sscanf(yytext,"%d",&yylval.integer); 
63                             return (LITT_ENT); }
64
65 {chaine}                  { yylval.string=(char *)malloc(strlen(yytext)+1);
66                             sscanf(yytext,"%s",yylval.string); 
67                             return (LITT_CHAINE); }
68
69 [a-zA-Z]{caractere}*      { yylval.string=(char *)malloc(strlen(yytext)+1);
70                             sscanf(yytext,"%s",yylval.string);
71                                               return (ID); }
72                    
73 {numl}                    { }
74
75 .                         { }
76
77 %%
78
79