1use crate::Pos;
2
3mod oo;
4pub use oo::*;
5
6#[derive(Clone, Debug, Default, PartialEq, Eq)]
7pub struct Program {
8 pub id: String,
9 pub options: Vec<String>,
11 pub initial: bool,
14 pub recursive: bool,
15 pub working_storage: Vec<DataEntry>,
16 pub local_storage: Vec<DataEntry>,
18 pub linkage: Vec<DataEntry>,
19 pub using: Vec<Param>,
21 pub returning: Option<String>,
22 pub paragraphs: Vec<Paragraph>,
23 pub files: Vec<FileDecl>,
25 pub sources: Vec<String>,
27 pub exec_declarations: Vec<ExecBlock>,
29 pub report_writer: crate::report::ReportWriter,
31 pub declaratives: Declaratives,
33 pub oo: Option<Box<Oo>>,
35 pub environment: Environment,
36 pub nested: Vec<String>,
38 pub containers: Vec<Container>,
40 pub messages: Vec<crate::Error>,
42}
43
44#[derive(Clone, Debug, PartialEq, Eq)]
45pub struct Param {
46 pub by_value: bool,
47 pub name: String,
48}
49
50#[derive(Clone, Copy, Debug, PartialEq, Eq)]
51pub enum Organization {
52 Sequential,
53 LineSequential,
54 Indexed,
55 Relative,
56}
57
58#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
59pub enum Access {
60 #[default]
61 Sequential,
62 Random,
63 Dynamic,
64}
65
66#[derive(Clone, Debug, PartialEq, Eq)]
67pub struct FileDecl {
68 pub name: String,
69 pub assign: String,
71 pub organization: Organization,
72 pub access: Access,
73 pub record_key: Option<Ref>,
74 pub alternate_keys: Vec<(Ref, bool)>,
76 pub relative_key: Option<Ref>,
77 pub optional: bool,
78 pub status: Option<Ref>,
79 pub vsam_status: Option<Ref>,
81 pub passwords: Vec<Ref>,
83 pub recording: Option<char>,
85 pub record_min: Option<u32>,
86 pub record_max: Option<u32>,
87 pub record_varying: bool,
90 pub record_depending: Option<Ref>,
92 pub records: Vec<DataEntry>,
93 pub reports: Vec<String>,
95 pub linage: Option<Linage>,
97 pub sort: bool,
99 pub external: bool,
100 pub global: bool,
101 pub declared_in: Option<String>,
103 pub pos: Pos,
104}
105
106#[derive(Clone, Debug, Default, PartialEq, Eq)]
109pub struct Container {
110 pub id: String,
111 pub working_storage: Vec<DataEntry>,
112 pub local_storage: Vec<DataEntry>,
113 pub linkage: Vec<DataEntry>,
114 pub files: Vec<FileDecl>,
115}
116
117#[derive(Clone, Debug, PartialEq, Eq)]
119pub struct Linage {
120 pub lines: LinageValue,
121 pub footing: Option<LinageValue>,
122 pub top: Option<LinageValue>,
123 pub bottom: Option<LinageValue>,
124}
125
126#[derive(Clone, Debug, PartialEq, Eq)]
127pub enum LinageValue {
128 Integer(String),
130 Data(Ref),
131}
132
133pub use rt::vocab::{Closing, OpenMode};
134
135#[derive(Clone, Debug, PartialEq, Eq)]
136pub enum Advancing {
137 Lines { before: bool, count: Expr },
138 Page { before: bool },
139 Mnemonic { before: bool, name: String, environment: String },
142}
143
144impl Advancing {
145 pub fn before(&self) -> bool {
146 match self {
147 Self::Lines { before, .. } | Self::Page { before } | Self::Mnemonic { before, .. } => *before,
148 }
149 }
150}
151
152#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
153pub enum Usage {
154 #[default]
155 Display,
156 Binary,
157 NativeBinary,
159 Packed,
160 Float1,
161 Float2,
162 National,
163 Pointer,
164 Index,
165 ObjectReference,
166 ProgramPointer,
168}
169
170pub use rt::vocab::{SignClause, SignPosition};
171
172#[derive(Clone, Debug, PartialEq, Eq)]
173pub struct DataEntry {
174 pub level: u8,
175 pub name: Option<String>,
177 pub spelled: Option<String>,
180 pub picture: Option<String>,
181 pub usage: Option<Usage>,
183 pub value: Option<Literal>,
184 pub redefines: Option<String>,
185 pub occurs: Option<u32>,
187 pub occurs_min: Option<u32>,
190 pub depending_on: Option<Ref>,
192 pub sign: Option<SignClause>,
193 pub justified: bool,
194 pub sync: bool,
195 pub blank_when_zero: bool,
196 pub indexed_by: Vec<String>,
198 pub keys: Vec<(bool, Ref)>,
200 pub condition_values: Vec<(Literal, Option<Literal>)>,
203 pub false_value: Option<Literal>,
205 pub renames: Option<(Ref, Option<Ref>)>,
207 pub object_class: Option<String>,
209 pub external: bool,
211 pub global: bool,
213 pub pos: Pos,
214}
215
216pub use rt::vocab::Figurative;
217
218#[derive(Clone, Debug, PartialEq, Eq)]
219pub enum Literal {
220 Alnum(String),
221 Hex(Vec<u8>),
222 National(String),
223 Number(String),
225 Figurative(Figurative),
226 All(Box<Literal>),
227}
228
229#[derive(Clone, Debug, PartialEq, Eq)]
231pub struct Paragraph {
232 pub name: String,
233 pub statements: Vec<Stmt>,
234 pub section: Option<String>,
236 pub is_section: bool,
237 pub priority: u8,
239 pub pos: Pos,
240}
241
242#[derive(Clone, Debug, PartialEq, Eq)]
244pub struct ProcName {
245 pub name: String,
246 pub section: Option<String>,
247}
248
249#[derive(Clone, Debug, Default, PartialEq, Eq)]
252pub struct Declaratives {
253 pub errors: Vec<UseAfterError>,
254 pub debugging: Vec<UseForDebugging>,
255}
256
257#[derive(Clone, Debug, PartialEq, Eq)]
259pub struct UseAfterError {
260 pub section: usize,
262 pub global: bool,
263 pub on: ErrorUse,
264 pub pos: Pos,
265}
266
267#[derive(Clone, Debug, PartialEq, Eq)]
269pub enum ErrorUse {
270 Files(Vec<String>),
271 Mode(OpenMode),
272}
273
274#[derive(Clone, Debug, PartialEq, Eq)]
276pub struct UseForDebugging {
277 pub section: usize,
278 pub procedures: Vec<ProcName>,
280 pub pos: Pos,
281}
282
283#[derive(Clone, Copy, Debug, PartialEq, Eq)]
284pub enum ExitKind {
285 Plain,
286 Paragraph,
287 Section,
288 Perform,
289 PerformCycle,
290}
291
292#[derive(Clone, Debug, PartialEq, Eq)]
293pub enum Subject {
294 Bool(bool),
295 Expr(Expr),
296 Cond(Cond),
297}
298
299#[derive(Clone, Debug, PartialEq, Eq)]
300pub enum Object {
301 Any,
302 Bool(bool),
303 Cond(Cond),
304 Value { not: bool, from: Expr, thru: Option<Expr> },
305}
306
307#[derive(Clone, Debug, PartialEq, Eq)]
309pub struct When {
310 pub alternatives: Vec<Vec<Object>>,
311 pub body: Vec<Stmt>,
312}
313
314#[derive(Clone, Debug, PartialEq, Eq)]
315pub struct Ref {
316 pub name: String,
317 pub qualifiers: Vec<String>,
318 pub subscripts: Vec<Expr>,
319 pub refmod: Option<RefMod>,
320 pub pos: Pos,
321}
322
323#[derive(Clone, Debug, PartialEq, Eq)]
324pub struct RefMod {
325 pub start: Box<Expr>,
326 pub length: Option<Box<Expr>>,
327}
328
329#[derive(Clone, Debug, PartialEq, Eq)]
330pub struct FunctionCall {
331 pub name: String,
332 pub args: Vec<Expr>,
333 pub modifier: Option<String>,
335 pub refmod: Option<RefMod>,
336 pub all_subscripts: Vec<(usize, Vec<usize>)>,
339 pub pos: Pos,
340}
341
342#[derive(Clone, Debug, PartialEq, Eq)]
343pub enum Operand {
344 Ref(Ref),
345 Literal(Literal),
346 Function(FunctionCall),
347 LengthOf(Ref),
348 AddressOf(Ref),
349}
350
351pub use rt::vocab::{AcceptFrom, BinOp, RelOp};
352
353#[derive(Clone, Debug, PartialEq, Eq)]
354pub enum Expr {
355 Operand(Operand),
356 Neg(Box<Expr>),
357 Bin(Box<Expr>, BinOp, Box<Expr>),
358}
359
360#[derive(Clone, Copy, Debug, PartialEq, Eq)]
361pub enum Class {
362 Numeric,
363 Alphabetic,
364 AlphabeticLower,
365 AlphabeticUpper,
366 Positive,
367 Negative,
368 Zero,
369}
370
371#[derive(Clone, Debug, PartialEq, Eq)]
372pub enum Cond {
373 Rel(Expr, RelOp, Expr),
374 Class(Expr, Class),
375 Name(Ref),
376 NameOrRel { subject: Expr, op: RelOp, negated: bool, name: Ref },
380 Not(Box<Cond>),
381 And(Box<Cond>, Box<Cond>),
382 Or(Box<Cond>, Box<Cond>),
383}
384
385#[derive(Clone, Debug, PartialEq, Eq)]
386pub struct Target {
387 pub r: Ref,
388 pub rounded: bool,
389}
390
391#[derive(Clone, Debug, PartialEq, Eq)]
392pub struct Varying {
393 pub var: Ref,
394 pub from: Expr,
395 pub by: Expr,
396 pub until: Cond,
397}
398
399#[derive(Clone, Debug, PartialEq, Eq)]
400pub enum Loop {
401 Once,
402 Times(Expr),
403 Until { cond: Cond, test_after: bool },
404 Varying { varying: Box<Varying>, after: Vec<Varying>, test_after: bool },
406}
407
408#[derive(Clone, Debug, PartialEq, Eq)]
409pub enum Stmt {
410 Move { from: Operand, to: Vec<Ref>, pos: Pos },
411 Compute { targets: Vec<Target>, expr: Expr, size_error: Option<SizeError>, pos: Pos },
412 Arith(Box<Arith>),
414 Corresponding(Box<Corresponding>),
417 If { cond: Cond, then: Vec<Stmt>, otherwise: Vec<Stmt>, pos: Pos },
418 PerformInline { body: Vec<Stmt>, repeat: Loop, pos: Pos },
419 PerformProc { from: ProcName, thru: Option<ProcName>, repeat: Loop, pos: Pos },
420 Evaluate { subjects: Vec<Subject>, whens: Vec<When>, other: Vec<Stmt>, pos: Pos },
421 Display { items: Vec<Operand>, no_advancing: bool, pos: Pos },
422 Open { files: Vec<(OpenMode, String)>, pos: Pos },
423 Close { files: Vec<(String, Option<Closing>)>, pos: Pos },
424 Read(Box<ReadStmt>),
425 Write { record: Ref, from: Option<Operand>, advancing: Option<Advancing>, invalid: Handlers, end_of_page: Handlers, pos: Pos },
426 Rewrite { record: Ref, from: Option<Operand>, invalid: Handlers, pos: Pos },
427 Delete { file: String, invalid: Handlers, pos: Pos },
428 Start { file: String, key: Option<(RelOp, Ref)>, invalid: Handlers, pos: Pos },
429 Initialize { targets: Vec<Ref>, with: Option<Box<InitializeWith>>, pos: Pos },
431 GoTo { target: Option<ProcName>, pos: Pos },
433 GoToDepending { targets: Vec<ProcName>, on: Ref, pos: Pos },
435 Alter { pairs: Vec<(ProcName, ProcName)>, pos: Pos },
437 Entry { name: String, using: Vec<Param>, pos: Pos },
439 Goback { pos: Pos },
440 ExitProgram { pos: Pos },
442 Call(Box<Call>),
443 Cancel { targets: Vec<Operand>, pos: Pos },
444 Set { set: SetStmt, pos: Pos },
445 Accept { target: Ref, from: AcceptFrom, pos: Pos },
446 String(Box<StringStmt>),
447 Unstring(Box<Unstring>),
448 Inspect(Box<Inspect>),
449 Search(Box<Search>),
450 NextSentence,
452 SentenceEnd,
454 Exec(Box<ExecBlock>),
455 Report(Box<crate::report::ReportStmt>),
456 Invoke(Box<Invoke>),
457 JsonGenerate(Box<JsonGenerate>),
458 JsonParse(Box<JsonParse>),
459 XmlParse(Box<XmlParse>),
460 XmlGenerate(Box<XmlGenerate>),
461 ExitMethod { pos: Pos },
462 Sorting(Box<Sorting>),
463 StopRun { pos: Pos },
464 Continue,
465 Exit { kind: ExitKind, pos: Pos },
466}
467
468#[derive(Clone, Debug, PartialEq, Eq)]
469pub struct SizeError {
470 pub on: Vec<Stmt>,
471 pub not_on: Vec<Stmt>,
472}
473
474#[derive(Clone, Copy, Debug, PartialEq, Eq)]
475pub enum ArithVerb {
476 Add,
477 Subtract,
478 Multiply,
479 Divide,
480}
481
482#[derive(Clone, Debug, PartialEq, Eq)]
486pub struct Arith {
487 pub verb: ArithVerb,
488 pub computations: Vec<(Target, Expr)>,
489 pub remainder: Option<(Target, Expr, Expr)>,
490 pub size_error: Option<SizeError>,
491 pub pos: Pos,
492}
493
494#[derive(Clone, Copy, Debug, PartialEq, Eq)]
495pub enum CorrespondingVerb {
496 Move,
497 Add,
498 Subtract,
499}
500
501#[derive(Clone, Debug, PartialEq, Eq)]
504pub struct Corresponding {
505 pub verb: CorrespondingVerb,
506 pub from: Ref,
507 pub to: Ref,
508 pub rounded: bool,
509 pub size_error: Option<SizeError>,
510 pub pos: Pos,
511}
512
513#[derive(Clone, Copy, Debug, PartialEq, Eq)]
514pub enum ArgMode {
515 Reference,
516 Content,
517 Value,
518}
519
520#[derive(Clone, Debug, PartialEq, Eq)]
522pub struct Arg {
523 pub mode: ArgMode,
524 pub value: Option<Operand>,
525}
526
527#[derive(Clone, Debug, PartialEq, Eq)]
528pub struct Call {
529 pub target: Operand,
530 pub using: Vec<Arg>,
531 pub returning: Option<Ref>,
532 pub on_exception: Option<Vec<Stmt>>,
533 pub not_on_exception: Option<Vec<Stmt>>,
534 pub pos: Pos,
535}
536
537#[derive(Clone, Debug, PartialEq, Eq)]
538pub enum SetStmt {
539 ConditionTrue(Vec<Ref>),
540 ConditionFalse(Vec<Ref>),
542 To { targets: Vec<Ref>, value: Operand },
544 Entry { targets: Vec<Ref>, entry: Operand },
546 AddressOf { targets: Vec<Ref>, value: Operand },
548 UpDown { targets: Vec<Ref>, down: bool, by: Expr },
549}
550
551#[derive(Clone, Debug, PartialEq, Eq)]
552pub enum Delimiter {
553 Size,
554 By(Operand),
555}
556
557#[derive(Clone, Debug, PartialEq, Eq)]
558pub struct StringStmt {
559 pub sources: Vec<(Operand, Delimiter)>,
560 pub into: Ref,
561 pub pointer: Option<Ref>,
562 pub on_overflow: Option<Vec<Stmt>>,
563 pub not_on_overflow: Option<Vec<Stmt>>,
564 pub pos: Pos,
565}
566
567#[derive(Clone, Debug, PartialEq, Eq)]
568pub struct UnstringInto {
569 pub target: Ref,
570 pub delimiter_in: Option<Ref>,
571 pub count_in: Option<Ref>,
572}
573
574#[derive(Clone, Debug, PartialEq, Eq)]
575pub struct Unstring {
576 pub source: Ref,
577 pub delimiters: Vec<(bool, Operand)>,
579 pub into: Vec<UnstringInto>,
580 pub pointer: Option<Ref>,
581 pub tallying: Option<Ref>,
582 pub on_overflow: Option<Vec<Stmt>>,
583 pub not_on_overflow: Option<Vec<Stmt>>,
584 pub pos: Pos,
585}
586
587#[derive(Clone, Debug, PartialEq, Eq)]
589pub struct Bound {
590 pub after: bool,
591 pub value: Operand,
592}
593
594pub use rt::vocab::InspectMode;
595
596#[derive(Clone, Debug, PartialEq, Eq)]
598pub struct InspectPhrase {
599 pub mode: InspectMode,
600 pub pattern: Option<Operand>,
601 pub by: Option<Operand>,
602 pub counter: Option<Ref>,
603 pub bounds: Vec<Bound>,
604}
605
606#[derive(Clone, Copy, Debug, PartialEq, Eq)]
609pub enum DataCategory {
610 Alphabetic,
611 Alphanumeric,
612 AlphanumericEdited,
613 Dbcs,
614 National,
615 NationalEdited,
616 Numeric,
617 NumericEdited,
618 Utf8,
619}
620
621impl DataCategory {
622 pub const ALL: [Self; 9] = [
623 Self::Alphabetic,
624 Self::Alphanumeric,
625 Self::AlphanumericEdited,
626 Self::Dbcs,
627 Self::National,
628 Self::NationalEdited,
629 Self::Numeric,
630 Self::NumericEdited,
631 Self::Utf8,
632 ];
633
634 pub fn from_word(word: &str) -> Option<Self> {
635 Some(match word {
636 "ALPHABETIC" => Self::Alphabetic,
637 "ALPHANUMERIC" => Self::Alphanumeric,
638 "ALPHANUMERIC-EDITED" => Self::AlphanumericEdited,
639 "DBCS" | "EGCS" => Self::Dbcs,
640 "NATIONAL" => Self::National,
641 "NATIONAL-EDITED" => Self::NationalEdited,
642 "NUMERIC" => Self::Numeric,
643 "NUMERIC-EDITED" => Self::NumericEdited,
644 "UTF-8" => Self::Utf8,
645 _ => return None,
646 })
647 }
648
649 pub fn word(self) -> &'static str {
650 match self {
651 Self::Alphabetic => "ALPHABETIC",
652 Self::Alphanumeric => "ALPHANUMERIC",
653 Self::AlphanumericEdited => "ALPHANUMERIC-EDITED",
654 Self::Dbcs => "DBCS",
655 Self::National => "NATIONAL",
656 Self::NationalEdited => "NATIONAL-EDITED",
657 Self::Numeric => "NUMERIC",
658 Self::NumericEdited => "NUMERIC-EDITED",
659 Self::Utf8 => "UTF-8",
660 }
661 }
662}
663
664#[derive(Clone, Debug, Default, PartialEq, Eq)]
666pub struct InitializeWith {
667 pub filler: bool,
668 pub value: Vec<DataCategory>,
669 pub replacing: Vec<(DataCategory, Operand)>,
670 pub default: bool,
671}
672
673#[derive(Clone, Copy, Debug, PartialEq, Eq)]
675pub enum InitialValue<'a> {
676 Value,
678 Replacing(&'a Operand),
679 Default,
681}
682
683impl InitializeWith {
684 pub fn initial_value(&self, category: Option<DataCategory>, has_value: bool) -> Option<InitialValue<'_>> {
688 let named = |c: DataCategory| category == Some(c);
689 if has_value && self.value.iter().any(|&c| named(c)) {
690 return Some(InitialValue::Value);
691 }
692 if let Some((_, by)) = self.replacing.iter().find(|(c, _)| named(*c)) {
693 return Some(InitialValue::Replacing(by));
694 }
695 (self.default || self.value.is_empty() && self.replacing.is_empty()).then_some(InitialValue::Default)
696 }
697}
698
699#[derive(Clone, Debug, PartialEq, Eq)]
701pub struct Inspect {
702 pub target: Operand,
703 pub tallying: Vec<InspectPhrase>,
704 pub replacing: Vec<InspectPhrase>,
705 pub converting: Option<(Operand, Operand, Vec<Bound>)>,
706 pub pos: Pos,
707}
708
709#[derive(Clone, Debug, PartialEq, Eq)]
710pub struct Search {
711 pub table: Ref,
712 pub all: bool,
713 pub varying: Option<Ref>,
714 pub at_end: Option<Vec<Stmt>>,
715 pub whens: Vec<(Cond, Vec<Stmt>)>,
716 pub pos: Pos,
717}
718
719#[derive(Clone, Copy, Debug, PartialEq, Eq)]
720pub enum ExecKind {
721 Sql,
722 Cics,
723 Dli,
724 Other,
725}
726
727#[derive(Clone, Debug, PartialEq, Eq)]
728pub enum ExecArg {
729 Operand(Operand),
730 Text(String),
732}
733
734#[derive(Clone, Debug, PartialEq, Eq)]
736pub struct ExecBlock {
737 pub kind: ExecKind,
738 pub command: String,
740 pub options: Vec<(String, Option<ExecArg>)>,
742 pub host_variables: Vec<Ref>,
744 pub sql: Option<crate::sql::Sql>,
746 pub text: String,
747 pub pos: Pos,
748}
749
750impl ExecBlock {
751 pub fn declarative(&self) -> bool {
753 self.kind == ExecKind::Sql
754 && matches!(self.command.as_str(), "INCLUDE" | "BEGIN DECLARE SECTION" | "END DECLARE SECTION" | "WHENEVER" | "DECLARE CURSOR" | "DECLARE TABLE" | "DECLARE STATEMENT")
755 }
756}
757
758#[derive(Clone, Debug, Default, PartialEq, Eq)]
760pub struct Handlers {
761 pub on: Option<Vec<Stmt>>,
762 pub not_on: Option<Vec<Stmt>>,
763}
764
765#[derive(Clone, Debug, PartialEq, Eq)]
766pub struct ReadStmt {
767 pub file: String,
768 pub next: bool,
770 pub previous: bool,
771 pub into: Option<Ref>,
772 pub key: Option<Ref>,
774 pub at_end: Handlers,
775 pub invalid: Handlers,
776 pub pos: Pos,
777}
778
779#[derive(Clone, Debug, PartialEq, Eq)]
781pub enum Alphabet {
782 Ebcdic,
783 Native,
784 Standard1,
785 Standard2,
786 Literal(Vec<AlphabetEntry>),
788}
789
790impl Alphabet {
791 pub fn name(&self) -> &'static str {
792 match self {
793 Self::Ebcdic => "EBCDIC",
794 Self::Native => "NATIVE",
795 Self::Standard1 => "STANDARD-1",
796 Self::Standard2 => "STANDARD-2",
797 Self::Literal(_) => "literal",
798 }
799 }
800}
801
802#[derive(Clone, Debug, PartialEq, Eq)]
805pub enum AlphabetEntry {
806 Literal(Literal),
807 Through(Literal, Literal),
808 Also(Vec<Literal>),
809}
810
811#[derive(Clone, Debug, Default, PartialEq, Eq)]
813pub struct Environment {
814 pub alphabets: Vec<(String, Alphabet)>,
816 pub collating_sequence: Option<String>,
818 pub same_record_areas: Vec<Vec<String>>,
820 pub same_areas: Vec<Vec<String>>,
821 pub mnemonics: Vec<(String, String)>,
824 pub debugging_mode: bool,
827 pub decimal_point_comma: bool,
830 pub currency: Vec<CurrencySign>,
832}
833
834#[derive(Clone, Debug, PartialEq, Eq)]
836pub struct CurrencySign {
837 pub value: String,
838 pub symbol: char,
839 pub hex: Option<Vec<u8>>,
842}
843
844pub const HEX_SYMBOL: char = '\0';
846
847#[derive(Clone, Debug, PartialEq, Eq)]
848pub enum Sorting {
849 Sort(SortStmt),
850 Release { record: Ref, from: Option<Operand>, pos: Pos },
851 Return { file: String, into: Option<Ref>, at_end: Handlers, pos: Pos },
852}
853
854#[derive(Clone, Debug, PartialEq, Eq)]
856pub struct SortStmt {
857 pub merge: bool,
858 pub subject: Ref,
860 pub keys: Vec<(bool, Ref)>,
862 pub duplicates: bool,
863 pub collating: Option<String>,
864 pub input: Option<SortIo>,
865 pub output: Option<SortIo>,
866 pub pos: Pos,
867}
868
869#[derive(Clone, Debug, PartialEq, Eq)]
871pub enum SortIo {
872 Files(Vec<String>),
873 Procedure { from: ProcName, thru: Option<ProcName> },
874}
875
876
877#[derive(Clone, Debug, PartialEq, Eq)]
879pub struct JsonGenerate {
880 pub receiver: Ref,
881 pub from: Ref,
882 pub count: Option<Ref>,
883 pub names: Vec<(Ref, Option<Literal>)>,
885 pub suppress: Vec<Suppression>,
886 pub converting: Vec<(Ref, JsonConversion)>,
887 pub indicating: Vec<NullIndicator>,
888 pub encoding: Option<Encoding>,
889 pub on_exception: Option<Vec<Stmt>>,
890 pub not_on_exception: Option<Vec<Stmt>>,
891 pub pos: Pos,
892}
893
894#[derive(Clone, Debug, PartialEq, Eq)]
898pub enum Suppression {
899 Item { item: Ref, when: Vec<Figurative> },
900 Every { numeric: Option<bool>, form: Option<XmlForm>, when: Vec<Figurative> },
901}
902
903#[derive(Clone, Debug, PartialEq, Eq)]
906pub enum Marker {
907 Condition(Ref),
908 Literal(Literal),
909}
910
911#[derive(Clone, Debug, PartialEq, Eq)]
912pub enum JsonConversion {
913 Boolean(Marker),
914 Null(Figurative),
915}
916
917#[derive(Clone, Debug, PartialEq, Eq)]
919pub struct NullIndicator {
920 pub item: Ref,
921 pub marker: Marker,
922 pub indicator: Option<Ref>,
923}
924
925#[derive(Clone, Debug, PartialEq, Eq)]
926pub enum Encoding {
927 Ccsid(Operand),
928 FromCodepage,
929}
930
931#[derive(Clone, Debug, PartialEq, Eq)]
933pub struct JsonParse {
934 pub source: Ref,
935 pub into: Ref,
936 pub detail: bool,
937 pub ignoring: Vec<Option<Ref>>,
939 pub indicating: Vec<(Ref, Flag, Option<Ref>)>,
941 pub encoding: Option<Encoding>,
942 pub names: Vec<(Ref, Option<Literal>)>,
944 pub suppress: Vec<Ref>,
945 pub converting: Vec<(Ref, ParseConversion)>,
946 pub on_exception: Option<Vec<Stmt>>,
947 pub not_on_exception: Option<Vec<Stmt>>,
948 pub pos: Pos,
949}
950
951#[derive(Clone, Debug, PartialEq, Eq)]
955pub enum Flag {
956 Condition(Ref),
957 Conditions(Ref, Ref),
958 Literals(Literal, Literal),
959}
960
961#[derive(Clone, Debug, PartialEq, Eq)]
962pub enum ParseConversion {
963 Boolean(Box<Flag>),
964 Null(Figurative),
965}
966
967#[derive(Clone, Debug, PartialEq, Eq)]
969pub struct XmlGenerate {
970 pub receiver: Ref,
971 pub from: Ref,
972 pub count: Option<Ref>,
973 pub encoding: Option<Operand>,
975 pub declaration: bool,
976 pub attributes: bool,
977 pub namespace: Option<Operand>,
978 pub prefix: Option<Operand>,
979 pub names: Vec<(Ref, Literal)>,
980 pub types: Vec<(Ref, XmlForm)>,
981 pub suppress: Vec<Suppression>,
982 pub on_exception: Option<Vec<Stmt>>,
983 pub not_on_exception: Option<Vec<Stmt>>,
984 pub pos: Pos,
985}
986
987#[derive(Clone, Copy, Debug, PartialEq, Eq)]
989pub enum XmlForm {
990 Attribute,
991 Element,
992 Content,
993}
994
995#[derive(Clone, Debug, PartialEq, Eq)]
997pub struct XmlParse {
998 pub document: Ref,
999 pub encoding: Option<Operand>,
1001 pub returning_national: bool,
1002 pub procedure: ProcName,
1003 pub thru: Option<ProcName>,
1004 pub on_exception: Option<Vec<Stmt>>,
1005 pub not_on_exception: Option<Vec<Stmt>>,
1006 pub pos: Pos,
1007}