Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMC-SOG
PN-Parser
Commits
fe85a630
Commit
fe85a630
authored
Oct 14, 2018
by
Jaime Arias
Browse files
Fix spaces
parent
2050cdb8
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/RdPMonteur.l
View file @
fe85a630
...
...
@@ -8,27 +8,27 @@
%}
%%
"(" { return('('); }
")" { return(')'); }
"{" { return('{'); }
"}" { return('}'); }
":" { return(':'); }
";" { return(';'); }
"<."[ ]*".>" { return(TOKEN);}
"<." { return('['); }
".>" { return(']'); }
"<" { return(INHIBITOR); }
"#trans" { return(TRANS);}
"#place" { return(PLACE);}
"#queue" { return(QUEUE);}
"#endtr" { return(ENDTR);}
"reset" { return(RESET);}
"loss" { return(LOSS);}
mk/[ ]*"(" { return(MK);}
cp/[ ]*"(" { return(CP);}
^in { return(IN);}
^out { return(OUT);}
[0-9]+ { sscanf(yytext,"%d",&yylval.i); return(ENTIER);}
[a-zA-Z_][a-zA-Z0-9_]* { yylval.s
=
strdup(yytext); return(VARIABLE);}
[ \t\n] {}
"("
{ return('('); }
")"
{ return(')'); }
"{"
{ return('{'); }
"}"
{ return('}'); }
":"
{ return(':'); }
";"
{ return(';'); }
"<."[ ]*".>"
{ return(TOKEN);}
"<."
{ return('['); }
".>"
{ return(']'); }
"<"
{ return(INHIBITOR); }
"#trans"
{ return(TRANS);}
"#place"
{ return(PLACE);}
"#queue"
{ return(QUEUE);}
"#endtr"
{ return(ENDTR);}
"reset"
{ return(RESET);}
"loss"
{ return(LOSS);}
mk/[ ]*"("
{ return(MK);}
cp/[ ]*"("
{ return(CP);}
^in
{ return(IN);}
^out
{ return(OUT);}
[0-9]+
{ sscanf(yytext,"%d",&yylval.i); return(ENTIER);}
[a-zA-Z_][a-zA-Z0-9_]*
{ yylval.s
=
strdup(yytext); return(VARIABLE);}
[ \t\n]
{}
%%
src/RdPMonteur.y
View file @
fe85a630
...
...
@@ -2,9 +2,7 @@
/* .......... Declarations C ........*/
//#include <stdio.h>
#include <string>
//#include <iostream>
#include <stdio.h>
#include "RdPMonteur.h"
...
...
@@ -17,11 +15,12 @@ extern char yytext[];
/*........... Code C additionnel ....*/
extern "C" {
int yylex();
int yyerror(const char* s){
printf("parsing error\n");
return (1);
}
int yywrap(){
return (1);
}
...
...
@@ -30,7 +29,7 @@ extern "C" {
%}
/*........... Declarations Yacc .....*/
%union {
%union {
int i;
char *s;
}
...
...
@@ -53,45 +52,45 @@ extern "C" {
reseau : noeud | reseau noeud
;
noeud : place | queue | transition
noeud : place | queue | transition
;
/***********************/
/* lecture d'une place */
/***********************/
place : PLACE VARIABLE
{
place : PLACE VARIABLE
{
if(!R->addPlace($2))
{
{
yyerror("");return(1);
}
}
| PLACE VARIABLE MK '(' marquage ')'
{
{
if(!R->addPlace($2,$5))
{
{
yyerror("");return(1);
}
}
| PLACE VARIABLE CP '(' ENTIER ')'
{
{
if(!R->addPlace($2,0,$5))
{
{
yyerror("");return(1);
}
}
| PLACE VARIABLE MK '(' marquage ')' CP '(' ENTIER ')'
{
{
if(!R->addPlace($2,$5,$9))
{
{
yyerror("");return(1);
}
}
| PLACE VARIABLE CP '(' ENTIER ')' MK '(' marquage ')'
{
{
if(!R->addPlace($2,$9,$5))
{
{
yyerror("");return(1);
}
}
...
...
@@ -101,38 +100,38 @@ place : PLACE VARIABLE
/* lecture d'une queue */
/***********************/
queue : QUEUE VARIABLE
{
queue : QUEUE VARIABLE
{
if(!R->addQueue($2))
{
{
yyerror("");return(1);
}
}
| QUEUE VARIABLE CP '(' ENTIER ')'
{
{
if(!R->addQueue($2,$5))
{
{
yyerror("");return(1);
}
}
| QUEUE VARIABLE LOSS
{
| QUEUE VARIABLE LOSS
{
if(!R->addLossQueue($2))
{
{
yyerror("");return(1);
}
}
| QUEUE VARIABLE LOSS CP '(' ENTIER ')'
{
{
if(!R->addLossQueue($2,$6))
{
{
yyerror("");return(1);
}
}
| QUEUE VARIABLE CP '(' ENTIER ')' LOSS
{
{
if(!R->addLossQueue($2,$5))
{
{
yyerror("");return(1);
}
}
...
...
@@ -144,7 +143,7 @@ queue : QUEUE VARIABLE
nomtransition : TRANS VARIABLE
{
if(!R->addTrans($2))
{
{
yyerror("");return(1);
}
t=$2;
...
...
@@ -172,75 +171,75 @@ sortie : OUT '{' listearcout '}'
/* lecture d'un arc */
/***************************************/
listearcin : listearcin VARIABLE ':' marquage ';'
{
listearcin : listearcin VARIABLE ':' marquage ';'
{
if(!R->addPre($2,t,$4))
{
{
yyerror("");return(1);
}
}
}
| listearcin VARIABLE ':' '[' ENTIER ']' ';'
{
| listearcin VARIABLE ':' '[' ENTIER ']' ';'
{
if(!R->addPreQueue($2,t,$5))
{
{
yyerror("");return(1);
}
}
}
| listearcin VARIABLE ':' RESET ';'
{
| listearcin VARIABLE ':' RESET ';'
{
if(!R->addReset($2,t))
{
{
yyerror("");return(1);
}
}
}
| listearcin VARIABLE INHIBITOR ENTIER ';'
{
| listearcin VARIABLE INHIBITOR ENTIER ';'
{
if(!R->addInhibitor($2,t,$4))
{
{
yyerror("");return(1);
}
}
}
| listearcin VARIABLE ':' VARIABLE ';'
{
| listearcin VARIABLE ':' VARIABLE ';'
{
if(!R->addPreAuto($2,t,$4))
{
{
yyerror("");return(1);
}
}
}
|
;
listearcout : listearcout VARIABLE ':' marquage ';'
{
{
if(!R->addPost($2,t,$4))
{
{
yyerror("");return(1);
}
}
| listearcout VARIABLE ':' '[' ENTIER ']' ';'
{
| listearcout VARIABLE ':' '[' ENTIER ']' ';'
{
if(!R->addPostQueue($2,t,$5))
{
{
yyerror("");return(1);
}
}
}
| listearcout VARIABLE ':' VARIABLE ';'
{
{
if(!R->addPostAuto($2,t,$4))
{
{
yyerror("");return(1);
}
}
|
;
marquage : TOKEN {$$=1;}
marquage : TOKEN {$$=1;}
|
ENTIER TOKEN {$$=$1;}
;
%%
bool RdPMonteur::create(const char *f){
bool RdPMonteur::create(const char *f){
int i;
if ((yyin=fopen(f,"r"))==NULL)
return false;
...
...
@@ -249,5 +248,3 @@ bool RdPMonteur::create(const char *f){
fclose(yyin);
return (i==0);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment