1use core::range::Range;
2use std::{boxed::Box, string::String, vec::Vec};
3
4use super::{Dimension, ExprNode, SpecificationStmt};
5
6#[derive(Debug, Clone, PartialEq)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9pub enum ExecutableStmt {
10 Assignment(AssignmentNode),
12 Call(CallNode),
14 IfConstruct(IfConstructNode),
16 DoConstruct(DoConstructNode),
18 SelectCase(SelectCaseNode),
20 WhereConstruct(WhereConstructNode),
22 ForallConstruct(ForallConstructNode),
24 AssociateConstruct(AssociateConstructNode),
26 BlockConstruct(BlockConstructNode),
28 CriticalConstruct(CriticalConstructNode),
30 Allocate(AllocateNode),
32 Deallocate(DeallocateNode),
34 Nullify(NullifyNode),
36 Stop(StopNode),
38 Return(ReturnNode),
40 Continue,
42 Cycle(Option<String>),
44 Exit(Option<String>),
46 Read(ReadNode),
48 Write(WriteNode),
50 Print(PrintNode),
52}
53
54#[derive(Debug, Clone, PartialEq)]
56#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
57pub struct AssignmentNode {
58 pub variable: Box<ExprNode>,
60 pub expression: Box<ExprNode>,
62 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
64 pub span: Range<usize>,
65}
66
67#[derive(Debug, Clone, PartialEq)]
69#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
70pub struct CallNode {
71 pub procedure_name: String,
73 pub arguments: Vec<Box<ExprNode>>,
75 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
77 pub span: Range<usize>,
78}
79
80#[derive(Debug, Clone, PartialEq)]
82#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
83pub struct IfConstructNode {
84 pub condition: Box<ExprNode>,
86 pub then_part: Vec<ExecutableStmt>,
88 pub else_if_parts: Vec<(Box<ExprNode>, Vec<ExecutableStmt>)>,
90 pub else_part: Option<Vec<ExecutableStmt>>,
92 pub name: Option<String>,
94 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
96 pub span: Range<usize>,
97}
98
99#[derive(Debug, Clone, PartialEq)]
101#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
102pub struct DoConstructNode {
103 pub name: Option<String>,
105 pub control: Option<DoControl>,
107 pub body: Vec<ExecutableStmt>,
109 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
111 pub span: Range<usize>,
112}
113
114#[derive(Debug, Clone, PartialEq)]
116#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
117pub enum DoControl {
118 Iterative {
120 variable: String,
122 start: Box<ExprNode>,
124 end: Box<ExprNode>,
126 step: Option<Box<ExprNode>>,
128 },
129 While(Box<ExprNode>),
131 Concurrent {
133 header: ConcurrentHeader,
135 locality: Vec<LocalitySpec>,
137 },
138}
139
140#[derive(Debug, Clone, PartialEq)]
142#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
143pub struct ConcurrentHeader {
144 pub control_list: Vec<ConcurrentControl>,
146 pub mask: Option<Box<ExprNode>>,
148}
149
150#[derive(Debug, Clone, PartialEq)]
152#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
153pub struct ConcurrentControl {
154 pub name: String,
156 pub start: Box<ExprNode>,
158 pub end: Box<ExprNode>,
160 pub step: Option<Box<ExprNode>>,
162}
163
164#[derive(Debug, Clone, PartialEq)]
166#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
167pub enum LocalitySpec {
168 Local(Vec<String>),
170 LocalInit(Vec<String>),
172 Shared(Vec<String>),
174 DefaultNone,
176}
177
178#[derive(Debug, Clone, PartialEq)]
180#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
181pub struct SelectCaseNode {
182 pub expression: Box<ExprNode>,
184 pub cases: Vec<CaseConstruct>,
186 pub name: Option<String>,
188 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
190 pub span: Range<usize>,
191}
192
193#[derive(Debug, Clone, PartialEq)]
195#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
196pub struct CaseConstruct {
197 pub selector: CaseSelector,
199 pub body: Vec<ExecutableStmt>,
201}
202
203#[derive(Debug, Clone, PartialEq)]
205#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
206pub enum CaseSelector {
207 Case(Vec<CaseValue>),
209 Default,
211}
212
213#[derive(Debug, Clone, PartialEq)]
215#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
216pub enum CaseValue {
217 Single(Box<ExprNode>),
219 Range(Option<Box<ExprNode>>, Option<Box<ExprNode>>),
221}
222
223#[derive(Debug, Clone, PartialEq)]
225#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
226pub struct WhereConstructNode {
227 pub mask: Box<ExprNode>,
229 pub where_body: Vec<ExecutableStmt>,
231 pub else_where_parts: Vec<(Option<Box<ExprNode>>, Vec<ExecutableStmt>)>,
233 pub name: Option<String>,
235 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
237 pub span: Range<usize>,
238}
239
240#[derive(Debug, Clone, PartialEq)]
242#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
243pub struct ForallConstructNode {
244 pub header: ConcurrentHeader,
246 pub body: Vec<ExecutableStmt>,
248 pub name: Option<String>,
250 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
252 pub span: Range<usize>,
253}
254
255#[derive(Debug, Clone, PartialEq)]
257#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
258pub struct AssociateConstructNode {
259 pub associates: Vec<Associate>,
261 pub body: Vec<ExecutableStmt>,
263 pub name: Option<String>,
265 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
267 pub span: Range<usize>,
268}
269
270#[derive(Debug, Clone, PartialEq)]
272#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
273pub struct Associate {
274 pub name: String,
276 pub expression: Box<ExprNode>,
278}
279
280#[derive(Debug, Clone, PartialEq)]
282#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
283pub struct BlockConstructNode {
284 pub specification_part: Vec<SpecificationStmt>,
286 pub execution_part: Vec<ExecutableStmt>,
288 pub name: Option<String>,
290 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
292 pub span: Range<usize>,
293}
294
295#[derive(Debug, Clone, PartialEq)]
297#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
298pub struct CriticalConstructNode {
299 pub body: Vec<ExecutableStmt>,
301 pub name: Option<String>,
303 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
305 pub span: Range<usize>,
306}
307
308#[derive(Debug, Clone, PartialEq)]
310#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
311pub struct AllocateNode {
312 pub objects: Vec<Allocation>,
314 pub options: Vec<AllocOpt>,
316 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
318 pub span: Range<usize>,
319}
320
321#[derive(Debug, Clone, PartialEq)]
323#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
324pub struct Allocation {
325 pub variable: Box<ExprNode>,
327 pub array_spec: Option<Vec<Dimension>>,
329}
330
331#[derive(Debug, Clone, PartialEq)]
333#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
334pub enum AllocOpt {
335 Stat(Box<ExprNode>),
337 Errmsg(Box<ExprNode>),
339 Source(Box<ExprNode>),
341 Mold(Box<ExprNode>),
343}
344
345#[derive(Debug, Clone, PartialEq)]
347#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
348pub struct DeallocateNode {
349 pub objects: Vec<Box<ExprNode>>,
351 pub options: Vec<DeallocOpt>,
353 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
355 pub span: Range<usize>,
356}
357
358#[derive(Debug, Clone, PartialEq)]
360#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
361pub enum DeallocOpt {
362 Stat(Box<ExprNode>),
364 Errmsg(Box<ExprNode>),
366}
367
368#[derive(Debug, Clone, PartialEq)]
370#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
371pub struct NullifyNode {
372 pub pointers: Vec<Box<ExprNode>>,
374 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
376 pub span: Range<usize>,
377}
378
379#[derive(Debug, Clone, PartialEq)]
381#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
382pub struct StopNode {
383 pub stop_code: Option<Box<ExprNode>>,
385 pub quiet: Option<Box<ExprNode>>,
387 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
389 pub span: Range<usize>,
390}
391
392#[derive(Debug, Clone, PartialEq)]
394#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
395pub struct ReturnNode {
396 pub expression: Option<Box<ExprNode>>,
398 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
400 pub span: Range<usize>,
401}
402
403#[derive(Debug, Clone, PartialEq)]
405#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
406pub struct ReadNode {
407 pub io_control_spec: Vec<IoControlSpec>,
409 pub input_items: Vec<Box<ExprNode>>,
411 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
413 pub span: Range<usize>,
414}
415
416#[derive(Debug, Clone, PartialEq)]
418#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
419pub struct WriteNode {
420 pub io_control_spec: Vec<IoControlSpec>,
422 pub output_items: Vec<Box<ExprNode>>,
424 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
426 pub span: Range<usize>,
427}
428
429#[derive(Debug, Clone, PartialEq)]
431#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
432pub struct PrintNode {
433 pub format: Option<Box<ExprNode>>,
435 pub output_items: Vec<Box<ExprNode>>,
437 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
439 pub span: Range<usize>,
440}
441
442#[derive(Debug, Clone, PartialEq)]
444#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
445pub enum IoControlSpec {
446 Unit(Box<ExprNode>),
448 Format(Box<ExprNode>),
450 Nml(Box<ExprNode>),
452 Iomsg(Box<ExprNode>),
454 Iostat(Box<ExprNode>),
456 Advance(Box<ExprNode>),
458 Other(String, Box<ExprNode>),
460}