Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
correction compile warnings
[simgrid.git] / examples / msg / mc / parserPromela.yacc
1 %{
2
3 #include "automaton.h"
4 #include "automatonparse_promela.h"
5 #include "lex.yy.c"
6
7 void yyerror(const char *s);
8
9 %}
10
11 %union{
12   double real;
13   int integer;
14   char* string;
15   xbt_exp_label_t label;
16 }
17
18 %token NEVER
19 %token IF
20 %token FI
21 %token IMPLIES
22 %token GOTO
23 %token AND
24 %token OR
25 %token NOT
26 %token LEFT_PAR
27 %token RIGHT_PAR
28 %token CASE
29 %token COLON
30 %token SEMI_COLON
31 %token CASE_TRUE
32 %token LEFT_BRACE
33 %token RIGHT_BRACE
34 %token <integer> LITT_ENT
35 %token <string> LITT_CHAINE
36 %token <real> LITT_REEL
37 %token <string> ID
38
39 %type <label> exp;
40
41 %start automaton
42
43 %left AND OR
44 %nonassoc NOT
45
46 %%
47
48 automaton : NEVER LEFT_BRACE stateseq RIGHT_BRACE 
49           ;
50
51 stateseq : 
52          | ID COLON { new_state($1, 1);} IF option FI SEMI_COLON stateseq 
53          ;
54
55 option :
56        | CASE exp IMPLIES GOTO ID option { new_transition($5, $2);}
57        ;
58
59 exp : LEFT_PAR exp RIGHT_PAR { $$ = $2; }
60     | exp OR exp { $$ = new_label(0, $1, $3); }
61     | exp AND exp { $$ = new_label(1, $1, $3); }
62     | NOT exp { $$ = new_label(2, $2); }
63     | CASE_TRUE { $$ = new_label(4); }
64     | ID { $$ = new_label(3, $1); }
65     ;
66  
67 %%
68
69
70
71 void yyerror(const char *s){
72   fprintf (stderr, "%s\n", s);
73 }
74
75
76