Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / xbt / automaton / parserPromela.lex
index f4c9132..2207f74 100644 (file)
@@ -1,13 +1,23 @@
+/* Copyright (c) 2012-2022. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
 %option noyywrap
 
 %{
 
+#include "simgrid/config.h"
+#if !HAVE_UNISTD_H
+#define YY_NO_UNISTD_H /* hello Windows */
+#endif
 
 #include <stdio.h>
-#include "y.tab.h"
-  
+#include "parserPromela.tab.hacc"
+
   extern YYSTYPE yylval;
+
 %}
 
 blancs       [ \t]+
@@ -27,51 +37,46 @@ commentaire  "/*"([^\*\/]*{nouv_ligne}*[^\*\/]*)*"*/"
 
 %%
 
-"never"      { printf("%s", yytext); return (NEVER); }
-"if"         { printf("%s", yytext); return (IF); }
-"fi"         { printf("%s", yytext); 
-               return (FI); }
-"->"         { printf("%s", yytext); return (IMPLIES); }
-"goto"       { printf("%s", yytext); return (GOTO); }
-"&&"         { printf("%s", yytext); return (AND); }
-"||"         { printf("%s", yytext); return (OR); }
-"!"          { printf("%s", yytext); return (NOT); }
-"("          { printf("%s", yytext); return (LEFT_PAR); }
-")"          { printf("%s", yytext); return (RIGHT_PAR); }
-"::"         { printf("%s", yytext); return (CASE); }
-":"          { printf("%s", yytext); return (COLON); }
-";"          { printf("%s", yytext); return (SEMI_COLON); }
-"1"          { printf("%s", yytext); return (CASE_TRUE); }
-"{"          { printf("%s", yytext); return (LEFT_BRACE); }
-"}"          { printf("%s", yytext); return (RIGHT_BRACE); }
+"never"      { return (NEVER); }
+"if"         { return (IF); }
+"fi"         { return (FI); }
+"->"         { return (IMPLIES); }
+"goto"       { return (GOTO); }
+"&&"         { return (AND); }
+"||"         { return (OR); }
+"!"          { return (NOT); }
+"("          { return (LEFT_PAR); }
+")"          { return (RIGHT_PAR); }
+"::"         { return (CASE); }
+":"          { return (COLON); }
+";"          { return (SEMI_COLON); }
+"1"          { return (CASE_TRUE); }
+"{"          { return (LEFT_BRACE); }
+"}"          { return (RIGHT_BRACE); }
 
 
-{commentaire}             { printf(" ");}
+{commentaire}             { }
 
-{blancs}                  { printf("%s",yytext); }
+{blancs}                  { }
 
 
-{reel}                    { printf("%s",yytext); 
-                            sscanf(yytext,"%lf",&yylval.real); 
+{reel}                    { sscanf(yytext,"%lf",&yylval.real);
                             return (LITT_REEL); }
 
-{entier}                  { printf("%s",yytext); 
-                            sscanf(yytext,"%d",&yylval.integer); 
+{entier}                  { sscanf(yytext,"%d",&yylval.integer);
                             return (LITT_ENT); }
 
-{chaine}                  { printf("%s",yytext);  
-                            yylval.string=(char *)malloc(strlen(yytext)+1);
-                            sscanf(yytext,"%s",yylval.string); 
+{chaine}                  { yylval.string=(char *)malloc(strlen(yytext)+1);
+                            sscanf(yytext,"%s",yylval.string);
                             return (LITT_CHAINE); }
 
-[a-zA-Z]{caractere}*      { printf("%s",yytext); 
-                           yylval.string=(char *)malloc(strlen(yytext)+1);
-                           sscanf(yytext,"%s",yylval.string);
-                           return (ID); }
-                  
-{numl}                    { printf("\n"); }
+[a-zA-Z]{caractere}*      { yylval.string=(char *)malloc(strlen(yytext)+1);
+                            sscanf(yytext,"%s",yylval.string);
+                                             return (ID); }
+
+{numl}                    { }
 
-.                         { printf("caractère inconnu\n"); }
+.                         { }
 
 %%