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 common: bool,
17 pub working_storage: Vec<DataEntry>,
18 pub local_storage: Vec<DataEntry>,
20 pub linkage: Vec<DataEntry>,
21 pub using: Vec<Param>,
23 pub returning: Option<String>,
24 pub paragraphs: Vec<Paragraph>,
25 pub files: Vec<FileDecl>,
27 pub sources: Vec<String>,
29 pub exec_declarations: Vec<ExecBlock>,
31 pub report_writer: crate::report::ReportWriter,
33 pub declaratives: Declaratives,
35 pub oo: Option<Box<Oo>>,
37 pub environment: Environment,
38 pub nested: Vec<String>,
40 pub containers: Vec<Container>,
42 pub messages: Vec<crate::Error>,
44 pub function: Option<Function>,
46 pub prototypes: Vec<Prototype>,
49}
50
51impl Program {
52 pub fn load_name(&self) -> &str {
54 self.function.as_ref().map_or(&self.id, |f| &f.external)
55 }
56
57 pub fn is_prototype(&self) -> bool {
58 self.function.as_ref().is_some_and(|f| f.prototype)
59 }
60}
61
62#[derive(Clone, Debug, PartialEq, Eq)]
63pub struct Function {
64 pub external: String,
66 pub prototype: bool,
68 pub pos: Pos,
69}
70
71#[derive(Clone, Debug, PartialEq, Eq)]
73pub struct Prototype {
74 pub name: String,
75 pub external: String,
76 pub using: Vec<Param>,
77 pub returning: Option<String>,
78 pub linkage: Vec<DataEntry>,
79 pub environment: Environment,
81 pub pos: Pos,
82}
83
84#[derive(Clone, Debug, PartialEq, Eq)]
85pub struct Param {
86 pub by_value: bool,
87 pub name: String,
88}
89
90#[derive(Clone, Copy, Debug, PartialEq, Eq)]
91pub enum Organization {
92 Sequential,
93 LineSequential,
94 Indexed,
95 Relative,
96}
97
98#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
99pub enum Access {
100 #[default]
101 Sequential,
102 Random,
103 Dynamic,
104}
105
106#[derive(Clone, Debug, PartialEq, Eq)]
107pub struct FileDecl {
108 pub name: String,
109 pub assign: String,
111 pub assign_item: Option<AssignItem>,
114 pub organization: Organization,
115 pub access: Access,
116 pub record_key: Option<Ref>,
117 pub alternate_keys: Vec<(Ref, bool)>,
119 pub relative_key: Option<Ref>,
120 pub optional: bool,
121 pub status: Option<Ref>,
122 pub vsam_status: Option<Ref>,
124 pub passwords: Vec<Ref>,
126 pub recording: Option<char>,
128 pub record_min: Option<u32>,
129 pub record_max: Option<u32>,
130 pub record_varying: bool,
133 pub record_depending: Option<Ref>,
135 pub records: Vec<DataEntry>,
136 pub reports: Vec<String>,
138 pub linage: Option<Linage>,
140 pub sort: bool,
142 pub external: bool,
143 pub global: bool,
144 pub declared_in: Option<String>,
146 pub pos: Pos,
147}
148
149#[derive(Clone, Debug, PartialEq, Eq)]
154pub struct AssignItem {
155 pub reference: Ref,
156 pub explicit: bool,
158}
159
160#[derive(Clone, Debug, Default, PartialEq, Eq)]
163pub struct Container {
164 pub id: String,
165 pub working_storage: Vec<DataEntry>,
166 pub local_storage: Vec<DataEntry>,
167 pub linkage: Vec<DataEntry>,
168 pub files: Vec<FileDecl>,
169}
170
171#[derive(Clone, Debug, PartialEq, Eq)]
173pub struct Linage {
174 pub lines: LinageValue,
175 pub footing: Option<LinageValue>,
176 pub top: Option<LinageValue>,
177 pub bottom: Option<LinageValue>,
178}
179
180#[derive(Clone, Debug, PartialEq, Eq)]
181pub enum LinageValue {
182 Integer(String),
184 Data(Ref),
185}
186
187pub use rt::vocab::{Closing, OpenMode};
188
189#[derive(Clone, Debug, PartialEq, Eq)]
190pub enum Advancing {
191 Lines { before: bool, count: Expr },
192 Page { before: bool },
193 Mnemonic { before: bool, name: String, environment: String },
196}
197
198impl Advancing {
199 pub fn before(&self) -> bool {
200 match self {
201 Self::Lines { before, .. } | Self::Page { before } | Self::Mnemonic { before, .. } => *before,
202 }
203 }
204}
205
206#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
207pub enum Usage {
208 #[default]
209 Display,
210 Binary,
211 NativeBinary,
213 Packed,
214 Float1,
215 Float2,
216 National,
217 Dbcs,
219 Pointer,
220 Index,
221 ObjectReference,
222 ProgramPointer,
224}
225
226pub use rt::vocab::{SignClause, SignPosition};
227
228#[derive(Clone, Debug, PartialEq, Eq)]
229pub struct DataEntry {
230 pub level: u8,
231 pub name: Option<String>,
233 pub spelled: Option<String>,
236 pub picture: Option<String>,
237 pub usage: Option<Usage>,
239 pub value: Option<Literal>,
240 pub redefines: Option<String>,
241 pub occurs: Option<u32>,
243 pub occurs_min: Option<u32>,
246 pub depending_on: Option<Ref>,
248 pub sign: Option<SignClause>,
249 pub justified: bool,
250 pub sync: bool,
251 pub blank_when_zero: bool,
252 pub indexed_by: Vec<String>,
254 pub keys: Vec<(bool, Ref)>,
256 pub condition_values: Vec<(Literal, Option<Literal>)>,
259 pub false_value: Option<Literal>,
261 pub renames: Option<(Ref, Option<Ref>)>,
263 pub object_class: Option<String>,
265 pub external: bool,
267 pub global: bool,
269 pub pos: Pos,
270}
271
272pub use rt::vocab::Figurative;
273
274#[derive(Clone, Debug, PartialEq, Eq)]
275pub enum Literal {
276 Alnum(String),
277 Hex(Vec<u8>),
278 National(String),
279 Dbcs(String),
281 Number(String),
283 Figurative(Figurative),
284 All(Box<Literal>),
285}
286
287#[derive(Clone, Debug, PartialEq, Eq)]
289pub struct Paragraph {
290 pub name: String,
291 pub statements: Vec<Stmt>,
292 pub section: Option<String>,
294 pub is_section: bool,
295 pub priority: u8,
297 pub pos: Pos,
298}
299
300#[derive(Clone, Debug, PartialEq, Eq)]
302pub struct ProcName {
303 pub name: String,
304 pub section: Option<String>,
305}
306
307#[derive(Clone, Debug, Default, PartialEq, Eq)]
310pub struct Declaratives {
311 pub errors: Vec<UseAfterError>,
312 pub debugging: Vec<UseForDebugging>,
313}
314
315#[derive(Clone, Debug, PartialEq, Eq)]
317pub struct UseAfterError {
318 pub section: usize,
320 pub global: bool,
321 pub on: ErrorUse,
322 pub pos: Pos,
323}
324
325#[derive(Clone, Debug, PartialEq, Eq)]
327pub enum ErrorUse {
328 Files(Vec<String>),
329 Mode(OpenMode),
330}
331
332#[derive(Clone, Debug, PartialEq, Eq)]
334pub struct UseForDebugging {
335 pub section: usize,
336 pub procedures: Vec<ProcName>,
338 pub pos: Pos,
339}
340
341#[derive(Clone, Copy, Debug, PartialEq, Eq)]
342pub enum ExitKind {
343 Plain,
344 Paragraph,
345 Section,
346 Perform,
347 PerformCycle,
348}
349
350#[derive(Clone, Debug, PartialEq, Eq)]
351pub enum Subject {
352 Bool(bool),
353 Expr(Expr),
354 Cond(Cond),
355}
356
357#[derive(Clone, Debug, PartialEq, Eq)]
358pub enum Object {
359 Any,
360 Bool(bool),
361 Cond(Cond),
362 Value { not: bool, from: Expr, thru: Option<Expr> },
363}
364
365#[derive(Clone, Debug, PartialEq, Eq)]
367pub struct When {
368 pub alternatives: Vec<Vec<Object>>,
369 pub body: Vec<Stmt>,
370}
371
372#[derive(Clone, Debug, PartialEq, Eq)]
373pub struct Ref {
374 pub name: String,
375 pub qualifiers: Vec<String>,
376 pub subscripts: Vec<Expr>,
377 pub refmod: Option<RefMod>,
378 pub pos: Pos,
379}
380
381#[derive(Clone, Debug, PartialEq, Eq)]
382pub struct RefMod {
383 pub start: Box<Expr>,
384 pub length: Option<Box<Expr>>,
385}
386
387#[derive(Clone, Debug, PartialEq, Eq)]
388pub struct FunctionCall {
389 pub name: String,
390 pub args: Vec<Expr>,
391 pub modifier: Option<String>,
393 pub refmod: Option<RefMod>,
394 pub all_subscripts: Vec<(usize, Vec<usize>)>,
397 pub pos: Pos,
398}
399
400#[derive(Clone, Debug, PartialEq, Eq)]
401pub enum Operand {
402 Ref(Ref),
403 Literal(Literal),
404 Function(FunctionCall),
405 LengthOf(Ref),
406 AddressOf(Ref),
407}
408
409pub use rt::vocab::{AcceptFrom, BinOp, RelOp};
410
411#[derive(Clone, Debug, PartialEq, Eq)]
412pub enum Expr {
413 Operand(Operand),
414 Neg(Box<Expr>),
415 Bin(Box<Expr>, BinOp, Box<Expr>),
416}
417
418#[derive(Clone, Copy, Debug, PartialEq, Eq)]
419pub enum Class {
420 Numeric,
421 Alphabetic,
422 AlphabeticLower,
423 AlphabeticUpper,
424 Dbcs,
426 Kanji,
428 Positive,
429 Negative,
430 Zero,
431}
432
433#[derive(Clone, Debug, PartialEq, Eq)]
434pub enum Cond {
435 Rel(Expr, RelOp, Expr),
436 Class(Expr, Class),
437 Name(Ref),
438 NameOrRel { subject: Expr, op: RelOp, negated: bool, name: Ref },
442 Not(Box<Cond>),
443 And(Box<Cond>, Box<Cond>),
444 Or(Box<Cond>, Box<Cond>),
445}
446
447#[derive(Clone, Debug, PartialEq, Eq)]
448pub struct Target {
449 pub r: Ref,
450 pub rounded: bool,
451}
452
453#[derive(Clone, Debug, PartialEq, Eq)]
454pub struct Varying {
455 pub var: Ref,
456 pub from: Expr,
457 pub by: Expr,
458 pub until: Cond,
459}
460
461#[derive(Clone, Debug, PartialEq, Eq)]
462pub enum Loop {
463 Once,
464 Times(Expr),
465 Until { cond: Cond, test_after: bool },
466 Varying { varying: Box<Varying>, after: Vec<Varying>, test_after: bool },
468}
469
470#[derive(Clone, Debug, PartialEq, Eq)]
471pub enum Stmt {
472 Move { from: Operand, to: Vec<Ref>, pos: Pos },
473 Compute { targets: Vec<Target>, expr: Expr, size_error: Option<SizeError>, pos: Pos },
474 Arith(Box<Arith>),
476 Corresponding(Box<Corresponding>),
479 If { cond: Cond, then: Vec<Stmt>, otherwise: Vec<Stmt>, pos: Pos },
480 PerformInline { body: Vec<Stmt>, repeat: Loop, pos: Pos },
481 PerformProc { from: ProcName, thru: Option<ProcName>, repeat: Loop, pos: Pos },
482 Evaluate { subjects: Vec<Subject>, whens: Vec<When>, other: Vec<Stmt>, pos: Pos },
483 Display { items: Vec<Operand>, upon: Option<Upon>, no_advancing: bool, pos: Pos },
484 Open { files: Vec<(OpenMode, String)>, pos: Pos },
485 Close { files: Vec<(String, Option<Closing>)>, pos: Pos },
486 Read(Box<ReadStmt>),
487 Write { record: Ref, from: Option<Operand>, advancing: Option<Advancing>, invalid: Handlers, end_of_page: Handlers, pos: Pos },
488 Rewrite { record: Ref, from: Option<Operand>, invalid: Handlers, pos: Pos },
489 Delete { file: String, invalid: Handlers, pos: Pos },
490 Start { file: String, key: Option<(RelOp, Ref)>, invalid: Handlers, pos: Pos },
491 Initialize { targets: Vec<Ref>, with: Option<Box<InitializeWith>>, pos: Pos },
493 GoTo { target: Option<ProcName>, pos: Pos },
495 GoToDepending { targets: Vec<ProcName>, on: Ref, pos: Pos },
497 Alter { pairs: Vec<(ProcName, ProcName)>, pos: Pos },
499 Entry { name: String, using: Vec<Param>, pos: Pos },
501 Goback { pos: Pos },
502 ExitProgram { pos: Pos },
504 Call(Box<Call>),
505 Cancel { targets: Vec<Operand>, pos: Pos },
506 Set { set: SetStmt, pos: Pos },
507 Accept { target: Ref, from: AcceptFrom, pos: Pos },
508 String(Box<StringStmt>),
509 Unstring(Box<Unstring>),
510 Inspect(Box<Inspect>),
511 Search(Box<Search>),
512 NextSentence,
514 SentenceEnd,
516 Exec(Box<ExecBlock>),
517 Report(Box<crate::report::ReportStmt>),
518 Invoke(Box<Invoke>),
519 JsonGenerate(Box<JsonGenerate>),
520 JsonParse(Box<JsonParse>),
521 XmlParse(Box<XmlParse>),
522 XmlGenerate(Box<XmlGenerate>),
523 ExitMethod { pos: Pos },
524 Sorting(Box<Sorting>),
525 StopRun { pos: Pos },
526 Continue,
527 Exit { kind: ExitKind, pos: Pos },
528}
529
530#[derive(Clone, Debug, PartialEq, Eq)]
531pub struct SizeError {
532 pub on: Vec<Stmt>,
533 pub not_on: Vec<Stmt>,
534}
535
536#[derive(Clone, Copy, Debug, PartialEq, Eq)]
537pub enum ArithVerb {
538 Add,
539 Subtract,
540 Multiply,
541 Divide,
542}
543
544#[derive(Clone, Debug, PartialEq, Eq)]
548pub struct Arith {
549 pub verb: ArithVerb,
550 pub computations: Vec<(Target, Expr)>,
551 pub remainder: Option<(Target, Expr, Expr)>,
552 pub size_error: Option<SizeError>,
553 pub pos: Pos,
554}
555
556#[derive(Clone, Copy, Debug, PartialEq, Eq)]
557pub enum CorrespondingVerb {
558 Move,
559 Add,
560 Subtract,
561}
562
563#[derive(Clone, Debug, PartialEq, Eq)]
566pub struct Corresponding {
567 pub verb: CorrespondingVerb,
568 pub from: Ref,
569 pub to: Ref,
570 pub rounded: bool,
571 pub size_error: Option<SizeError>,
572 pub pos: Pos,
573}
574
575#[derive(Clone, Copy, Debug, PartialEq, Eq)]
576pub enum ArgMode {
577 Reference,
578 Content,
579 Value,
580}
581
582#[derive(Clone, Debug, PartialEq, Eq)]
584pub struct Arg {
585 pub mode: ArgMode,
586 pub value: Option<Operand>,
587}
588
589#[derive(Clone, Debug, PartialEq, Eq)]
590pub struct Call {
591 pub target: Operand,
592 pub using: Vec<Arg>,
593 pub returning: Option<Ref>,
594 pub on_exception: Option<Vec<Stmt>>,
595 pub not_on_exception: Option<Vec<Stmt>>,
596 pub pos: Pos,
597}
598
599#[derive(Clone, Debug, PartialEq, Eq)]
600pub enum SetStmt {
601 ConditionTrue(Vec<Ref>),
602 ConditionFalse(Vec<Ref>),
604 To { targets: Vec<Ref>, value: Operand },
606 Entry { targets: Vec<Ref>, entry: Operand },
608 AddressOf { targets: Vec<Ref>, value: Operand },
610 UpDown { targets: Vec<Ref>, down: bool, by: Expr },
611}
612
613#[derive(Clone, Debug, PartialEq, Eq)]
614pub enum Delimiter {
615 Size,
616 By(Operand),
617}
618
619#[derive(Clone, Debug, PartialEq, Eq)]
620pub struct StringStmt {
621 pub sources: Vec<(Operand, Delimiter)>,
622 pub into: Ref,
623 pub pointer: Option<Ref>,
624 pub on_overflow: Option<Vec<Stmt>>,
625 pub not_on_overflow: Option<Vec<Stmt>>,
626 pub pos: Pos,
627}
628
629#[derive(Clone, Debug, PartialEq, Eq)]
630pub struct UnstringInto {
631 pub target: Ref,
632 pub delimiter_in: Option<Ref>,
633 pub count_in: Option<Ref>,
634}
635
636#[derive(Clone, Debug, PartialEq, Eq)]
637pub struct Unstring {
638 pub source: Ref,
639 pub delimiters: Vec<(bool, Operand)>,
641 pub into: Vec<UnstringInto>,
642 pub pointer: Option<Ref>,
643 pub tallying: Option<Ref>,
644 pub on_overflow: Option<Vec<Stmt>>,
645 pub not_on_overflow: Option<Vec<Stmt>>,
646 pub pos: Pos,
647}
648
649#[derive(Clone, Debug, PartialEq, Eq)]
651pub struct Bound {
652 pub after: bool,
653 pub value: Operand,
654}
655
656pub use rt::vocab::InspectMode;
657
658#[derive(Clone, Debug, PartialEq, Eq)]
660pub struct InspectPhrase {
661 pub mode: InspectMode,
662 pub pattern: Option<Operand>,
663 pub by: Option<Operand>,
664 pub counter: Option<Ref>,
665 pub bounds: Vec<Bound>,
666}
667
668#[derive(Clone, Copy, Debug, PartialEq, Eq)]
671pub enum DataCategory {
672 Alphabetic,
673 Alphanumeric,
674 AlphanumericEdited,
675 Dbcs,
676 National,
677 NationalEdited,
678 Numeric,
679 NumericEdited,
680 Utf8,
681}
682
683impl DataCategory {
684 pub const ALL: [Self; 9] = [
685 Self::Alphabetic,
686 Self::Alphanumeric,
687 Self::AlphanumericEdited,
688 Self::Dbcs,
689 Self::National,
690 Self::NationalEdited,
691 Self::Numeric,
692 Self::NumericEdited,
693 Self::Utf8,
694 ];
695
696 pub fn from_word(word: &str) -> Option<Self> {
697 Some(match word {
698 "ALPHABETIC" => Self::Alphabetic,
699 "ALPHANUMERIC" => Self::Alphanumeric,
700 "ALPHANUMERIC-EDITED" => Self::AlphanumericEdited,
701 "DBCS" | "EGCS" => Self::Dbcs,
702 "NATIONAL" => Self::National,
703 "NATIONAL-EDITED" => Self::NationalEdited,
704 "NUMERIC" => Self::Numeric,
705 "NUMERIC-EDITED" => Self::NumericEdited,
706 "UTF-8" => Self::Utf8,
707 _ => return None,
708 })
709 }
710
711 pub fn word(self) -> &'static str {
712 match self {
713 Self::Alphabetic => "ALPHABETIC",
714 Self::Alphanumeric => "ALPHANUMERIC",
715 Self::AlphanumericEdited => "ALPHANUMERIC-EDITED",
716 Self::Dbcs => "DBCS",
717 Self::National => "NATIONAL",
718 Self::NationalEdited => "NATIONAL-EDITED",
719 Self::Numeric => "NUMERIC",
720 Self::NumericEdited => "NUMERIC-EDITED",
721 Self::Utf8 => "UTF-8",
722 }
723 }
724}
725
726#[derive(Clone, Debug, Default, PartialEq, Eq)]
728pub struct InitializeWith {
729 pub filler: bool,
730 pub value: Vec<DataCategory>,
731 pub replacing: Vec<(DataCategory, Operand)>,
732 pub default: bool,
733}
734
735#[derive(Clone, Copy, Debug, PartialEq, Eq)]
737pub enum InitialValue<'a> {
738 Value,
740 Replacing(&'a Operand),
741 Default,
743}
744
745impl InitializeWith {
746 pub fn initial_value(&self, category: Option<DataCategory>, has_value: bool) -> Option<InitialValue<'_>> {
750 let named = |c: DataCategory| category == Some(c);
751 if has_value && self.value.iter().any(|&c| named(c)) {
752 return Some(InitialValue::Value);
753 }
754 if let Some((_, by)) = self.replacing.iter().find(|(c, _)| named(*c)) {
755 return Some(InitialValue::Replacing(by));
756 }
757 (self.default || self.value.is_empty() && self.replacing.is_empty()).then_some(InitialValue::Default)
758 }
759}
760
761#[derive(Clone, Debug, PartialEq, Eq)]
763pub struct Inspect {
764 pub target: Operand,
765 pub tallying: Vec<InspectPhrase>,
766 pub replacing: Vec<InspectPhrase>,
767 pub converting: Option<(Operand, Operand, Vec<Bound>)>,
768 pub pos: Pos,
769}
770
771#[derive(Clone, Debug, PartialEq, Eq)]
772pub struct Search {
773 pub table: Ref,
774 pub all: bool,
775 pub varying: Option<Ref>,
776 pub at_end: Option<Vec<Stmt>>,
777 pub whens: Vec<(Cond, Vec<Stmt>)>,
778 pub pos: Pos,
779}
780
781#[derive(Clone, Copy, Debug, PartialEq, Eq)]
782pub enum ExecKind {
783 Sql,
784 Cics,
785 Dli,
786 Other,
787}
788
789#[derive(Clone, Debug, PartialEq, Eq)]
790pub enum ExecArg {
791 Operand(Operand),
792 Text(String),
794}
795
796#[derive(Clone, Debug, PartialEq, Eq)]
798pub struct ExecBlock {
799 pub kind: ExecKind,
800 pub command: String,
802 pub options: Vec<(String, Option<ExecArg>)>,
804 pub host_variables: Vec<Ref>,
806 pub sql: Option<crate::sql::Sql>,
808 pub text: String,
809 pub pos: Pos,
810}
811
812impl ExecBlock {
813 pub fn declarative(&self) -> bool {
815 self.kind == ExecKind::Sql
816 && matches!(self.command.as_str(), "INCLUDE" | "BEGIN DECLARE SECTION" | "END DECLARE SECTION" | "WHENEVER" | "DECLARE CURSOR" | "DECLARE TABLE" | "DECLARE STATEMENT")
817 }
818}
819
820#[derive(Clone, Debug, Default, PartialEq, Eq)]
822pub struct Handlers {
823 pub on: Option<Vec<Stmt>>,
824 pub not_on: Option<Vec<Stmt>>,
825}
826
827#[derive(Clone, Debug, PartialEq, Eq)]
828pub struct ReadStmt {
829 pub file: String,
830 pub next: bool,
832 pub previous: bool,
833 pub into: Option<Ref>,
834 pub key: Option<Ref>,
836 pub at_end: Handlers,
837 pub invalid: Handlers,
838 pub pos: Pos,
839}
840
841#[derive(Clone, Debug, PartialEq, Eq)]
843pub enum Alphabet {
844 Ebcdic,
845 Native,
846 Standard1,
847 Standard2,
848 Literal(Vec<AlphabetEntry>),
850}
851
852impl Alphabet {
853 pub fn name(&self) -> &'static str {
854 match self {
855 Self::Ebcdic => "EBCDIC",
856 Self::Native => "NATIVE",
857 Self::Standard1 => "STANDARD-1",
858 Self::Standard2 => "STANDARD-2",
859 Self::Literal(_) => "literal",
860 }
861 }
862}
863
864#[derive(Clone, Debug, PartialEq, Eq)]
867pub enum AlphabetEntry {
868 Literal(Literal),
869 Through(Literal, Literal),
870 Also(Vec<Literal>),
871}
872
873#[derive(Clone, Debug, Default, PartialEq, Eq)]
875pub struct Environment {
876 pub alphabets: Vec<(String, Alphabet)>,
878 pub collating_sequence: Option<String>,
880 pub same_record_areas: Vec<Vec<String>>,
882 pub same_areas: Vec<Vec<String>>,
883 pub mnemonics: Vec<(String, String)>,
886 pub debugging_mode: bool,
889 pub decimal_point_comma: bool,
892 pub currency: Vec<CurrencySign>,
894}
895
896#[derive(Clone, Debug, PartialEq, Eq)]
899pub struct Upon {
900 pub name: String,
901 pub device: String,
902}
903
904#[derive(Clone, Debug, PartialEq, Eq)]
906pub struct CurrencySign {
907 pub value: String,
908 pub symbol: char,
909 pub hex: Option<Vec<u8>>,
912}
913
914pub const HEX_SYMBOL: char = '\0';
916
917#[derive(Clone, Debug, PartialEq, Eq)]
918pub enum Sorting {
919 Sort(SortStmt),
920 Release { record: Ref, from: Option<Operand>, pos: Pos },
921 Return { file: String, into: Option<Ref>, at_end: Handlers, pos: Pos },
922}
923
924#[derive(Clone, Debug, PartialEq, Eq)]
926pub struct SortStmt {
927 pub merge: bool,
928 pub subject: Ref,
930 pub keys: Vec<(bool, Ref)>,
932 pub duplicates: bool,
933 pub collating: Option<String>,
934 pub input: Option<SortIo>,
935 pub output: Option<SortIo>,
936 pub pos: Pos,
937}
938
939#[derive(Clone, Debug, PartialEq, Eq)]
941pub enum SortIo {
942 Files(Vec<String>),
943 Procedure { from: ProcName, thru: Option<ProcName> },
944}
945
946
947#[derive(Clone, Debug, PartialEq, Eq)]
949pub struct JsonGenerate {
950 pub receiver: Ref,
951 pub from: Ref,
952 pub count: Option<Ref>,
953 pub names: Vec<(Ref, Option<Literal>)>,
955 pub suppress: Vec<Suppression>,
956 pub converting: Vec<(Ref, JsonConversion)>,
957 pub indicating: Vec<NullIndicator>,
958 pub encoding: Option<Encoding>,
959 pub on_exception: Option<Vec<Stmt>>,
960 pub not_on_exception: Option<Vec<Stmt>>,
961 pub pos: Pos,
962}
963
964#[derive(Clone, Debug, PartialEq, Eq)]
968pub enum Suppression {
969 Item { item: Ref, when: Vec<Figurative> },
970 Every { numeric: Option<bool>, form: Option<XmlForm>, when: Vec<Figurative> },
971}
972
973#[derive(Clone, Debug, PartialEq, Eq)]
976pub enum Marker {
977 Condition(Ref),
978 Literal(Literal),
979}
980
981#[derive(Clone, Debug, PartialEq, Eq)]
982pub enum JsonConversion {
983 Boolean(Marker),
984 Null(Figurative),
985}
986
987#[derive(Clone, Debug, PartialEq, Eq)]
989pub struct NullIndicator {
990 pub item: Ref,
991 pub marker: Marker,
992 pub indicator: Option<Ref>,
993}
994
995#[derive(Clone, Debug, PartialEq, Eq)]
996pub enum Encoding {
997 Ccsid(Operand),
998 FromCodepage,
999}
1000
1001#[derive(Clone, Debug, PartialEq, Eq)]
1003pub struct JsonParse {
1004 pub source: Ref,
1005 pub into: Ref,
1006 pub detail: bool,
1007 pub ignoring: Vec<Option<Ref>>,
1009 pub indicating: Vec<(Ref, Flag, Option<Ref>)>,
1011 pub encoding: Option<Encoding>,
1012 pub names: Vec<(Ref, Option<Literal>)>,
1014 pub suppress: Vec<Ref>,
1015 pub converting: Vec<(Ref, ParseConversion)>,
1016 pub on_exception: Option<Vec<Stmt>>,
1017 pub not_on_exception: Option<Vec<Stmt>>,
1018 pub pos: Pos,
1019}
1020
1021#[derive(Clone, Debug, PartialEq, Eq)]
1025pub enum Flag {
1026 Condition(Ref),
1027 Conditions(Ref, Ref),
1028 Literals(Literal, Literal),
1029}
1030
1031#[derive(Clone, Debug, PartialEq, Eq)]
1032pub enum ParseConversion {
1033 Boolean(Box<Flag>),
1034 Null(Figurative),
1035}
1036
1037#[derive(Clone, Debug, PartialEq, Eq)]
1039pub struct XmlGenerate {
1040 pub receiver: Ref,
1041 pub from: Ref,
1042 pub count: Option<Ref>,
1043 pub encoding: Option<Operand>,
1045 pub declaration: bool,
1046 pub attributes: bool,
1047 pub namespace: Option<Operand>,
1048 pub prefix: Option<Operand>,
1049 pub names: Vec<(Ref, Literal)>,
1050 pub types: Vec<(Ref, XmlForm)>,
1051 pub suppress: Vec<Suppression>,
1052 pub on_exception: Option<Vec<Stmt>>,
1053 pub not_on_exception: Option<Vec<Stmt>>,
1054 pub pos: Pos,
1055}
1056
1057#[derive(Clone, Copy, Debug, PartialEq, Eq)]
1059pub enum XmlForm {
1060 Attribute,
1061 Element,
1062 Content,
1063}
1064
1065#[derive(Clone, Debug, PartialEq, Eq)]
1067pub struct XmlParse {
1068 pub document: Ref,
1069 pub encoding: Option<Operand>,
1071 pub returning_national: bool,
1072 pub procedure: ProcName,
1073 pub thru: Option<ProcName>,
1074 pub on_exception: Option<Vec<Stmt>>,
1075 pub not_on_exception: Option<Vec<Stmt>>,
1076 pub pos: Pos,
1077}