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, 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 Named(String),
433}
434
435#[derive(Clone, Debug, PartialEq, Eq)]
436pub enum Cond {
437 Rel(Expr, RelOp, Expr),
438 Class(Expr, Class),
439 Name(Ref),
440 NameOrRel { subject: Expr, op: RelOp, negated: bool, name: Ref },
444 Not(Box<Cond>),
445 And(Box<Cond>, Box<Cond>),
446 Or(Box<Cond>, Box<Cond>),
447}
448
449#[derive(Clone, Debug, PartialEq, Eq)]
450pub struct Target {
451 pub r: Ref,
452 pub rounded: bool,
453}
454
455#[derive(Clone, Debug, PartialEq, Eq)]
456pub struct Varying {
457 pub var: Ref,
458 pub from: Expr,
459 pub by: Expr,
460 pub until: Cond,
461}
462
463#[derive(Clone, Debug, PartialEq, Eq)]
464pub enum Loop {
465 Once,
466 Times(Expr),
467 Until { cond: Cond, test_after: bool },
468 Varying { varying: Box<Varying>, after: Vec<Varying>, test_after: bool },
470}
471
472#[derive(Clone, Debug, PartialEq, Eq)]
473pub enum Stmt {
474 Move { from: Operand, to: Vec<Ref>, pos: Pos },
475 Compute { targets: Vec<Target>, expr: Expr, size_error: Option<SizeError>, pos: Pos },
476 Arith(Box<Arith>),
478 Corresponding(Box<Corresponding>),
481 If { cond: Cond, then: Vec<Stmt>, otherwise: Vec<Stmt>, pos: Pos },
482 PerformInline { body: Vec<Stmt>, repeat: Loop, pos: Pos },
483 PerformProc { from: ProcName, thru: Option<ProcName>, repeat: Loop, pos: Pos },
484 Evaluate { subjects: Vec<Subject>, whens: Vec<When>, other: Vec<Stmt>, pos: Pos },
485 Display { items: Vec<Operand>, upon: Option<Upon>, no_advancing: bool, pos: Pos },
486 Open { files: Vec<(OpenMode, String)>, pos: Pos },
487 Close { files: Vec<(String, Option<Closing>)>, pos: Pos },
488 Read(Box<ReadStmt>),
489 Write { record: Ref, from: Option<Operand>, advancing: Option<Advancing>, invalid: Handlers, end_of_page: Handlers, pos: Pos },
490 Rewrite { record: Ref, from: Option<Operand>, invalid: Handlers, pos: Pos },
491 Delete { file: String, invalid: Handlers, pos: Pos },
492 Start { file: String, key: Option<(RelOp, Ref)>, invalid: Handlers, pos: Pos },
493 Initialize { targets: Vec<Ref>, with: Option<Box<InitializeWith>>, pos: Pos },
495 GoTo { target: Option<ProcName>, pos: Pos },
497 GoToDepending { targets: Vec<ProcName>, on: Ref, pos: Pos },
499 Alter { pairs: Vec<(ProcName, ProcName)>, pos: Pos },
501 Entry { name: String, using: Vec<Param>, pos: Pos },
503 Goback { pos: Pos },
504 ExitProgram { pos: Pos },
506 Call(Box<Call>),
507 Cancel { targets: Vec<Operand>, pos: Pos },
508 Set { set: SetStmt, pos: Pos },
509 Accept { target: Ref, from: AcceptFrom, exception: Handlers, pos: Pos },
512 String(Box<StringStmt>),
513 Unstring(Box<Unstring>),
514 Inspect(Box<Inspect>),
515 Search(Box<Search>),
516 NextSentence,
518 SentenceEnd,
520 Exec(Box<ExecBlock>),
521 Report(Box<crate::report::ReportStmt>),
522 Invoke(Box<Invoke>),
523 JsonGenerate(Box<JsonGenerate>),
524 JsonParse(Box<JsonParse>),
525 XmlParse(Box<XmlParse>),
526 XmlGenerate(Box<XmlGenerate>),
527 ExitMethod { pos: Pos },
528 Sorting(Box<Sorting>),
529 StopRun { pos: Pos },
530 Continue,
531 Exit { kind: ExitKind, pos: Pos },
532}
533
534#[derive(Clone, Debug, PartialEq, Eq)]
535pub struct SizeError {
536 pub on: Vec<Stmt>,
537 pub not_on: Vec<Stmt>,
538}
539
540#[derive(Clone, Copy, Debug, PartialEq, Eq)]
541pub enum ArithVerb {
542 Add,
543 Subtract,
544 Multiply,
545 Divide,
546}
547
548#[derive(Clone, Debug, PartialEq, Eq)]
552pub struct Arith {
553 pub verb: ArithVerb,
554 pub computations: Vec<(Target, Expr)>,
555 pub remainder: Option<(Target, Expr, Expr)>,
556 pub size_error: Option<SizeError>,
557 pub pos: Pos,
558}
559
560#[derive(Clone, Copy, Debug, PartialEq, Eq)]
561pub enum CorrespondingVerb {
562 Move,
563 Add,
564 Subtract,
565}
566
567#[derive(Clone, Debug, PartialEq, Eq)]
570pub struct Corresponding {
571 pub verb: CorrespondingVerb,
572 pub from: Ref,
573 pub to: Ref,
574 pub rounded: bool,
575 pub size_error: Option<SizeError>,
576 pub pos: Pos,
577}
578
579#[derive(Clone, Copy, Debug, PartialEq, Eq)]
580pub enum ArgMode {
581 Reference,
582 Content,
583 Value,
584}
585
586#[derive(Clone, Debug, PartialEq, Eq)]
588pub struct Arg {
589 pub mode: ArgMode,
590 pub value: Option<Operand>,
591}
592
593#[derive(Clone, Debug, PartialEq, Eq)]
594pub struct Call {
595 pub target: Operand,
596 pub using: Vec<Arg>,
597 pub returning: Option<Ref>,
598 pub on_exception: Option<Vec<Stmt>>,
599 pub not_on_exception: Option<Vec<Stmt>>,
600 pub pos: Pos,
601}
602
603#[derive(Clone, Debug, PartialEq, Eq)]
604pub enum SetStmt {
605 ConditionTrue(Vec<Ref>),
606 ConditionFalse(Vec<Ref>),
608 To { targets: Vec<Ref>, value: Operand },
610 Entry { targets: Vec<Ref>, entry: Operand },
612 AddressOf { targets: Vec<Ref>, value: Operand },
614 UpDown { targets: Vec<Ref>, down: bool, by: Expr },
615 Switches(Vec<(Vec<Ref>, bool)>),
617}
618
619#[derive(Clone, Debug, PartialEq, Eq)]
620pub enum Delimiter {
621 Size,
622 By(Operand),
623}
624
625#[derive(Clone, Debug, PartialEq, Eq)]
626pub struct StringStmt {
627 pub sources: Vec<(Operand, Delimiter)>,
628 pub into: Ref,
629 pub pointer: Option<Ref>,
630 pub on_overflow: Option<Vec<Stmt>>,
631 pub not_on_overflow: Option<Vec<Stmt>>,
632 pub pos: Pos,
633}
634
635#[derive(Clone, Debug, PartialEq, Eq)]
636pub struct UnstringInto {
637 pub target: Ref,
638 pub delimiter_in: Option<Ref>,
639 pub count_in: Option<Ref>,
640}
641
642#[derive(Clone, Debug, PartialEq, Eq)]
643pub struct Unstring {
644 pub source: Ref,
645 pub delimiters: Vec<(bool, Operand)>,
647 pub into: Vec<UnstringInto>,
648 pub pointer: Option<Ref>,
649 pub tallying: Option<Ref>,
650 pub on_overflow: Option<Vec<Stmt>>,
651 pub not_on_overflow: Option<Vec<Stmt>>,
652 pub pos: Pos,
653}
654
655#[derive(Clone, Debug, PartialEq, Eq)]
657pub struct Bound {
658 pub after: bool,
659 pub value: Operand,
660}
661
662pub use rt::vocab::InspectMode;
663
664#[derive(Clone, Debug, PartialEq, Eq)]
666pub struct InspectPhrase {
667 pub mode: InspectMode,
668 pub pattern: Option<Operand>,
669 pub by: Option<Operand>,
670 pub counter: Option<Ref>,
671 pub bounds: Vec<Bound>,
672}
673
674#[derive(Clone, Copy, Debug, PartialEq, Eq)]
677pub enum DataCategory {
678 Alphabetic,
679 Alphanumeric,
680 AlphanumericEdited,
681 Dbcs,
682 National,
683 NationalEdited,
684 Numeric,
685 NumericEdited,
686 Utf8,
687}
688
689impl DataCategory {
690 pub const ALL: [Self; 9] = [
691 Self::Alphabetic,
692 Self::Alphanumeric,
693 Self::AlphanumericEdited,
694 Self::Dbcs,
695 Self::National,
696 Self::NationalEdited,
697 Self::Numeric,
698 Self::NumericEdited,
699 Self::Utf8,
700 ];
701
702 pub fn from_word(word: &str) -> Option<Self> {
703 Some(match word {
704 "ALPHABETIC" => Self::Alphabetic,
705 "ALPHANUMERIC" => Self::Alphanumeric,
706 "ALPHANUMERIC-EDITED" => Self::AlphanumericEdited,
707 "DBCS" | "EGCS" => Self::Dbcs,
708 "NATIONAL" => Self::National,
709 "NATIONAL-EDITED" => Self::NationalEdited,
710 "NUMERIC" => Self::Numeric,
711 "NUMERIC-EDITED" => Self::NumericEdited,
712 "UTF-8" => Self::Utf8,
713 _ => return None,
714 })
715 }
716
717 pub fn word(self) -> &'static str {
718 match self {
719 Self::Alphabetic => "ALPHABETIC",
720 Self::Alphanumeric => "ALPHANUMERIC",
721 Self::AlphanumericEdited => "ALPHANUMERIC-EDITED",
722 Self::Dbcs => "DBCS",
723 Self::National => "NATIONAL",
724 Self::NationalEdited => "NATIONAL-EDITED",
725 Self::Numeric => "NUMERIC",
726 Self::NumericEdited => "NUMERIC-EDITED",
727 Self::Utf8 => "UTF-8",
728 }
729 }
730}
731
732#[derive(Clone, Debug, Default, PartialEq, Eq)]
734pub struct InitializeWith {
735 pub filler: bool,
736 pub value: Vec<DataCategory>,
737 pub replacing: Vec<(DataCategory, Operand)>,
738 pub default: bool,
739}
740
741#[derive(Clone, Copy, Debug, PartialEq, Eq)]
743pub enum InitialValue<'a> {
744 Value,
746 Replacing(&'a Operand),
747 Default,
749}
750
751impl InitializeWith {
752 pub fn initial_value(&self, category: Option<DataCategory>, has_value: bool) -> Option<InitialValue<'_>> {
756 let named = |c: DataCategory| category == Some(c);
757 if has_value && self.value.iter().any(|&c| named(c)) {
758 return Some(InitialValue::Value);
759 }
760 if let Some((_, by)) = self.replacing.iter().find(|(c, _)| named(*c)) {
761 return Some(InitialValue::Replacing(by));
762 }
763 (self.default || self.value.is_empty() && self.replacing.is_empty()).then_some(InitialValue::Default)
764 }
765}
766
767#[derive(Clone, Debug, PartialEq, Eq)]
769pub struct Inspect {
770 pub target: Operand,
771 pub tallying: Vec<InspectPhrase>,
772 pub replacing: Vec<InspectPhrase>,
773 pub converting: Option<(Operand, Operand, Vec<Bound>)>,
774 pub pos: Pos,
775}
776
777#[derive(Clone, Debug, PartialEq, Eq)]
778pub struct Search {
779 pub table: Ref,
780 pub all: bool,
781 pub varying: Option<Ref>,
782 pub at_end: Option<Vec<Stmt>>,
783 pub whens: Vec<(Cond, Vec<Stmt>)>,
784 pub pos: Pos,
785}
786
787#[derive(Clone, Copy, Debug, PartialEq, Eq)]
788pub enum ExecKind {
789 Sql,
790 Cics,
791 Dli,
792 Other,
793}
794
795#[derive(Clone, Debug, PartialEq, Eq)]
796pub enum ExecArg {
797 Operand(Operand),
798 Text(String),
800}
801
802#[derive(Clone, Debug, PartialEq, Eq)]
804pub struct ExecBlock {
805 pub kind: ExecKind,
806 pub command: String,
808 pub options: Vec<(String, Option<ExecArg>)>,
810 pub host_variables: Vec<Ref>,
812 pub sql: Option<crate::sql::Sql>,
814 pub text: String,
815 pub pos: Pos,
816}
817
818impl ExecBlock {
819 pub fn declarative(&self) -> bool {
821 self.kind == ExecKind::Sql
822 && matches!(self.command.as_str(), "INCLUDE" | "BEGIN DECLARE SECTION" | "END DECLARE SECTION" | "WHENEVER" | "DECLARE CURSOR" | "DECLARE TABLE" | "DECLARE STATEMENT")
823 }
824}
825
826#[derive(Clone, Debug, Default, PartialEq, Eq)]
828pub struct Handlers {
829 pub on: Option<Vec<Stmt>>,
830 pub not_on: Option<Vec<Stmt>>,
831}
832
833#[derive(Clone, Debug, PartialEq, Eq)]
834pub struct ReadStmt {
835 pub file: String,
836 pub next: bool,
838 pub previous: bool,
839 pub into: Option<Ref>,
840 pub key: Option<Ref>,
842 pub at_end: Handlers,
843 pub invalid: Handlers,
844 pub pos: Pos,
845}
846
847#[derive(Clone, Debug, PartialEq, Eq)]
849pub enum Alphabet {
850 Ebcdic,
851 Native,
852 Standard1,
853 Standard2,
854 Literal(Vec<AlphabetEntry>),
856}
857
858impl Alphabet {
859 pub fn name(&self) -> &'static str {
860 match self {
861 Self::Ebcdic => "EBCDIC",
862 Self::Native => "NATIVE",
863 Self::Standard1 => "STANDARD-1",
864 Self::Standard2 => "STANDARD-2",
865 Self::Literal(_) => "literal",
866 }
867 }
868}
869
870#[derive(Clone, Debug, PartialEq, Eq)]
873pub enum AlphabetEntry {
874 Literal(Literal),
875 Through(Literal, Literal),
876 Also(Vec<Literal>),
877}
878
879#[derive(Clone, Debug, Default, PartialEq, Eq)]
881pub struct Environment {
882 pub alphabets: Vec<(String, Alphabet)>,
884 pub collating_sequence: Option<String>,
886 pub same_record_areas: Vec<Vec<String>>,
888 pub same_areas: Vec<Vec<String>>,
889 pub mnemonics: Vec<(String, String)>,
892 pub debugging_mode: bool,
895 pub decimal_point_comma: bool,
898 pub currency: Vec<CurrencySign>,
900 pub switches: Vec<Switch>,
902 pub classes: Vec<ClassClause>,
904}
905
906#[derive(Clone, Debug, PartialEq, Eq)]
908pub struct ClassClause {
909 pub name: String,
910 pub members: Vec<(Literal, Option<Literal>)>,
911 pub pos: Pos,
912}
913
914#[derive(Clone, Debug, PartialEq, Eq)]
917pub struct Switch {
918 pub number: u8,
919 pub mnemonic: Option<String>,
920 pub on: Option<String>,
921 pub off: Option<String>,
922 pub pos: Pos,
923}
924
925#[derive(Clone, Debug, PartialEq, Eq)]
928pub struct Upon {
929 pub name: String,
930 pub device: String,
931}
932
933#[derive(Clone, Debug, PartialEq, Eq)]
935pub struct CurrencySign {
936 pub value: String,
937 pub symbol: char,
938 pub hex: Option<Vec<u8>>,
941}
942
943pub const HEX_SYMBOL: char = '\0';
945
946#[derive(Clone, Debug, PartialEq, Eq)]
947pub enum Sorting {
948 Sort(SortStmt),
949 Release { record: Ref, from: Option<Operand>, pos: Pos },
950 Return { file: String, into: Option<Ref>, at_end: Handlers, pos: Pos },
951}
952
953#[derive(Clone, Debug, PartialEq, Eq)]
955pub struct SortStmt {
956 pub merge: bool,
957 pub subject: Ref,
959 pub keys: Vec<(bool, Ref)>,
961 pub duplicates: bool,
962 pub collating: Option<String>,
963 pub input: Option<SortIo>,
964 pub output: Option<SortIo>,
965 pub pos: Pos,
966}
967
968#[derive(Clone, Debug, PartialEq, Eq)]
970pub enum SortIo {
971 Files(Vec<String>),
972 Procedure { from: ProcName, thru: Option<ProcName> },
973}
974
975
976#[derive(Clone, Debug, PartialEq, Eq)]
978pub struct JsonGenerate {
979 pub receiver: Ref,
980 pub from: Ref,
981 pub count: Option<Ref>,
982 pub names: Vec<(Ref, Option<Literal>)>,
984 pub suppress: Vec<Suppression>,
985 pub converting: Vec<(Ref, JsonConversion)>,
986 pub indicating: Vec<NullIndicator>,
987 pub encoding: Option<Encoding>,
988 pub on_exception: Option<Vec<Stmt>>,
989 pub not_on_exception: Option<Vec<Stmt>>,
990 pub pos: Pos,
991}
992
993#[derive(Clone, Debug, PartialEq, Eq)]
997pub enum Suppression {
998 Item { item: Ref, when: Vec<Figurative> },
999 Every { numeric: Option<bool>, form: Option<XmlForm>, when: Vec<Figurative> },
1000}
1001
1002#[derive(Clone, Debug, PartialEq, Eq)]
1005pub enum Marker {
1006 Condition(Ref),
1007 Literal(Literal),
1008}
1009
1010#[derive(Clone, Debug, PartialEq, Eq)]
1011pub enum JsonConversion {
1012 Boolean(Marker),
1013 Null(Figurative),
1014}
1015
1016#[derive(Clone, Debug, PartialEq, Eq)]
1018pub struct NullIndicator {
1019 pub item: Ref,
1020 pub marker: Marker,
1021 pub indicator: Option<Ref>,
1022}
1023
1024#[derive(Clone, Debug, PartialEq, Eq)]
1025pub enum Encoding {
1026 Ccsid(Operand),
1027 FromCodepage,
1028}
1029
1030#[derive(Clone, Debug, PartialEq, Eq)]
1032pub struct JsonParse {
1033 pub source: Ref,
1034 pub into: Ref,
1035 pub detail: bool,
1036 pub ignoring: Vec<Option<Ref>>,
1038 pub indicating: Vec<(Ref, Flag, Option<Ref>)>,
1040 pub encoding: Option<Encoding>,
1041 pub names: Vec<(Ref, Option<Literal>)>,
1043 pub suppress: Vec<Ref>,
1044 pub converting: Vec<(Ref, ParseConversion)>,
1045 pub on_exception: Option<Vec<Stmt>>,
1046 pub not_on_exception: Option<Vec<Stmt>>,
1047 pub pos: Pos,
1048}
1049
1050#[derive(Clone, Debug, PartialEq, Eq)]
1054pub enum Flag {
1055 Condition(Ref),
1056 Conditions(Ref, Ref),
1057 Literals(Literal, Literal),
1058}
1059
1060#[derive(Clone, Debug, PartialEq, Eq)]
1061pub enum ParseConversion {
1062 Boolean(Box<Flag>),
1063 Null(Figurative),
1064}
1065
1066#[derive(Clone, Debug, PartialEq, Eq)]
1068pub struct XmlGenerate {
1069 pub receiver: Ref,
1070 pub from: Ref,
1071 pub count: Option<Ref>,
1072 pub encoding: Option<Operand>,
1074 pub declaration: bool,
1075 pub attributes: bool,
1076 pub namespace: Option<Operand>,
1077 pub prefix: Option<Operand>,
1078 pub names: Vec<(Ref, Literal)>,
1079 pub types: Vec<(Ref, XmlForm)>,
1080 pub suppress: Vec<Suppression>,
1081 pub on_exception: Option<Vec<Stmt>>,
1082 pub not_on_exception: Option<Vec<Stmt>>,
1083 pub pos: Pos,
1084}
1085
1086#[derive(Clone, Copy, Debug, PartialEq, Eq)]
1088pub enum XmlForm {
1089 Attribute,
1090 Element,
1091 Content,
1092}
1093
1094#[derive(Clone, Debug, PartialEq, Eq)]
1096pub struct XmlParse {
1097 pub document: Ref,
1098 pub encoding: Option<Operand>,
1100 pub returning_national: bool,
1101 pub procedure: ProcName,
1102 pub thru: Option<ProcName>,
1103 pub on_exception: Option<Vec<Stmt>>,
1104 pub not_on_exception: Option<Vec<Stmt>>,
1105 pub pos: Pos,
1106}