Logo AND Algorithmique Numérique Distribuée

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