Logo AND Algorithmique Numérique Distribuée

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