-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathariel.y
2224 lines (1944 loc) · 48.7 KB
/
ariel.y
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
%{
/***************************************************************************
**
** File: ariel.y
**
** Description: parser of the Ariel language
**
** Language: yacc
**
** Version 3.0e [email protected]
** - Added functions for the management of `@' variables.
** - ``reboot'' has been removed. A node can be restarted.
** - added predicate STAGE.
** - added option `-s'
***********************************************************************/
#define VERSION "v3.0e"
#define EFTOS_ENV "TIRAN_HOME"
#define EFTOS_SRC ".ariel"
#define HFNAME "outputs/trl.h"
#define TONAME "outputs/timeouts.h"
#define IDNAME "outputs/identifiers.h"
#define ALPHANAME "outputs/alphacount.h"
#define STRNAME "outputs/arielstrings.h"
#define LOGICAL_FNAME "outputs/LogicalTable.csv"
#define TASK_FNAME "outputs/TaskTable.csv"
#ifndef CLOCKS_PER_SEC
#define CLOCKS_PER_SEC 1000000
#endif
int sflush(char*[], int);
int init_taskram(void);
int init_logicalram(void);
int kbwait (void);
int yyerror (char*);
int yylex (void);
/* debugging */
int phase;
#define DeBug /* {fprintf(stderr, ". debug: phase %d\n", ++phase); fflush(stderr);} */
/* input and output file names */
char *ifname, *ofname;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <fcntl.h>
#include <time.h>
#include "assoc.h"
#include "ObjAlloc.h"
#include "rl.h"
#include "rcode.h"
/* Added on Jan 19 2000 by VdF */
int i, j, d, goto_pc;
extern int list[], card_list, lines;
int default_action;
int tasklist_nr;
int tasklist[MAX_TASKS_IN_LOGICAL];
char verbose, debug;
char static_version;
char notime; /* don't print time of day via external command `date' */
int errors;
int booleans; /* cardinality of the expression list */
int boole_pc[BOOLE_ATOMS]; /* at most BOOLE_ATOMS can be found in one expr */
int booleanstack[RCODE_MAX_NEST]; /* a stack to save booleans */
int nestings;
int rec; /* a flag which records whether an IF has been encountered or not */
int nprocs = 3; /* number of nodes to be used */
int mia_send_timeout = 200000 ; /* timeout `Manager Is Alive' */
int taia_send_timeout = 200000 ; /* timeout `This Agent Is Alive' */
int imalive_clear_timeout = 120000 ; /* I'm Alive timeout */
int mia_recv_timeout = 250000 ; /* timeout `Manager Is Alive' -- backup side */
int taia_recv_timeout = 250000 ; /* `This Agent Is Alive' -- backup side */
int imalive_set_timeout = 300000 ; /* I'm Alive timeout -- IAT side */
int teif_timeout = 300000; /* this entity is faulty */
int mid_timeout = 500000; /* manager is down */
int request_db_timeout = 200000;
int reply_db_timeout = 500000;
int numtask[MAX_NODES];
alphacount_t alphas[MAX_TASKS];
static int var[26]; /* 26 pre-defined and pre-initialised variables */
FILE *f; /* output file pointer */
FILE *h; /* header file pointer */
ASSOC *a; /* associations found in header files */
typedef struct {
unsigned
int role; /* a bit pattern with one or more of these
bit positions turned on:
ID_GROUP, ID_THREAD, ID_NODE, ID_ENTITY,
ID_NORMAL, ID_STAR, ID_DOLLAR */
int id; /* an integer identifying the entity */
} ident_t;
/************************** watchdogs *****************************/
typedef struct {
int watching, watched, rate, unit, action,
target, running;
} watchdog_t;
#define MAX_WDOGS 32
watchdog_t watchdog[MAX_WDOGS];
int w_sp = 0;
#define INCWATCH ++w_sp;
#define WATCHTOP watchdog[w_sp]
#define BADWATCH (w_sp > MAX_WDOGS)
#define MAX_WD_FNAME 80
#define MAX_WD_NAME 40
int watchdog_flush(watchdog_t*, int);
/*********************** end watchdogs ****************************/
/************************* nversion ******************************/
typedef struct { int version, task, timeout, unit; } version_t;
#define MAX_VERS 7
typedef struct {
int running, task;
version_t va[MAX_VERS]; int va_num;
int voting; char *metric;
int success, error;
int versmin, versmax;
} nversion_t;
#define MAX_NVERS 16
nversion_t nversion[MAX_NVERS];
int nv_sp = 0;
#define INCNVERS ++nv_sp;
#define NVERSTOP nversion[nv_sp]
#define BADNVERS (nv_sp > MAX_NVERS)
#define MAX_NV_FNAME 80
#define MAX_NV_NAME 40
int nversion_flush(nversion_t*, int);
/*********************** end nversion ****************************/
#define GENERATE_RACTION(act,who) \
if (who.role & ID_DOLLAR) \
{ \
rcode_raction(act, who.role, - boole_pc[ who.id -1 ]); \
d=dollarsign_check(who.role, boole_pc[ who.id -1]); \
if (d == 1) \
{ \
errors++; \
fprintf(stderr, "\tLine %d: semantical error: ", lines); \
yyerror("Improper use of ``$'' sign."); \
} \
if (who.id > booleans) \
{ \
errors++; \
fprintf(stderr, "\tLine %d: semantical error: ", lines); \
yyerror("Too large an index in $var."); \
} \
} \
else \
if (who.role & ID_DOLLARS) \
{ \
rcode_raction(act, who.role, - boole_pc[ booleans-1 ]); \
d=dollarsign_check(who.role, boole_pc[ booleans -1]); \
if (d == 1) \
{ \
errors++; \
fprintf(stderr, "\tLine %d: semantical error: ", lines); \
yyerror("Improper use of ``$'' sign."); \
} \
} \
else \
rcode_raction(act, who.role, who.id)
#define MANAGE_AT_OR_TILDE(act,n) \
{ \
int opcode, ro, id; \
if (n == -1) \
{ \
rcode_raction(act, -1, booleans -1); \
query_rcode_array( boole_pc[ booleans -1 ], &opcode, &ro, &id); \
} \
else \
{ \
if (n > booleans) \
{ \
errors++; \
fprintf(stderr, "\tLine %d: semantical error: ", lines); \
yyerror("Too large an index in @- or ~-var."); \
} \
rcode_raction(act, -1, n -1); \
query_rcode_array( boole_pc[ n -1 ], &opcode, &ro, &id); \
} \
\
if ( ! isclause(opcode) ) \
{ \
fprintf(stderr, "\tLine %d: semantical error: ", lines); \
yyerror("Can only use `@' or `~' with clauses (-r, -i, -s, -f, -p, -t)");\
errors++; \
} \
}
char *today(void);
#include "rcode.c"
int read_associations(ASSOC*, char*);
int pushstring(char*);
%}
%union {
float real;
int integer;
ident_t id;
struct { char name[64];
int rcode;
} string;
char quoted_string[64];
int status;
int which;
}
%token <string> ROLE
%token <integer> NUMBER VAR
%token <real> REAL
%token <id> GID NID TID
%token IF ELSE ELIF FI THEN
%token DEF DA PHASE NPROCS
%token KILL RESTART START
%token WARN ON ACTION ERROR ANY
%token CALL
%token MIA_TIMEOUT MIA_TIMEOUT_B
%token TAIA_TIMEOUT TAIA_TIMEOUT_B
%token ALIVE_TIMEOUT ALIVE_TIMEOUT_B
%token REQUEST_DB_TIMEOUT REPLY_DB_TIMEOUT
%token TEIF_TIMEOUT MID_TIMEOUT
%token NUMTASKS PAUSE SEND
%token INJECT BFAULT MFAULT NODE COMPONENT AFTER TICKS
%token KEYW_TASK KEYW_TASKID KEYW_NODE KEYW_IS KEYW_ALIAS KEYW_MBOX
%token KEYW_LOGICAL KEYW_ENDLOGICAL
%token WATCHDOG WATCHES HEARTBEATS EVERY
%token REBOOT KEYW_ENDWATCHDOG
%token NVERSION KEYW_VERSION TIMEOUT VOTING
%token MAJORITY ALGORITHM
%token METRIC SUCCESS KEYW_ENDNVERSION
%token THRESHOLD ALPHACOUNT FACTOR KEYW_ENDALPHA
%token WRITE LOG CLOCK CLEAR
%token <integer> LET VAL
%token <integer> EQ NEQ GT GE LT LE
%token <integer> MILLISEC MICROSEC
%token ERRN ERRT ERR ACT
%token REMOVE FROM ERRORLIST
%token ENABLE
%token <which> AT TILDE
%token INCLUDE
%token <quoted_string> STRING OSTRING
%left AND OR
%left NOT
%token <status> KILLED RESTARTED PRESENT
%token <status> ISOLATED FAULTY DEADLOCKED
%token <status> REINTEGRATED FIRED
%type <status> status
%type <id> id
%type <integer> compare
%type <integer> seconds
%type <which> those
%type <integer> fault
%type <integer> expression linexp
/* precedences/associativity */
%left '+' '-'
%left '*' '/'
%left UMINUS
%%
rlstats:
| rlstats rlstat
| error '\n'
{
fprintf(stderr, "\tLine %d: syntax error.\n", lines);
errors++;
/* yyerrok; */
}
;
rlstat: '\n'
| definition '\n'
{
if (rec)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can't define roles in strategy section");
errors++;
}
}
| default_action '\n'
{
printf("\tDefault action is %s\n",
(default_action==KILL)? "killing":"restarting");
}
| number_of_nodes '\n'
| section '\n'
| include '\n'
| timeouts '\n'
| definitions '\n'
| identifiers '\n'
| alphacounts '\n'
| aliases '\n'
| logicals '\n'
| watchdog '\n'
| nversiontask '\n'
| injection '\n'
;
aliases: KEYW_TASK '[' NUMBER ',' NUMBER ']' KEYW_IS KEYW_MBOX '[' NUMBER ',' NUMBER ']' ',' KEYW_ALIAS '[' NUMBER ',' NUMBER ']'
{
task_t t;
int storetaskII(task_t *);
int i, tl, tu, ml, mu, al, au;
tl = $3, tu = $5,
ml = $10, mu = $12;
al = $17, au = $19;
for (i = tl; i <= tu; i++)
{
t.identifier = i;
t.alias = al++;
t.mbox = ml++;
storetaskII(&t);
}
if (ml > mu + 1 || al > au + 1)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("MBOX/Aliases out of range.");
errors++;
}
}
| KEYW_TASK NUMBER KEYW_IS KEYW_MBOX NUMBER ',' KEYW_ALIAS NUMBER
{
task_t t;
int storetaskII(task_t *);
t.identifier = $2;
t.mbox = $5;
t.alias = $8;
storetaskII(&t);
}
;
tasklist: { tasklist_nr = 0; } KEYW_TASK NUMBER tasklist
{
tasklist[tasklist_nr++] = $3;
}
| ',' KEYW_TASK NUMBER tasklist
{
tasklist[tasklist_nr++] = $3;
}
| ',' NUMBER tasklist
{
tasklist[tasklist_nr++] = $2;
}
|
;
logicals: KEYW_LOGICAL NUMBER '=' STRING KEYW_IS tasklist KEYW_ENDLOGICAL
{
int i;
int storelogical(int, int[], int, char*);
/* struct logicalid_t *pl1, *pl2, *pl3; */
storelogical($2, tasklist, tasklist_nr, $4);
/*
for (i=0; i<tasklist_nr; i++)
{
pl1 = malloc(sizeof(struct logicalid_t));
if (pl1 == NULL)
yyerror("malloc");
for (pl3 = pl2 = taskram[tasklist[i]].p_logicalid;
pl2 != NULL;
pl2 = pl2->plid_next;
)
pl3 = pl2;
pl1->plid_next = NULL;
pl1->identifier = $2;
if (pl3)
pl3->plid_next = p1;
else
taskram[tasklist[i]].p_logicalid = p1;
}
*/
}
;
nversiontask: nversion_start nversion_args nversion_end
;
nversion_start: NVERSION KEYW_TASK NUMBER '\n'
{
NVERSTOP.running = 1; /* we're within a nversion task */
NVERSTOP.task = $3;
NVERSTOP.va_num = 0;
NVERSTOP.versmin = 99999;
NVERSTOP.versmax = -1;
}
;
nversion_args:
| nv_version nversion_args
| nv_voting nversion_args
| nv_metric nversion_args
| nv_on_error nversion_args
| nv_on_success nversion_args
;
nv_version: KEYW_VERSION NUMBER KEYW_IS KEYW_TASK NUMBER '\n'
{
int this = NVERSTOP.va_num;
NVERSTOP.va_num++;
if ($2 > NVERSTOP.versmax)
NVERSTOP.versmax = $2;
if ($2 < NVERSTOP.versmin)
NVERSTOP.versmin = $2;
NVERSTOP.va[this].version = $2;
NVERSTOP.va[this].task = $5;
NVERSTOP.va[this].timeout = -1;
}
| KEYW_VERSION NUMBER KEYW_IS KEYW_TASK NUMBER TIMEOUT NUMBER seconds '\n'
{
int this = NVERSTOP.va_num;
NVERSTOP.va_num++;
if ($2 > NVERSTOP.versmax)
NVERSTOP.versmax = $2;
if ($2 < NVERSTOP.versmin)
NVERSTOP.versmin = $2;
NVERSTOP.va[this].version = $2;
NVERSTOP.va[this].task = $5;
NVERSTOP.va[this].timeout = $7;
NVERSTOP.va[this].unit =
($8 == MILLISEC)? 0:1;
}
;
nv_voting: VOTING ALGORITHM KEYW_IS MAJORITY '\n'
{
NVERSTOP.voting = 1; /* majority voting */
}
;
nv_metric: METRIC STRING '\n'
{
NVERSTOP.metric = strdup($2);
}
;
nv_on_error: ON ERROR KEYW_TASK NUMBER '\n'
{
if (NVERSTOP.running)
{
NVERSTOP.error = $4;
}
else
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("bad use of ON ERROR.");
errors++;
}
}
;
nv_on_success: ON SUCCESS KEYW_TASK NUMBER '\n'
{
if (NVERSTOP.running)
{
NVERSTOP.success = $4;
}
else
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("bad use of ON ERROR.");
errors++;
}
}
;
nversion_end: KEYW_ENDNVERSION '\n'
{
NVERSTOP.running = 0;
INCNVERS;
if (BADNVERS)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Too many nversion tasks have been defined.");
errors++;
}
}
;
watchdog: watchdog_start watchdog_args watchdog_end
;
watchdog_args:
| on_error watchdog_args
| heartbeats watchdog_args
| w_alphacount watchdog_args
;
watchdog_start: WATCHDOG KEYW_TASK NUMBER WATCHES KEYW_TASK NUMBER '\n'
{
WATCHTOP.running = 1; /* we're within a watchdog */
WATCHTOP.watching = $3;
WATCHTOP.watched = $6;
}
;
w_alphacount: ALPHACOUNT KEYW_IS THRESHOLD '=' REAL ',' FACTOR '=' REAL KEYW_ENDALPHA '\n'
{
alphas[WATCHTOP.watching].used = 1;
alphas[WATCHTOP.watching].threshold = $5;
alphas[WATCHTOP.watching].k = $9;
}
;
seconds : MILLISEC | MICROSEC
;
heartbeats: HEARTBEATS EVERY NUMBER seconds '\n'
{
if (WATCHTOP.running)
{
WATCHTOP.rate = $3;
WATCHTOP.unit = ($4 == MILLISEC)? 0:1;
}
else
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("bad use of ON ERROR.");
errors++;
}
}
;
on_error: ON ERROR WARN KEYW_TASK NUMBER '\n'
{
if (WATCHTOP.running)
{
WATCHTOP.action = 0;
WATCHTOP.target = $5;
}
else
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("bad use of ON ERROR.");
errors++;
}
}
| ON ERROR REBOOT '\n'
{
if (WATCHTOP.running)
WATCHTOP.action = 1;
else
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("bad use of ON ERROR.");
errors++;
}
}
| ON ERROR RESTART '\n'
{
if (WATCHTOP.running)
WATCHTOP.action = 2;
else
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("bad use of ON ERROR.");
errors++;
}
}
;
watchdog_end: KEYW_ENDWATCHDOG '\n'
{
WATCHTOP.running = 0;
INCWATCH;
if (BADWATCH)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Too many watchdogs have been defined.");
errors++;
}
}
;
alphacounts: ALPHACOUNT NUMBER KEYW_IS THRESHOLD '=' REAL ',' FACTOR '=' REAL KEYW_ENDALPHA
{
alphas[$2].used = 1;
alphas[$2].threshold = $6;
alphas[$2].k = $10;
}
;
identifiers: KEYW_TASK NUMBER '=' STRING KEYW_IS KEYW_NODE NUMBER ',' KEYW_TASKID NUMBER
{
task_t t;
int storetask(task_t *);
t.identifier = $2;
t.name = $4;
t.node = $7;
t.idf = $10;
storetask(&t);
}
|
KEYW_TASK '[' NUMBER ',' NUMBER ']' '=' STRING KEYW_IS KEYW_NODE NUMBER ',' KEYW_TASKID '[' NUMBER ',' NUMBER ']'
{
task_t t;
int storetask(task_t *);
int i, l1, u1, l2, u2;
char name[TASK_MAXNAME];
l1 = $3, u1 = $5,
l2 = $15, u2 = $17;
t.node = $11;
t.name = name;
for (i = l1; i<=u1; i++)
{
t.identifier = i;
t.idf = l2++;
sprintf(name, "%s.%d", $8, i);
storetask(&t);
}
if (l2 > u2 + 1)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("IDF's out of range.");
errors++;
}
}
;
definitions: NUMTASKS NUMBER '=' NUMBER
{
numtask[$2] = $4;
}
;
timeouts: MIA_TIMEOUT '=' NUMBER
{
mia_send_timeout = $3;
}
| TAIA_TIMEOUT '=' NUMBER
{
taia_send_timeout = $3;
}
| ALIVE_TIMEOUT '=' NUMBER
{
imalive_clear_timeout = $3;
}
| MIA_TIMEOUT_B '=' NUMBER
{
mia_recv_timeout = $3;
}
| TAIA_TIMEOUT_B '=' NUMBER
{
taia_recv_timeout = $3;
}
| ALIVE_TIMEOUT_B '=' NUMBER
{
imalive_set_timeout = $3;
}
| TEIF_TIMEOUT '=' NUMBER
{
teif_timeout = $3;
}
| REQUEST_DB_TIMEOUT '=' NUMBER
{
request_db_timeout = $3;
}
| REPLY_DB_TIMEOUT '=' NUMBER
{
reply_db_timeout = $3;
}
| MID_TIMEOUT '=' NUMBER
{
mid_timeout = $3;
}
;
fault: BFAULT
{
return BFAULT;
}
| MFAULT
{
return BFAULT;
}
;
what: NODE | COMPONENT
;
ticks:
| TICKS
;
injection: INJECT fault ON what NUMBER AFTER NUMBER ticks
{
if ($2 == BFAULT)
{
}
else /* MFAULT */
{
}
}
;
definition: DEF list '=' ROLE
{
for (i=0; i<card_list; i++)
{
rcode_set_role((char) list[i], $4.rcode);
}
}
|
DEF interval '=' ROLE
{ int i;
if (rec)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can't define roles in strategy section");
errors++;
}
for (i=list[0]; i<=list[1]; i++)
{
rcode_set_role((char) i, $4.rcode);
}
}
;
list: NUMBER
{
list[card_list++] = $1;
}
|
list ',' NUMBER
{
list[card_list++] = $3;
}
;
interval: NUMBER '-' NUMBER
{
list[card_list++] = $1;
list[card_list++] = $3;
}
;
number_of_nodes: NPROCS '=' NUMBER
{
nprocs = $3;
}
;
default_action: DA '=' KILL
{
if (rec)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can't set default action in strategy section");
errors++;
}
default_action = KILL;
rcode_set_defaction(R_DA_IS_KILL);
}
|
DA '=' RESTART
{
if (rec)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can't set default action in strategy section");
errors++;
}
default_action = RESTART;
rcode_set_defaction(R_DA_IS_RESTART);
}
;
Sepp: '\n' | ';'
;
those : AT | TILDE
;
expr: status id
{
if (debug)
printf("\t\t +expr(pc==%d)\n", pc);
if ($2.role & ID_DOLLAR || $2.role & ID_DOLLARS)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can't use $var in expressions");
errors++;
}
if ($1 == R_PRESENT)
{
if (isstar($2.role) || isnode($2.role))
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can't use -p with *, N, or N*");
errors++;
}
}
if ($1 == R_REINTEGRATED)
{
if (!isnode($2.role))
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("clause `-reintegrated' requires a node as an argument.");
errors++;
}
}
boole_pc[booleans] = rcode_status ($1, $2, booleans) -1;
booleans++;
if (debug)
printf("\t\t -expr(pc==%d)\n", pc);
}
| status those
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can't use @- or ~-vars in expressions");
errors++;
}
| '(' expr ')'
| expr AND expr
{
if (debug)
printf("\t\t +exprAND(pc==%d)\n", pc);
rcode_single_op (R_AND);
if (debug)
printf("\t\t -exprAND(pc==%d)\n", pc);
}
| expr OR expr
{
if (debug)
printf("\t\t +exprOR(pc==%d)\n", pc);
rcode_single_op (R_OR);
if (debug)
printf("\t\t -exprOR(pc==%d)\n", pc);
}
| NOT expr
{
if (debug)
printf("\t\t +exprNOT(pc==%d)\n", pc);
rcode_single_op (R_NOT);
if (debug)
printf("\t\t -exprNOT(pc==%d)\n", pc);
}
| ERRN '(' id ')' compare NUMBER
{
if ($3.role & ID_DOLLAR || $3.role & ID_DOLLARS)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can't use $var in expressions");
errors++;
}
if ($3.role & ID_STAR)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can't use `*' with ERRN");
errors++;
}
/* rcode_err advances pc by 2 units */
boole_pc[booleans] = rcode_errn($3, $5, $6) -2;
booleans++;
}
| ERRT '(' id ')' compare NUMBER
{
if ($3.role & ID_DOLLAR || $3.role & ID_DOLLARS)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can't use $var in expressions");
errors++;
}
if ($3.role & ID_STAR)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can't use `*' with ERRT");
errors++;
}
/* rcode_err advances pc by 2 units */
boole_pc[booleans] = rcode_errt($3, $5, $6) -2;
booleans++;
}
| PHASE '(' id ')' compare NUMBER
{
if ($3.role & ID_DOLLAR || $3.role & ID_DOLLARS)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can't use $var in expressions");
errors++;
}
if ($3.role & ID_STAR)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can't use `*' with PHASE");
errors++;
}
if (! ($3.role & ID_THREAD) )
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can only use PHASE with threads");
errors++;
}
/* rcode_phase advances pc by 2 units */
boole_pc[booleans] = rcode_phase($3, $5, $6) -2;
booleans++;
}
| DEADLOCKED id id
{
if ($2.role & ID_DOLLAR || $2.role & ID_DOLLARS ||
$3.role & ID_DOLLAR || $3.role & ID_DOLLARS)
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can't use $var in expressions");
errors++;
}
if ($2.role & ID_THREAD && $3.role & ID_THREAD)
{
rcode_deadlocked($2.id, $3.id);
}
else
{
fprintf(stderr, "\tLine %d: semantical error: ", lines);
yyerror("Can only use thread identifiers with -d clause.");
errors++;
}
/* should be added here */
}
| VAL '(' VAR ')' compare NUMBER
{
/* rcode_compare_val advances pc by 2 units */
boole_pc[booleans] = rcode_compare_val($3, $5, $6) -2;
booleans++;
}
;
compare: EQ | NEQ | GT | GE | LT | LE
;
include: INCLUDE STRING
{
printf("[ Including file `%s' ...", $2);
printf("%d associations have been stored. ]\n", read_associations(a, $2));
}
;