Revision 17abbe95 src/parser_lustre.mly
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 OPEN QUOTE FUNCTION
|
|
51 |
%token STATELESS ASSERT INCLUDE 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 |
|
96 | 94 |
|
97 | 95 |
%% |
98 | 96 |
|
99 | 97 |
prog: |
100 | 98 |
typ_def_list top_decl_list EOF {$1;(List.rev $2)} |
101 | 99 |
|
102 |
header: |
|
103 |
typ_def_list top_decl_header_list EOF {$1;(List.rev $2)} |
|
104 |
|
|
105 | 100 |
top_decl_list: |
106 | 101 |
top_decl {[$1]} |
107 | 102 |
| top_decl_list top_decl {$2::$1} |
108 | 103 |
|
104 |
top_decl: |
|
105 |
| CONST cdecl_list { mktop_decl (Consts (List.rev $2)) } |
|
109 | 106 |
|
110 |
top_decl_header_list: |
|
111 |
top_decl_header {[$1]} |
|
112 |
| top_decl_header_list top_decl_header {$2::$1} |
|
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} |
|
113 | 124 |
|
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} |
|
114 | 142 |
|
115 |
top_decl_header: |
|
116 |
| NODE IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR stateless_opt SCOL |
|
143 |
| IMPORTED NODE IDENT LPAR vdecl_list RPAR RETURNS LPAR vdecl_list RPAR stateless_opt SCOL |
|
117 | 144 |
{let nd = mktop_decl (ImportedNode |
118 |
{nodei_id = $2;
|
|
145 |
{nodei_id = $3;
|
|
119 | 146 |
nodei_type = Types.new_var (); |
120 | 147 |
nodei_clock = Clocks.new_var true; |
121 |
nodei_inputs = List.rev $4;
|
|
148 |
nodei_inputs = List.rev $5;
|
|
122 | 149 |
nodei_outputs = List.rev $9; |
123 |
nodei_stateless = $12;
|
|
150 |
nodei_stateless = $11;
|
|
124 | 151 |
nodei_spec = None}) |
125 | 152 |
in |
126 |
Hashtbl.add node_table $2 nd; nd}
|
|
153 |
Hashtbl.add node_table $3 nd; nd}
|
|
127 | 154 |
|
128 |
| nodespec_list NODE IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR stateless_opt SCOL
|
|
155 |
| nodespec_list IMPORTED NODE IDENT LPAR vdecl_list RPAR RETURNS LPAR vdecl_list RPAR stateless_opt SCOL
|
|
129 | 156 |
{let nd = mktop_decl (ImportedNode |
130 |
{nodei_id = $3;
|
|
157 |
{nodei_id = $4;
|
|
131 | 158 |
nodei_type = Types.new_var (); |
132 | 159 |
nodei_clock = Clocks.new_var true; |
133 |
nodei_inputs = List.rev $5;
|
|
160 |
nodei_inputs = List.rev $6;
|
|
134 | 161 |
nodei_outputs = List.rev $10; |
135 |
nodei_stateless = $13;
|
|
162 |
nodei_stateless = $12;
|
|
136 | 163 |
nodei_spec = Some $1}) |
137 | 164 |
in |
138 |
Hashtbl.add node_table $3 nd; nd}
|
|
165 |
Hashtbl.add node_table $4 nd; nd}
|
|
139 | 166 |
|
140 |
| FUNCTION IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL
|
|
167 |
| FUNCTION IDENT LPAR vdecl_list RPAR RETURNS LPAR vdecl_list RPAR SCOL
|
|
141 | 168 |
{let nd = mktop_decl (ImportedNode |
142 | 169 |
{nodei_id = $2; |
143 | 170 |
nodei_type = Types.new_var (); |
144 | 171 |
nodei_clock = Clocks.new_var true; |
145 | 172 |
nodei_inputs = List.rev $4; |
146 |
nodei_outputs = List.rev $9;
|
|
173 |
nodei_outputs = List.rev $8;
|
|
147 | 174 |
nodei_stateless = true; |
148 | 175 |
nodei_spec = None}) |
149 | 176 |
in |
150 | 177 |
Hashtbl.add node_table $2 nd; nd} |
151 | 178 |
|
152 |
| nodespec_list FUNCTION IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL
|
|
179 |
| nodespec_list FUNCTION IDENT LPAR vdecl_list RPAR RETURNS LPAR vdecl_list RPAR SCOL
|
|
153 | 180 |
{let nd = mktop_decl (ImportedNode |
154 | 181 |
{nodei_id = $3; |
155 | 182 |
nodei_type = Types.new_var (); |
156 | 183 |
nodei_clock = Clocks.new_var true; |
157 | 184 |
nodei_inputs = List.rev $5; |
158 |
nodei_outputs = List.rev $10;
|
|
185 |
nodei_outputs = List.rev $9;
|
|
159 | 186 |
nodei_stateless = true; |
160 | 187 |
nodei_spec = Some $1}) |
161 | 188 |
in |
162 | 189 |
Hashtbl.add node_table $3 nd; nd} |
163 | 190 |
|
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) } |
|
191 |
| INCLUDE QUOTE IDENT QUOTE { mktop_decl (Include $3) } |
|
204 | 192 |
|
205 | 193 |
nodespec_list: |
206 | 194 |
NODESPEC { $1 } |
Also available in: Unified diff