Logo AND Algorithmique Numérique Distribuée

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