Logo AND Algorithmique Numérique Distribuée

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