Commit fe85a630 authored by Jaime Arias's avatar Jaime Arias
Browse files

Fix spaces

parent 2050cdb8
...@@ -8,27 +8,27 @@ ...@@ -8,27 +8,27 @@
%} %}
%% %%
"(" { return('('); } "(" { return('('); }
")" { return(')'); } ")" { return(')'); }
"{" { return('{'); } "{" { return('{'); }
"}" { return('}'); } "}" { return('}'); }
":" { return(':'); } ":" { return(':'); }
";" { return(';'); } ";" { return(';'); }
"<."[ ]*".>" { return(TOKEN);} "<."[ ]*".>" { return(TOKEN);}
"<." { return('['); } "<." { return('['); }
".>" { return(']'); } ".>" { return(']'); }
"<" { return(INHIBITOR); } "<" { return(INHIBITOR); }
"#trans" { return(TRANS);} "#trans" { return(TRANS);}
"#place" { return(PLACE);} "#place" { return(PLACE);}
"#queue" { return(QUEUE);} "#queue" { return(QUEUE);}
"#endtr" { return(ENDTR);} "#endtr" { return(ENDTR);}
"reset" { return(RESET);} "reset" { return(RESET);}
"loss" { return(LOSS);} "loss" { return(LOSS);}
mk/[ ]*"(" { return(MK);} mk/[ ]*"(" { return(MK);}
cp/[ ]*"(" { return(CP);} cp/[ ]*"(" { return(CP);}
^in { return(IN);} ^in { return(IN);}
^out { return(OUT);} ^out { return(OUT);}
[0-9]+ { sscanf(yytext,"%d",&yylval.i); return(ENTIER);} [0-9]+ { sscanf(yytext,"%d",&yylval.i); return(ENTIER);}
[a-zA-Z_][a-zA-Z0-9_]* { yylval.s=strdup(yytext); return(VARIABLE);} [a-zA-Z_][a-zA-Z0-9_]* { yylval.s = strdup(yytext); return(VARIABLE);}
[ \t\n] {} [ \t\n] {}
%% %%
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
/* .......... Declarations C ........*/ /* .......... Declarations C ........*/
//#include <stdio.h>
#include <string> #include <string>
//#include <iostream>
#include <stdio.h> #include <stdio.h>
#include "RdPMonteur.h" #include "RdPMonteur.h"
...@@ -17,11 +15,12 @@ extern char yytext[]; ...@@ -17,11 +15,12 @@ extern char yytext[];
/*........... Code C additionnel ....*/ /*........... Code C additionnel ....*/
extern "C" { extern "C" {
int yylex(); int yylex();
int yyerror(const char* s){ int yyerror(const char* s){
printf("parsing error\n"); printf("parsing error\n");
return (1); return (1);
} }
int yywrap(){ int yywrap(){
return (1); return (1);
} }
...@@ -30,7 +29,7 @@ extern "C" { ...@@ -30,7 +29,7 @@ extern "C" {
%} %}
/*........... Declarations Yacc .....*/ /*........... Declarations Yacc .....*/
%union { %union {
int i; int i;
char *s; char *s;
} }
...@@ -53,45 +52,45 @@ extern "C" { ...@@ -53,45 +52,45 @@ extern "C" {
reseau : noeud | reseau noeud reseau : noeud | reseau noeud
; ;
noeud : place | queue | transition noeud : place | queue | transition
; ;
/***********************/ /***********************/
/* lecture d'une place */ /* lecture d'une place */
/***********************/ /***********************/
place : PLACE VARIABLE place : PLACE VARIABLE
{ {
if(!R->addPlace($2)) if(!R->addPlace($2))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| PLACE VARIABLE MK '(' marquage ')' | PLACE VARIABLE MK '(' marquage ')'
{ {
if(!R->addPlace($2,$5)) if(!R->addPlace($2,$5))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| PLACE VARIABLE CP '(' ENTIER ')' | PLACE VARIABLE CP '(' ENTIER ')'
{ {
if(!R->addPlace($2,0,$5)) if(!R->addPlace($2,0,$5))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| PLACE VARIABLE MK '(' marquage ')' CP '(' ENTIER ')' | PLACE VARIABLE MK '(' marquage ')' CP '(' ENTIER ')'
{ {
if(!R->addPlace($2,$5,$9)) if(!R->addPlace($2,$5,$9))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| PLACE VARIABLE CP '(' ENTIER ')' MK '(' marquage ')' | PLACE VARIABLE CP '(' ENTIER ')' MK '(' marquage ')'
{ {
if(!R->addPlace($2,$9,$5)) if(!R->addPlace($2,$9,$5))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
...@@ -101,38 +100,38 @@ place : PLACE VARIABLE ...@@ -101,38 +100,38 @@ place : PLACE VARIABLE
/* lecture d'une queue */ /* lecture d'une queue */
/***********************/ /***********************/
queue : QUEUE VARIABLE queue : QUEUE VARIABLE
{ {
if(!R->addQueue($2)) if(!R->addQueue($2))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| QUEUE VARIABLE CP '(' ENTIER ')' | QUEUE VARIABLE CP '(' ENTIER ')'
{ {
if(!R->addQueue($2,$5)) if(!R->addQueue($2,$5))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| QUEUE VARIABLE LOSS | QUEUE VARIABLE LOSS
{ {
if(!R->addLossQueue($2)) if(!R->addLossQueue($2))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| QUEUE VARIABLE LOSS CP '(' ENTIER ')' | QUEUE VARIABLE LOSS CP '(' ENTIER ')'
{ {
if(!R->addLossQueue($2,$6)) if(!R->addLossQueue($2,$6))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| QUEUE VARIABLE CP '(' ENTIER ')' LOSS | QUEUE VARIABLE CP '(' ENTIER ')' LOSS
{ {
if(!R->addLossQueue($2,$5)) if(!R->addLossQueue($2,$5))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
...@@ -144,7 +143,7 @@ queue : QUEUE VARIABLE ...@@ -144,7 +143,7 @@ queue : QUEUE VARIABLE
nomtransition : TRANS VARIABLE nomtransition : TRANS VARIABLE
{ {
if(!R->addTrans($2)) if(!R->addTrans($2))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
t=$2; t=$2;
...@@ -172,75 +171,75 @@ sortie : OUT '{' listearcout '}' ...@@ -172,75 +171,75 @@ sortie : OUT '{' listearcout '}'
/* lecture d'un arc */ /* lecture d'un arc */
/***************************************/ /***************************************/
listearcin : listearcin VARIABLE ':' marquage ';' listearcin : listearcin VARIABLE ':' marquage ';'
{ {
if(!R->addPre($2,t,$4)) if(!R->addPre($2,t,$4))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| listearcin VARIABLE ':' '[' ENTIER ']' ';' | listearcin VARIABLE ':' '[' ENTIER ']' ';'
{ {
if(!R->addPreQueue($2,t,$5)) if(!R->addPreQueue($2,t,$5))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| listearcin VARIABLE ':' RESET ';' | listearcin VARIABLE ':' RESET ';'
{ {
if(!R->addReset($2,t)) if(!R->addReset($2,t))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| listearcin VARIABLE INHIBITOR ENTIER ';' | listearcin VARIABLE INHIBITOR ENTIER ';'
{ {
if(!R->addInhibitor($2,t,$4)) if(!R->addInhibitor($2,t,$4))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| listearcin VARIABLE ':' VARIABLE ';' | listearcin VARIABLE ':' VARIABLE ';'
{ {
if(!R->addPreAuto($2,t,$4)) if(!R->addPreAuto($2,t,$4))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| |
; ;
listearcout : listearcout VARIABLE ':' marquage ';' listearcout : listearcout VARIABLE ':' marquage ';'
{ {
if(!R->addPost($2,t,$4)) if(!R->addPost($2,t,$4))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| listearcout VARIABLE ':' '[' ENTIER ']' ';' | listearcout VARIABLE ':' '[' ENTIER ']' ';'
{ {
if(!R->addPostQueue($2,t,$5)) if(!R->addPostQueue($2,t,$5))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| listearcout VARIABLE ':' VARIABLE ';' | listearcout VARIABLE ':' VARIABLE ';'
{ {
if(!R->addPostAuto($2,t,$4)) if(!R->addPostAuto($2,t,$4))
{ {
yyerror("");return(1); yyerror("");return(1);
} }
} }
| |
; ;
marquage : TOKEN {$$=1;} marquage : TOKEN {$$=1;}
| |
ENTIER TOKEN {$$=$1;} ENTIER TOKEN {$$=$1;}
; ;
%% %%
bool RdPMonteur::create(const char *f){ bool RdPMonteur::create(const char *f){
int i; int i;
if ((yyin=fopen(f,"r"))==NULL) if ((yyin=fopen(f,"r"))==NULL)
return false; return false;
...@@ -249,5 +248,3 @@ bool RdPMonteur::create(const char *f){ ...@@ -249,5 +248,3 @@ bool RdPMonteur::create(const char *f){
fclose(yyin); fclose(yyin);
return (i==0); return (i==0);
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment