Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
mv simgrid_config.h simgrid/config
[simgrid.git] / src / xbt / automaton / parserPromela.yacc
1 /* Copyright (c) 2012-2018. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 %{
8 #include "simgrid/config.h"
9 #if !HAVE_UNISTD_H
10 #define YY_NO_UNISTD_H /* hello Windows */
11 #endif
12
13 #include "automaton_lexer.yy.c"
14 #include <xbt/automaton.h>
15
16 void yyerror(const char *s);
17
18 %}
19
20 %union{
21   double real;
22   int integer;
23   char* string;
24   xbt_automaton_exp_label_t label;
25 }
26
27 %token NEVER
28 %token IF
29 %token FI
30 %token IMPLIES
31 %token GOTO
32 %token AND
33 %token OR
34 %token NOT
35 %token LEFT_PAR
36 %token RIGHT_PAR
37 %token CASE
38 %token COLON
39 %token SEMI_COLON
40 %token CASE_TRUE
41 %token LEFT_BRACE
42 %token RIGHT_BRACE
43 %token <integer> LITT_ENT
44 %token <string> LITT_CHAINE
45 %token <real> LITT_REEL
46 %token <string> ID
47
48 %type <label> exp;
49
50 %start automaton
51
52 %left AND OR
53 %nonassoc NOT
54
55 %%
56
57 automaton : NEVER LEFT_BRACE stateseq RIGHT_BRACE
58           ;
59
60 stateseq :
61          | ID COLON { new_state($1, 1);} IF option FI SEMI_COLON stateseq
62          ;
63
64 option :
65        | CASE exp IMPLIES GOTO ID option { new_transition($5, $2);}
66        ;
67
68 exp : LEFT_PAR exp RIGHT_PAR { $$ = $2; }
69     | exp OR exp { $$ = new_label(0, $1, $3); }
70     | exp AND exp { $$ = new_label(1, $1, $3); }
71     | NOT exp { $$ = new_label(2, $2); }
72     | CASE_TRUE { $$ = new_label(4); }
73     | ID { $$ = new_label(3, $1); }
74     ;
75
76 %%
77
78
79
80 void yyerror(const char *s){
81   fprintf (stderr, "%s\n", s);
82 }
83
84
85