Project

General

Profile

Revision 5c1184ad src/parser_lustre.mly

View differences:

src/parser_lustre.mly
48 48
%token <string> REAL
49 49
%token <float> FLOAT
50 50
%token AUTOMATON STATE UNTIL UNLESS RESTART RESUME LAST
51
%token STATELESS ASSERT INCLUDE QUOTE FUNCTION
51
%token STATELESS ASSERT OPEN QUOTE FUNCTION
52 52
%token <string> IDENT
53 53
%token <LustreSpec.expr_annot> ANNOT
54 54
%token <LustreSpec.node_annot> NODESPEC
......
91 91

  
92 92
%start prog
93 93
%type <Corelang.top_decl list> prog
94
%start header
95
%type <Corelang.top_decl list> header
94 96

  
95 97
%%
96 98

  
97 99
prog:
98 100
    typ_def_list top_decl_list EOF {$1;(List.rev $2)}
99 101

  
102
header:
103
    typ_def_list top_decl_header_list EOF {$1;(List.rev $2)}
104

  
100 105
top_decl_list:
101 106
  top_decl {[$1]}
102 107
| top_decl_list top_decl {$2::$1}
103 108

  
104
top_decl:
105
| CONST cdecl_list { mktop_decl (Consts (List.rev $2)) }
106 109

  
107
| NODE IDENT LPAR vdecl_list RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL_opt locals LET eq_list TEL 
108
    {let eqs, asserts, annots = $14 in
109
     let nd = mktop_decl (Node
110
                            {node_id = $2;
111
                             node_type = Types.new_var ();
112
                             node_clock = Clocks.new_var true;
113
                             node_inputs = List.rev $4;
114
                             node_outputs = List.rev $8;
115
                             node_locals = List.rev $12;
116
			     node_gencalls = [];
117
			     node_checks = [];
118
			     node_asserts = asserts; 
119
                             node_eqs = eqs;
120
			     node_spec = None;
121
			     node_annot = match annots with [] -> None | _ -> Some annots})
122
    in
123
    Hashtbl.add node_table $2 nd; nd}
110
top_decl_header_list:
111
  top_decl_header {[$1]}
112
| top_decl_header_list top_decl_header {$2::$1}
124 113

  
125
| nodespec_list NODE IDENT LPAR vdecl_list RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL_opt locals LET eq_list TEL 
126
    {let eqs, asserts, annots = $15 in
127
     let nd = mktop_decl (Node
128
                            {node_id = $3;
129
                             node_type = Types.new_var ();
130
                             node_clock = Clocks.new_var true;
131
                             node_inputs = List.rev $5;
132
                             node_outputs = List.rev $9;
133
                             node_locals = List.rev $13;
134
			     node_gencalls = [];
135
			     node_checks = [];
136
			     node_asserts = asserts; 
137
                             node_eqs = eqs;
138
			     node_spec = Some $1;
139
			     node_annot = match annots with [] -> None | _ -> Some annots})
140
    in
141
    Hashtbl.add node_table $3 nd; nd}
142 114

  
143
| IMPORTED NODE IDENT LPAR vdecl_list RPAR RETURNS LPAR vdecl_list RPAR stateless_opt SCOL
115
top_decl_header:
116
| NODE IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR stateless_opt SCOL
144 117
    {let nd = mktop_decl (ImportedNode
145
                            {nodei_id = $3;
118
                            {nodei_id = $2;
146 119
                             nodei_type = Types.new_var ();
147 120
                             nodei_clock = Clocks.new_var true;
148
                             nodei_inputs = List.rev $5;
121
                             nodei_inputs = List.rev $4;
149 122
                             nodei_outputs = List.rev $9;
150
			     nodei_stateless = $11;
123
			     nodei_stateless = $12;
151 124
			     nodei_spec = None})
152 125
    in
153
    Hashtbl.add node_table $3 nd; nd}
126
    Hashtbl.add node_table $2 nd; nd}
