Next: Références
Up: C2. Les source des
Previous: C2.1 Le programme Lex
  Table des matières
C2.2 Le programme Yacc : service_parser.y
/***
*** Analyseur Syntaxique
***
*** Thomas Nemeth -- Juin 1999
***/
%{
#include <stdio.h>
#include <sys/param.h>
/* #include <iostream.h> */
#include "service.h"
int num_ligne = 1;
char nomfic[MAXPATHLEN];
SERV_LIST *services = NULL;
%}
%union {
int ival;
ID_STR *idStr; /* any string (or symbol) */
ID_LIST *idList; /* list of string value */
SERV_STR *servStr;
SERV_LIST *servList;
SERV_AV_STR *servAv;
}
%token <ival> MODULE SERVICE REQUEST INTER WAIT GROUP
%token <idStr> IDENTIFICATEUR
%type <ival> declaration_top
%type <servList> liste_declaration_service
%type <servStr> declaration_service
%type <servStr> liste_av_service
%type <servStr> attributs_service
%type <servAv> av_service
%type <idList> liste_id
%start declaration_top
%%
declaration_top: liste_declaration_service
{ actions = $1; $$ = 0; }
liste_declaration_service: declaration_service ';'
{ $$ = STR_ALLOC(SERV_LIST);
$$->serv = $1;
$$->next = NULL;
}
| declaration_service ';' liste_declaration_service
{
$$ = STR_ALLOC(SERV_LIST);
$$->serv = $1;
$$->next = $3;
}
;
declaration_service: SERVICE IDENTIFICATEUR attributs_service
{ $$ = $3;
$$->name = $2;
/* switch(correct_resource_postion($3)){
case 1: yyerror("Produce set on an invalid slot");
return 1;
case 2: yyerror("Consume set on an invalid slot");
return 1;
}
switch(correct_eff_cond_postion($3)){
case 1: yyerror("Condition set on an invalid slot");
return 1;
case 2: yyerror("Assertion set on an invalid slot");
return 1;
case 3: yyerror("Effect set on an invalid slot");
return 1;
}
*/
}
attributs_service: '{' liste_av_service '}' { $$ = $2; }
liste_av_service: av_service ';'
{
$$ = STR_ALLOC(ACT_STR);
$$ = ajout_av_service($1, $$);
free($1);
}
| av_service ';' liste_av_service
{ $$ = ajout_av_service($1, $3);
free($1);}
;
av_service: MODULE ':' IDENTIFICATEUR
{ $$ = STR_ALLOC(ACT_AV_STR);
$$->attribute = $1; $$->value.module = $3; }
| REQUEST ':' IDENTIFICATEUR
{ $$ = STR_ALLOC(SERV_AV_STR);
$$->attribute = $1 ; $$->value.request = $3; }
| INTER ':' liste_id
{ $$ = STR_ALLOC(SERV_AV_STR);
$$->attribute = $1; $$->value.inter = $3; }
| WAIT ':' liste_id
{ $$ = STR_ALLOC(SERV_AV_STR);
$$->attribute = $1; $$->value.wait = $3; }
| GROUP ':' IDENTIFICATEUR
{ $$ = STR_ALLOC(SERV_AV_STR);
$$->attribute = $1 ; $$->value.group = $3; }
;
liste_id:
{ $$ = NULL; }
| IDENTIFICATEUR
{ $$ = STR_ALLOC(ID_LIST);
$$->name = $1;
$$->next = NULL; }
| IDENTIFICATEUR ',' liste_id
{ $$ = STR_ALLOC(ID_LIST);
$$->name = $1;
$$->next = $3; }
;
%%
Next: Références
Up: C2. Les source des
Previous: C2.1 Le programme Lex
  Table des matières
Thomas Nemeth
1999-10-03