-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtarget.c
3873 lines (3575 loc) · 160 KB
/
target.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
**
** _ ____ _ ___ _ ___ ___
** | | | |_ \ \_/ / / \ | |\ | / / \ __ ) )
** |_|__ |_|__ /_/ \ \_\_/ |_| \| \_\_/ (_() _)_)
**
**
** Lexon — natural language programming
**
** Copyright (C) 2016-24 Henning Diedrich. Licensed to you under
** AGPL3 subject to the conditions described in the file LICENSE.
**
** Also see https://www.lexon.org/license-0.3.html
**
**
** Lexon code production / AST walk target module
*/
## target.c
##
## This file is used to create javascript.c, solidity.c and sophia.c.
## It is a blend of all three and not intended to compile as-is.
##
## This streamlines grammar extension work that comprises identical
## boilerplate across the targets, and common additional logic.
## It is an intermediary device to find the commonalities between targets
## en-route to a higher-level abstraction of shared basics.
##
## Lines are marked for how they are split up by the Makefile:
##
## /*JS */ Javascript only
## /*Sol*/ Solidity only
## /*Sop*/ Sophia only
## /*J+S*/ Javascript and Solidity
## /*S+S*/ Solidity and Sophia
## /*T*/ generated boilerplate
##
## All other lines, and the *T* boilerplate, are shared by all targets.
##
## The tags are processed during build by one-liners in the Makefile
## to create javascript.c, solidity.c and sophia.c.
##
## To work with this source, to help telling apart the targets, add this
## syntax highlighting in ~/.vimrc:
##
## :syntax on
##
## autocmd ColorScheme *
## \ syn match lexfrontT "\/\*T.*" contains=cFunction |
## \ syn match lexfrontJS "\/\*JS .*" contains=cString |
## \ syn match lexfrontSol "\/\*Sol.*" contains=cString |
## \ syn match lexfrontSop "\/\*Sop.*" contains=cString |
## \ syn match lexfrontJaS "\/\*J+S.*" contains=cString |
## \ syn match lexfrontSaS "\/\*S+S.*" contains=cString |
## \ hi lexfrontT ctermfg=110 guifg=#84a0c6 |
## \ hi lexfrontJS ctermfg=76 guifg=#5fd700 |
## \ hi lexfrontSol ctermfg=51 guifg=#00ffff |
## \ hi lexfrontSaS ctermfg=21 guifg=#0000ff |
## \ hi lexfrontJaS ctermfg=28 guifg=#008700 |
## \ hi lexfrontJxS ctermfg=94 guifg=#875f00 |
## \ hi lexfrontSop ctermfg=127 guifg=#af00afv
##
## This colors every tagged line in its own hue, making the scheme
## more transparent and workable.
/*JS */ /* javascript.c - Javascript backend */
/*JS */
/*JS */ #define backend_version "javascript 0.3.93-95 U"
/*JS */ #define target_version "node 14.1+"
/*Sol*/ /* solidity.c - Solidity backend */
/*Sol*/
/*Sol*/ #define backend_version "solidity 0.3.93-95 U"
/*Sol*/ #define target_version "solidity 0.8+"
/*Sop*/ /* sophia.c - Sophia backend */
/*Sop*/
/*Sop*/ #define backend_version "sophia 0.3.93-95 U"
/*Sop*/ #define target_version "sophia 6+"
#define CYCLE_2 true
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
/*JS */ #define EOL ";"
/*Sol*/ #define EOL ";"
/*Sop*/ #define EOL ""
int yylex(void);
void yyerror(const char *);
static void error(char *msg, char *cargo);
#define NEW(type) \
if(opt_debug_tokens) fprintf(stderr, "tokens : creating node for " #type "\n"); \
type *type = mtrac_malloc(sizeof(struct type)); \
memset(type, 0, sizeof(struct type));
#define mtrac_malloc(size_) _mtrac_malloc(size_, "[unknown]", __FILE__, __LINE__)
#define mtrac_strdup(string_) _mtrac_strdup(string_, "[unknown]", __FILE__, __LINE__)
#define mtrac_free(var_) _mtrac_free(var_, #var_, __FILE__, __LINE__)
#define mtrac_concat(...) _mtrac_concat(__FILE__, __LINE__, 0, 0, __VA_ARGS__, null)
#define replace_first_from(orig_, rep_, with_, from_) \
_replace(orig_, rep_, with_, false, from_, false, #orig_, __FILE__, __LINE__)
void *_mtrac_malloc(size_t size, char *name, char *file, int line);
void *_mtrac_strdup(const char *string, char *name, char *file, int line);
void _mtrac_free(void *p, char *name, char *file, int line);
char **_mtrac_concat(char *file, int line, int down, int right, char **buf, ...);
#define YYFPRINTF yacc_printf
typedef int bool;
#define false 0
#define true 1
#define null (void *)0
extern const char *program_version;
extern const char *grammar_version;
typedef char Literal;
typedef char Name;
typedef char Description;
typedef char Scalar;
typedef char Hex;
#define concat(var_, ...) _concat(#var_, __FILE__, __LINE__, 0, 0, var_, __VA_ARGS__, null)
#define padcat(down_, right_, var_, ...) _concat(#var_, __FILE__, __LINE__, down_, right_, var_, __VA_ARGS__, null)
char **_concat(char *, char*, int, int, int, char **buf, ...);
char **_concatnum(char **buf, char *prefix, int number, char *postfix);
void yacc_printf(FILE *stream, char *format, ...);
extern char *opt_source;
extern bool opt_debug;
extern bool opt_verbose;
extern bool opt_bare;
extern bool opt_instructions;
extern bool opt_comment;
extern bool opt_lexon_comments;
extern bool opt_feedback;
extern bool opt_harden;
extern char *opt_log;
extern int opt_chaining;
extern int opt_signatures;
extern char *opt_persistence;
extern char *opt_bundle;
extern char *opt_email;
extern bool opt_debug_actions;
extern bool opt_debug_tokens;
extern bool opt_debug_production;
extern bool _concat_trace;
extern char *opt_summarized;
extern const char *get_lexcom(const char *);
/* optical convenience */
#define C (1 + (opt_comment?0:1))
/* extern calls from lexon.l */
const char *str(int line);
extern struct Document *root;
bool xxx_document(char **production, struct Document *root, int indent);
#define replace(orig_, rep_, with_) _replace(orig_, rep_, with_, true, null, false, #orig_, __FILE__, __LINE__)
extern char *_replace(char **orig, const char *rep, const char *with, int all, char *from, bool whole, char *origname, char *file, int line);
extern const char *str(int line);
static char *quote_trimmed(const char *token);
static char *dash_spaced(const char *token);
extern char *snake_spaced(const char *token);
extern char *camel_spaced(const char *token);
extern char *LOW(const char *token);
extern char *UP(const char *token);
static char *SAFE(const char *token);
static const char *type(const char *varname, bool option_type, bool forpara);
static const char *nullmap(const char *lex_type, bool defined_default);
static const char *defaultmap(const char *lex_type);
static const char *lextype(const char *varname);
static const char *typemap(const char *lextype, bool option_type, bool forpara);
static const char *nullvalue(const char *name, bool defined_default);
static char *methods = null;
static char *globals = null;
static char *declarations = null;
static char *initializations = null;
static char *fixed = null; // list of variables that have been set in this function
static char *declared = null; // list of variables that come in as paremeters
static char *functions = null;
static bool miller = false;
static char _safe[1003];
static char *SAFE(const char *name) { ////// INCOMPLETE LIST: INCLUDE ALL LANGUAGE KEYWORDS
assert(name);
assert(strlen(name) < 1000);
strcpy(_safe, " ");
strcat(_safe, name);
strcat(_safe, " ");
/*JS */ if(!strstr(" send terminate terminated default ", _safe))
/*Sol*/ if(!strstr(" Message permit send terminate terminated default contract constructor function transfer call check_termination ", _safe))
/*Sop*/ if(!strstr(" Message permit send terminate terminated default contract constructor function transfer call check_termination" // Lexon
/*Sop*/ " contract include let switch type record datatype if elif else function stateful payable true false mod public" // Sophia 7.1
/*Sop*/ " entrypoint private indexed namespace interface main using as for hiding", _safe)) // Sophia 7.1
return (char *)name;
/*S+S*/ strcpy(_safe, "_");
/*S+S*/ strcat(_safe, name); // haystack limits lenght of possible needles
/*JS */ strcpy(_safe, name); //X difference to S+S warranted? //////
/*JS */ strcat(_safe, "_");
return _safe;
}
typedef struct list {
void *item;
struct list *next;
} list;
static void list_add(list **l, void *item) {
list *n = mtrac_malloc(sizeof(list));
n->item = item;
n->next = *l;
*l = n;
}
static list *shallow_clone(list *l) {
list *clone = null;
while(l) {
list_add(&clone, l->item);
l = l->next;
}
return clone;
}
static int drop_item(list **l, list *drop) {
int count = 0;
list *cur = *l, *prev = null;
while(cur) {
if(cur->item == drop->item) {
if(prev) prev->next = cur->next;
else *l = cur->next;
list *next = cur->next;
mtrac_free(cur);
cur = next;
// prev remains
count++;
} else {
prev = cur;
cur = cur->next;
}
}
return count;
}
static void delete_list(list *l) {
list *m;
while((m = l)) l = l->next, mtrac_free(m);
}
static void delete_list_and_items(list *l) {
list *m;
while((m = l)) l = l->next, mtrac_free(m->item), mtrac_free(m);
}
/* this is an optimization to not have all functions require a caller.
This is almost an optical nuance but really about not confusing
users with compilation artifacts. */
static int bind_index = 100;
typedef struct bind {
int index;
char *tag;
char *name;
char *parameters;
char *arguments;
char *parameta; // for instructions, wrapped in < >
bool uses_caller;
bool uses_permission;
bool changes_state;
struct call *calls;
struct bind *next;
} bind;
static bind *binds = null;
static bind *last_bind = null;
typedef struct call {
struct bind *bind;
struct call *next;
} call;
static bool traverse_for_caller(bind *bind, int fuse);
static void produce_access_conditions(int down, int indent, char **production, list *subjects);
/* create or find a binding for a function name */
static bind *register_bind(char *name) {
assert(name && strlen(name));
bind *bind = binds;
while(bind && strcmp(name, bind->name)) bind = bind->next;
if(!bind) {
bind = mtrac_malloc(sizeof(struct bind)); // sic
bind->index = bind_index++;
bind->tag = mtrac_strdup("");
mtrac_concat(&bind->tag, "%", str(bind->index), "%");
bind->name = mtrac_strdup(name);
bind->parameters = mtrac_strdup("");
bind->arguments = mtrac_strdup("");
bind->parameta = mtrac_strdup("");
bind->uses_caller = false;
bind->uses_permission = false;
bind->changes_state = false;
bind->calls = null;
bind->next = null;
if(!binds) binds = bind;
if(last_bind) last_bind->next = bind;
last_bind = bind;
}
return bind;
}
/* register a call and receive the point to be set to the coming next one */
static call **register_call(call **prevnext, char *to) {
call *call = mtrac_malloc(sizeof(call));
call->bind = register_bind(to);
call->next = null;
*prevnext = call;
return &call->next;
}
static void replace_bind_tags(char **production, char **instructions, bind *b) {
while(b) {
char *head = mtrac_strdup("");
char *ihead = mtrac_strdup("");
// if(!b->uses_permission && b->changes_state) ///// replace by logic 'has subject'
// mtrac_concat(&head, "#");
mtrac_concat(&head, b->name);
mtrac_concat(&ihead, b->name);
/*JS */ if(traverse_for_caller(b, 10)) {
/*JS */ mtrac_concat(&head, "(caller", strlen(b->parameters)?", ":"", b->parameters, ")");
/*JS */ if(!strlen(b->parameta)) /* sic: instructions have the subject (caller) in parameta */
/*JS */ mtrac_concat(&ihead, "(<caller>)");
/*JS */ else
/*JS */ mtrac_concat(&ihead, "(", b->parameta, ")");
/*JS */
/*JS */ } else {
mtrac_concat(&head, "(", b->parameters, ")");
mtrac_concat(&ihead, "(", b->parameta, ")");
/*JS */ }
/* now replace the tags standing in for the function declaration head and all calls to the function in the production string */
replace(production, b->tag, head);
replace(instructions, b->tag, ihead); // private functions will just not have a tag to match
mtrac_free(head);
mtrac_free(ihead);
b = b->next;
}
}
static bool traverse_for_caller(bind *bind, int fuse) {
if(bind->uses_caller) return true;
if(!fuse) return false;
call *c = bind->calls;
while(c) {
if(traverse_for_caller(c->bind, fuse-1)) return true;
c = c->next;
}
return false;
}
static void delete_bind_tree(bind *b) {
while(b) {
call *cc, *c = b->calls;
while(c) { cc = c->next; mtrac_free(c); c = cc; }
mtrac_free(b->name);
mtrac_free(b->tag);
if(b->parameters) mtrac_free(b->parameters);
if(b->arguments) mtrac_free(b->arguments);
if(b->parameta) mtrac_free(b->parameta);
bind *bb = b->next;
mtrac_free(b);
b = bb;
}
}
static bool in(char *hay, char *needle) {
char *tagged = mtrac_strdup("");
mtrac_concat(&tagged, ":", needle, ":");
bool in = !!strstr(hay, tagged);
mtrac_free(tagged);
return in;
}
/* AST nodes = semantic value types (in actions, the respective types of '$$') */
/*T*/
/*T*/ typedef struct Document {
/*T*/ struct Head *Head;
/*T*/ struct Terms *Terms;
/*T*/ struct Covenants *Covenants;
/*T*/ } Document;
/*T*/
/*T*/ typedef struct Head {
/*T*/ struct Lex *Lex;
/*T*/ struct Preamble *Preamble;
/*T*/ struct Comment *Comment;
/*T*/ struct Authors *Authors;
/*T*/ struct Lexon *Lexon;
/*T*/ } Head;
/*T*/
/*T*/ typedef struct Lex {
/*T*/ Name *Name;
/*T*/ } Lex;
/*T*/
/*T*/ typedef struct Lexon {
/*T*/ Description *Description;
/*T*/ } Lexon;
/*T*/
/*T*/ typedef struct Authors {
/*T*/ Description *Description;
/*T*/ } Authors;
/*T*/
/*T*/ typedef struct Comment {
/*T*/ Description *Description;
/*T*/ } Comment;
/*T*/
/*T*/ typedef struct Preamble {
/*T*/ Description *Description;
/*T*/ } Preamble;
/*T*/
/*T*/ typedef struct Terms {
/*T*/ struct Provisions *Provisions;
/*T*/ } Terms;
/*T*/
/*T*/ typedef struct Covenants {
/*T*/ struct Covenant *Covenant;
/*T*/ struct Covenants *Covenants;
/*T*/ } Covenants;
/*T*/
/*T*/ typedef struct Covenant {
/*T*/ Name *Name;
/*T*/ struct Provisions *Provisions;
/*T*/ } Covenant;
/*T*/
/*T*/ typedef struct Provisions {
/*T*/ struct Definitions *Definitions;
/*T*/ struct Clauses *Clauses;
/*T*/ struct Statements *Statements;
/*T*/ } Provisions;
/*T*/
/*T*/ typedef struct Definitions {
/*T*/ struct Definition *Definition;
/*T*/ struct Definitions *Definitions;
/*T*/ } Definitions;
/*T*/
/*T*/ typedef struct Definition {
/*T*/ Name *Name;
/*T*/ struct Placeholder *Placeholder;
/*T*/ struct Article *Article;
/*T*/ struct This_Contract *This_Contract;
/*T*/ } Definition;
/*T*/
/*T*/ typedef struct Placeholder {
/*T*/ struct Type *Type;
/*T*/ struct Article *Article;
/*T*/ } Placeholder;
/*T*/
/*T*/ typedef struct Type {
/*T*/ struct Person *Person;
/*T*/ struct Amount *Amount;
/*T*/ struct Time *Time;
/*T*/ struct Binary *Binary;
/*T*/ struct Text *Text;
/*T*/ struct Data *Data;
Literal *Literal;
/*T*/ } Type;
/*T*/
/*T*/ typedef struct Person {
/*T*/ } Person;
/*T*/
/*T*/ typedef struct Amount {
/*T*/ } Amount;
/*T*/
/*T*/ typedef struct Time {
/*T*/ } Time;
/*T*/
/*T*/ typedef struct Binary {
/*T*/ } Binary;
/*T*/
/*T*/ typedef struct Text {
/*T*/ } Text;
/*T*/
/*T*/ typedef struct Data {
/*T*/ } Data;
/*T*/
/*T*/ typedef struct This_Contract {
/*T*/ struct This *This;
/*T*/ Name *Name;
/*T*/ } This_Contract;
/*T*/
/*T*/ typedef struct All_Contracts {
/*T*/ } All_Contracts;
/*T*/
/*T*/ typedef struct This {
/*T*/ } This;
/*T*/
/*T*/ typedef struct Clauses {
/*T*/ struct Clause *Clause;
/*T*/ struct Clauses *Clauses;
/*T*/ } Clauses;
/*T*/
/*T*/ typedef struct Clause {
/*T*/ Name *Name;
/*T*/ struct Body *Body;
/*T*/ } Clause;
/*T*/
/*T*/ typedef struct Body {
/*T*/ struct Statements *Statements;
/*T*/ struct Function *Function;
/*T*/ } Body;
/*T*/
/*T*/ typedef struct Function {
/*T*/ Name *Name;
/*T*/ struct Illocutor *Illocutor;
/*T*/ struct Expression *Expression;
/*T*/ struct Article *Article;
/*T*/ } Function;
/*T*/
/*T*/ typedef struct Statements {
/*T*/ struct Statement *Statement;
/*T*/ struct Statements *Statements;
/*T*/ } Statements;
/*T*/
/*T*/ typedef struct Statement {
/*T*/ struct Action *Action;
/*T*/ struct Flagging *Flagging;
/*T*/ } Statement;
/*T*/
/*T*/ typedef struct Actions {
/*T*/ struct Action *Action;
/*T*/ struct Actions *Actions;
/*T*/ } Actions;
/*T*/
/*T*/ typedef struct Action {
/*T*/ struct Subject *Subject;
/*T*/ struct Predicates *Predicates;
/*T*/ struct Permission *Permission;
/*T*/ struct Condition *Condition;
/*T*/ } Action;
/*T*/
/*T*/ typedef struct Subject {
/*T*/ struct Symbols *Symbols;
/*T*/ } Subject;
/*T*/
/*T*/ typedef struct Symbols {
/*T*/ struct Symbol *Symbol;
/*T*/ struct Symbols *Symbols;
/*T*/ struct Catena *Catena;
/*T*/ } Symbols;
/*T*/
/*T*/ typedef struct Symbol {
/*T*/ Name *Name;
/*T*/ struct Article *Article;
/*T*/ struct Type *Type;
/*T*/ } Symbol;
/*T*/
/*T*/ typedef struct Catena {
/*T*/ } Catena;
/*T*/
/*T*/ typedef struct Object {
/*T*/ struct Symbol *Symbol;
/*T*/ struct Reflexive *Reflexive;
/*T*/ } Object;
/*T*/
/*T*/ typedef struct Reflexive {
/*T*/ } Reflexive;
/*T*/
/*T*/ typedef struct Contract {
/*T*/ struct This_Contract *This_Contract;
/*T*/ struct All_Contracts *All_Contracts;
/*T*/ } Contract;
/*T*/
/*T*/ typedef struct Predicates {
/*T*/ struct Predicates *Predicates;
/*T*/ struct Predicate *Predicate;
/*T*/ } Predicates;
/*T*/
/*T*/ typedef struct Predicate {
/*T*/ struct Certification *Certification;
/*T*/ struct Declaration *Declaration;
/*T*/ struct Filing *Filing;
/*T*/ struct Registration *Registration;
/*T*/ struct Grantment *Grantment;
/*T*/ struct Appointment *Appointment;
/*T*/ struct Fixture *Fixture;
/*T*/ struct Setting *Setting;
/*T*/ struct Payment *Payment;
/*T*/ struct Sending *Sending;
/*T*/ struct Notification *Notification;
/*T*/ struct Termination *Termination;
/*T*/ } Predicate;
/*T*/
/*T*/ typedef struct Permission {
/*T*/ } Permission;
/*T*/
/*T*/ typedef struct Certification {
/*T*/ struct Certify *Certify;
/*T*/ struct Symbol *Symbol;
/*T*/ struct Expression *Expression;
/*T*/ struct Contract *Contract;
/*T*/ } Certification;
/*T*/
/*T*/ typedef struct Certify {
/*T*/ } Certify;
/*T*/
/*T*/ typedef struct Declaration {
/*T*/ struct Declare *Declare;
/*T*/ struct Symbol *Symbol;
/*T*/ struct Expression *Expression;
/*T*/ struct Contract *Contract;
/*T*/ } Declaration;
/*T*/
/*T*/ typedef struct Declare {
/*T*/ } Declare;
/*T*/
/*T*/ typedef struct Filing {
/*T*/ struct File *File;
/*T*/ struct Symbol *Symbol;
/*T*/ struct Expression *Expression;
/*T*/ struct Contract *Contract;
/*T*/ } Filing;
/*T*/
/*T*/ typedef struct File {
/*T*/ } File;
/*T*/
/*T*/ typedef struct Registration {
/*T*/ struct Register *Register;
/*T*/ struct Symbol *Symbol;
/*T*/ struct Expression *Expression;
/*T*/ struct Contract *Contract;
/*T*/ } Registration;
/*T*/
/*T*/ typedef struct Register {
/*T*/ } Register;
/*T*/
/*T*/ typedef struct Grantment {
/*T*/ struct Grant *Grant;
/*T*/ struct Symbol *Symbol;
/*T*/ } Grantment;
/*T*/
/*T*/ typedef struct Grant {
/*T*/ } Grant;
/*T*/
/*T*/ typedef struct Appointment {
/*T*/ struct Appoint *Appoint;
/*T*/ struct Symbol *Symbol;
/*T*/ } Appointment;
/*T*/
/*T*/ typedef struct Appoint {
/*T*/ } Appoint;
/*T*/
/*T*/ typedef struct Fixture {
/*T*/ struct Fix *Fix;
/*T*/ struct Symbol *Symbol;
/*T*/ struct Expression *Expression;
/*T*/ struct Contract *Contract;
/*T*/ } Fixture;
/*T*/
/*T*/ typedef struct Fix {
/*T*/ } Fix;
/*T*/
/*T*/ typedef struct Setting {
/*T*/ struct Illocutor *Illocutor;
/*T*/ struct Symbol *Symbol;
/*T*/ } Setting;
/*T*/
/*T*/ typedef struct Illocutor {
/*T*/ struct Be *Be;
/*T*/ } Illocutor;
/*T*/
/*T*/ typedef struct Be {
/*T*/ } Be;
/*T*/
/*T*/ typedef struct Payment {
/*T*/ struct Pay *Pay;
/*T*/ struct Expression *Expression;
/*T*/ struct Preposition *Preposition;
/*T*/ struct Object *Object;
/*T*/ struct From_Escrow *From_Escrow;
/*T*/ struct Escrow *Escrow;
/*T*/ } Payment;
/*T*/
/*T*/ typedef struct Pay {
/*T*/ } Pay;
/*T*/
/*T*/ typedef struct Preposition {
/*T*/ } Preposition;
/*T*/
/*T*/ typedef struct Escrow {
/*T*/ } Escrow;
/*T*/
/*T*/ typedef struct From_Escrow {
/*T*/ } From_Escrow;
/*T*/
/*T*/ typedef struct Sending {
/*T*/ struct Send *Send;
/*T*/ struct Expression *Expression;
/*T*/ struct Preposition *Preposition;
/*T*/ struct Object *Object;
/*T*/ } Sending;
/*T*/
/*T*/ typedef struct Send {
/*T*/ } Send;
/*T*/
/*T*/ typedef struct Notification {
/*T*/ struct Notify *Notify;
/*T*/ struct Object *Object;
/*T*/ struct Preposition *Preposition;
/*T*/ struct Expression *Expression;
/*T*/ } Notification;
/*T*/
/*T*/ typedef struct Notify {
/*T*/ } Notify;
/*T*/
/*T*/ typedef struct Termination {
/*T*/ struct Terminate *Terminate;
/*T*/ struct This_Contract *This_Contract;
/*T*/ struct All_Contracts *All_Contracts;
/*T*/ } Termination;
/*T*/
/*T*/ typedef struct Terminate {
/*T*/ } Terminate;
/*T*/
/*T*/ typedef struct Flagging {
/*T*/ struct Illocutor *Illocutor;
/*T*/ struct Symbol *Symbol;
/*T*/ struct This_Contract *This_Contract;
/*T*/ } Flagging;
/*T*/
/*T*/ typedef struct Condition {
/*T*/ struct If *If;
/*T*/ struct Expression *Expression;
/*T*/ } Condition;
/*T*/
/*T*/ typedef struct If {
/*T*/ } If;
/*T*/
/*T*/ typedef struct Expression {
/*T*/ struct Combination *Combination;
/*T*/ } Expression;
/*T*/
/*T*/ typedef struct Scalar_Comparison {
/*T*/ struct Scalar_Expression *Scalar_Expression;
/*T*/ struct Comparison_Operator *Comparison_Operator;
/*T*/ struct Scalar_Expression *Scalar_Expression2;
/*T*/ } Scalar_Comparison;
/*T*/
/*T*/ typedef struct Hex_Expression {
/*T*/ struct Symbol *Symbol;
/*T*/ Hex *Hex;
// struct Point_In_Time *Point_In_Time;
/*T*/ } Hex_Expression;
/*T*/
/*T*/ typedef struct Comparison_Operator {
/*T*/ struct Equal *Equal;
/*T*/ struct Later *Later;
/*T*/ } Comparison_Operator;
/*T*/
/*T*/ typedef struct Equal {
/*T*/ } Equal;
/*T*/
/*T*/ typedef struct Later {
/*T*/ } Later;
/*T*/
/*T*/ typedef struct Scalar_Expression {
/*T*/ struct Symbol *Symbol;
/*T*/ Scalar *Scalar;
struct Point_In_Time *Point_In_Time;
/*T*/ } Scalar_Expression;
/*T*/
/*T*/ typedef struct Combination {
/*T*/ struct Combinor *Combinor;
/*T*/ struct Combination *Combination;
/*T*/ struct Combinator *Combinator;
/*T*/ } Combination;
/*T*/
/*T*/ typedef struct Combinor {
/*T*/ struct Combinand *Combinand;
/*T*/ struct Combinator *Combinator;
/*T*/ struct Combinor *Combinor;
/*T*/ } Combinor;
/*T*/
/*T*/ typedef struct Combinand {
/*T*/ struct Symbol *Symbol;
/*T*/ struct Expiration *Expiration;
/*T*/ struct Scalar_Comparison *Scalar_Comparison;
/*T*/ struct Negation *Negation;
/*T*/ struct Existence *Existence;
/*T*/ struct Point_In_Time *Point_In_Time;
/*T*/ } Combinand;
/*T*/
/*T*/ typedef struct Combinator {
/*T*/ struct Or_ *Or_;
/*T*/ struct And *And;
/*T*/ struct Neither *Neither;
/*T*/ struct Nor *Nor;
/*T*/ } Combinator;
/*T*/
/*T*/ typedef struct Or_ {
/*T*/ } Or_;
/*T*/
/*T*/ typedef struct And {
/*T*/ } And;
/*T*/
/*T*/ typedef struct Neither {
/*T*/ } Neither;
/*T*/
/*T*/ typedef struct Nor {
/*T*/ } Nor;
/*T*/
/*T*/ typedef struct Existence {
/*T*/ struct Symbol *Symbol;
/*T*/ struct Contract *Contract;
/*T*/ struct Equal *Equal;
/*T*/ struct Be *Be;
/*T*/ struct Being *Being;
/*T*/ struct True *True;
/*T*/ } Existence;
/*T*/
/*T*/ typedef struct Negation {
/*T*/ struct Negator *Negator;
/*T*/ struct Symbol *Symbol;
/*T*/ struct Contract *Contract;
/*T*/ } Negation;
/*T*/
/*T*/ typedef struct Negator {
/*T*/ struct Be *Be;
/*T*/ } Negator;
/*T*/
/*T*/ typedef struct Being {
/*T*/ } Being;
/*T*/
/*T*/ typedef struct True {
/*T*/ } True;
/*T*/
/*T*/ typedef struct Article {
/*T*/ } Article;
/*T*/
/*T*/ typedef struct Point_In_Time {
/*T*/ struct Current_Time *Current_Time;
/*T*/ struct Relative_Time *Relative_Time;
/*T*/ } Point_In_Time;
/*T*/
/*T*/ typedef struct Current_Time {
/*T*/ } Current_Time;
/*T*/
/*T*/ typedef struct Relative_Time {
/*T*/ struct Duration *Duration;
/*T*/ struct Symbol *Symbol;
/*T*/ } Relative_Time;
/*T*/
/*T*/ typedef struct Duration {
/*T*/ struct Scalar_Expression *Scalar_Expression;
/*T*/ struct Time_Unit *Time_Unit;
/*T*/ } Duration;
/*T*/
/*T*/ typedef struct Time_Unit {
/*T*/ struct Years *Years;
/*T*/ struct Months *Months;
/*T*/ struct Weeks *Weeks;
/*T*/ struct Days *Days;
/*T*/ struct Hours *Hours;
/*T*/ struct Minutes *Minutes;
/*T*/ struct Seconds *Seconds;
/*T*/ struct Milliseconds *Milliseconds;
/*T*/ } Time_Unit;
/*T*/
/*T*/
/*T*/ typedef struct Years {
/*T*/ } Years;
/*T*/
/*T*/ typedef struct Months {
/*T*/ } Months;
/*T*/
/*T*/ typedef struct Weeks {
/*T*/ } Weeks;
/*T*/
/*T*/ typedef struct Days {
/*T*/ } Days;
/*T*/
/*T*/ typedef struct Hours {
/*T*/ } Hours;
/*T*/
/*T*/ typedef struct Minutes {
/*T*/ } Minutes;
/*T*/
/*T*/ typedef struct Seconds {
/*T*/ } Seconds;
/*T*/
/*T*/ typedef struct Milliseconds {
/*T*/ } Milliseconds;
/*T*/
/*T*/ typedef struct Expiration {
/*T*/ } Expiration;
/*T*/
static void insert_parameter_and_set_member(char **production, char **instructions, Symbol *symbol, bool payment, size_t paratag, int indent, int line);
/*T*/ bool xxx_walk(char **production) {
/*T*/ if(!root) return false;
/*T*/ return xxx_document(production, root, 0);
/*T*/ }
static Name *class = null;
static bool main_constructor_body = true;
static bool covenant_constructor_body = false;
static bool recital_of_terms = false;
/*T*/ bool xxx_name(char **production, Name *Name, int indent) {
/*T*/ if(!Name) return false;
/* put '_' to names that are target language keywords */ ///// incomplete list
char *safe = SAFE(LOW(snake_spaced(Name))); ///// don't store LOW buffer
if(!in(functions, Name)) {
/*JS */ padcat(0, 0, production, in(globals, Name) && !main_constructor_body?"main.":"this.", safe);
/*Sol*/ padcat(0, 0, production, safe);
/*Sop*/ padcat(0, 0, production, in(globals, Name) && !miller?"state.":"", safe);
} else {
bind *bind = register_bind(safe);
/*JS */ padcat(0, 0, production, in(globals, Name) && !main_constructor_body?"main.":"this.", bind->tag);
/*Sol*/ padcat(0, 0, production, bind->tag);
/*Sop*/ padcat(0, 0, production, in(globals, Name) && !miller?"state.":"", bind->tag);
}
/*T*/ return true;
/*T*/ }
/*T*/ bool xxx_description(char **production, Description *Description, int indent) {
/*T*/ if(!Description) return false;
/*T*/ padcat(0, 0, production, "\"", Description, "\"");
/*T*/ return true;
/*T*/ }
/*T*/ bool xxx_scalar(char **production, Scalar *Scalar, int indent) {
/*T*/ if(!Scalar) return false;
/*T*/ padcat(0, 0, production, Scalar);
/*T*/ return true;
/*T*/ }
/*T*/ bool xxx_hex(char **production, Hex *Hex, int indent) {
/*T*/ if(!Hex) return false;
/*T*/ padcat(0, 0, production, Hex);
/*T*/ return true;
/*T*/ }
static const char *lexsymtype(Symbol *symbol);
/* AST walk (stub) functions */
/*T*/ bool xxx_document(char **production, Document *Document, int indent);
/*T*/ bool xxx_head(char **production, Head *Head, int indent);
/*T*/ bool xxx_lex(char **production, Lex *Lex, int indent);
/*T*/ bool xxx_lexon(char **production, Lexon *Lexon, int indent);
/*T*/ bool xxx_authors(char **production, Authors *Authors, int indent);
/*T*/ bool xxx_comment(char **production, Comment *Comment, int indent);
/*T*/ bool xxx_preamble(char **production, Preamble *Preamble, int indent);
/*T*/ bool xxx_terms(char **production, Terms *Terms, int indent);
/*T*/ bool xxx_covenants(char **production, Covenants *Covenants, int indent);
/*T*/ bool xxx_covenant(char **production, Covenant *Covenant, int indent);
/*T*/ bool xxx_provisions(char **production, Provisions *Provisions, int indent);
/*T*/ bool xxx_definitions(char **production, Definitions *Definitions, int indent);
/*T*/ bool xxx_definition(char **production, Definition *Definition, int indent);
/*T*/ bool xxx_placeholder(char **production, Placeholder *Placeholder, int indent);
/*T*/ bool xxx_type(char **production, Type *Type, int indent);
/*T*/ bool xxx_person(char **production, Person *Person, int indent);
/*T*/ bool xxx_amount(char **production, Amount *Amount, int indent);
/*T*/ bool xxx_time(char **production, Time *Time, int indent);
/*T*/ bool xxx_binary(char **production, Binary *Binary, int indent);
/*T*/ bool xxx_text(char **production, Text *Text, int indent);
/*T*/ bool xxx_data(char **production, Data *Data, int indent);
/*T*/ bool xxx_this(char **production, This *This, int indent);
/*T*/ bool xxx_clauses(char **production, Clauses *Clauses, int indent);
/*T*/ bool xxx_clause(char **production, Clause *Clause, int indent);
/*T*/ bool xxx_body(char **production, Body *Body, int indent);
/*T*/ bool xxx_function(char **production, Function *Function, int indent);
/*T*/ bool xxx_statements(char **production, Statements *Statements, int indent);
/*T*/ bool xxx_statement(char **production, Statement *Statement, int indent);
/*T*/ bool xxx_actions(char **production, Actions *Actions, int indent);
/*T*/ bool xxx_action(char **production, Action *Action, int indent);
/*T*/ bool xxx_subject(char **production, Subject *Subject, int indent);
/*T*/ bool xxx_symbols(char **production, Symbols *Symbols, int indent);
/*T*/ bool xxx_symbol(char **production, Symbol *Symbol, int indent);
bool xxx_noun(char **production, Symbol *Symbol, int indent);
/*T*/ bool xxx_catena(char **production, Catena *Catena, int indent);
/*T*/ bool xxx_object(char **production, Object *Object, int indent);
/*T*/ bool xxx_reflexive(char **production, Reflexive *Reflexive, int indent);
/*T*/ bool xxx_contract(char **production, Contract *Contract, int indent);
/*T*/ bool xxx_predicates(char **production, Predicates *Predicates, int indent);
/*T*/ bool xxx_predicate(char **production, Predicate *Predicate, int indent);
/*T*/ bool xxx_permission(char **production, Permission *Permission, int indent);
/*T*/ bool xxx_certification(char **production, Certification *Certification, int indent);
/*T*/ bool xxx_certify(char **production, Certify *Certify, int indent);
/*T*/ bool xxx_declaration(char **production, Declaration *Declaration, int indent);