154 127

  
155
| nodespec_list IMPORTED NODE IDENT LPAR vdecl_list RPAR RETURNS LPAR vdecl_list RPAR stateless_opt SCOL
128
| nodespec_list NODE IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR stateless_opt SCOL
156 129
    {let nd = mktop_decl (ImportedNode
157
                            {nodei_id = $4;
130
                            {nodei_id = $3;
158 131
                             nodei_type = Types.new_var ();
159 132
                             nodei_clock = Clocks.new_var true;
160
                             nodei_inputs = List.rev $6;
133
                             nodei_inputs = List.rev $5;
161 134
                             nodei_outputs = List.rev $10;
162
			     nodei_stateless = $12;
135
			     nodei_stateless = $13;
163 136
			     nodei_spec = Some $1})
164 137
    in
165
    Hashtbl.add node_table $4 nd; nd}
138
    Hashtbl.add node_table $3 nd; nd}
166 139

  
167
| FUNCTION IDENT LPAR vdecl_list RPAR RETURNS LPAR vdecl_list RPAR SCOL
140
| FUNCTION IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL
168 141
    {let nd = mktop_decl (ImportedNode
169 142
                            {nodei_id = $2;
170 143
                             nodei_type = Types.new_var ();
171 144
			     nodei_clock = Clocks.new_var true;
172 145
                             nodei_inputs = List.rev $4;
173
                             nodei_outputs = List.rev $8;
146
                             nodei_outputs = List.rev $9;
174 147
			     nodei_stateless = true;
175 148
			     nodei_spec = None})
176 149
     in
177 150
     Hashtbl.add node_table $2 nd; nd}
178 151

  
179
| nodespec_list FUNCTION IDENT LPAR vdecl_list RPAR RETURNS LPAR vdecl_list RPAR SCOL
152
| nodespec_list FUNCTION IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL
180 153
    {let nd = mktop_decl (ImportedNode
181 154
                            {nodei_id = $3;
182 155
                             nodei_type = Types.new_var ();
183 156
			     nodei_clock = Clocks.new_var true;
184 157
                             nodei_inputs = List.rev $5;
185
                             nodei_outputs = List.rev $9;
158
                             nodei_outputs = List.rev $10;
186 159
			     nodei_stateless = true;
187 160
			     nodei_spec = Some $1})
188 161
     in
189 162
    Hashtbl.add node_table $3 nd; nd}
190 163

  
191
| INCLUDE QUOTE IDENT QUOTE { mktop_decl (Include $3) }
164
top_decl:
165
| CONST cdecl_list { mktop_decl (Consts (List.rev $2)) }
166

  
167
| NODE IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL_opt locals LET eq_list TEL 
168
    {let eqs, asserts, annots = $15 in
169
     let nd = mktop_decl (Node
170
                            {node_id = $2;
171
                             node_type = Types.new_var ();
172
                             node_clock = Clocks.new_var true;
173
                             node_inputs = List.rev $4;
174
                             node_outputs = List.rev $9;
175
                             node_locals = List.rev $13;
176
			     node_gencalls = [];
177
			     node_checks = [];
178
			     node_asserts = asserts; 
179
                             node_eqs = eqs;
180
			     node_spec = None;
181
			     node_annot = match annots with [] -> None | _ -> Some annots})
182
    in
183
    Hashtbl.add node_table $2 nd; nd}
184

  
185
| nodespec_list NODE IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL_opt locals LET eq_list TEL 
186
    {let eqs, asserts, annots = $16 in
187
     let nd = mktop_decl (Node
188
                            {node_id = $3;
189
                             node_type = Types.new_var ();
190
                             node_clock = Clocks.new_var true;
191
                             node_inputs = List.rev $5;
192
                             node_outputs = List.rev $10;
193
                             node_locals = List.rev $14;
194
			     node_gencalls = [];
195
			     node_checks = [];
196
			     node_asserts = asserts; 
197
                             node_eqs = eqs;
198
			     node_spec = Some $1;
199
			     node_annot = match annots with [] -> None | _ -> Some annots})
200
    in
201
    Hashtbl.add node_table $3 nd; nd}
202

  
203
| OPEN QUOTE IDENT QUOTE { mktop_decl (Open $3) }
192 204

  
193 205
nodespec_list:
194 206
NODESPEC { $1 }

Also available in: Unified diff