-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathspl.y
2927 lines (2711 loc) · 81.3 KB
/
spl.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
%{
#include "config.h"
#include "stdio.h"
#include <stdlib.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#include <string.h>
#include "spl_internal.h"
#include "structs.h"
#define yyparse spl_yyparse
#define yylex spl_yylex
#define yyrestart spl_yyrestart
#define yywrap spl_yywrap
#define yyerror spl_yyerror
#define yy_create_buffer spl_yy_create_buffer
#define yy_delete_buffer spl_yy_delete_buffer
#define yy_flush_buffer spl_yy_flush_buffer
#define yy_init_buffer spl_yy_init_buffer
#define yy_load_buffer_state spl_yy_load_buffer_state
#define yy_scan_buffer spl_yy_scan_buffer
#define yy_scan_bytes spl_yy_scan_bytes
#define yy_scan_string spl_yy_scan_string
#define yy_switch_to_buffer spl_yy_switch_to_buffer
#define yychar spl_yychar
#define yyin spl_yyin
#define yyleng spl_yyleng
#define yylval spl_yylval
#define yynerrs spl_yynerrs
#define yyout spl_yyout
#define yytext spl_yytext
#define yyset_out spl_yyset_out
#define yyset_lineno spl_yyset_lineno
#define yyset_in spl_yyset_in
#define yyset_debug spl_yyset_debug
#define yyrealloc spl_yyrealloc
#define yyalloc spl_yyalloc
#define yyfree spl_yyfree
#define yypush_buffer_state spl_yypush_buffer_state
#define yypop_buffer_state spl_yypop_buffer_state
#define yylex_destroy spl_yylex_destroy
#define yyget_out spl_yyget_out
#define yyget_lineno spl_yyget_lineno
#define yyget_in spl_yyget_in
#define yyget_debug spl_yyget_debug
#define yyget_text spl_yyget_text
#define yyget_leng spl_yyget_leng
static char *create_string_from_yytext();
extern int yylex();
extern int yyparse();
static sm_ref yyparse_value;
static int yyerror_count = 1;
extern void yyerror(char *str);
static int parsing_type = 0;
void process_graph( sm_list two);
char *process_expr(sm_ref node, const char *str);
static int parsing_param_spec = 0;
static spl_parse_context yycontext;
static const char *spl_code_string;
%}
%union {
lx_info info;
sm_ref reference;
sm_list list;
char *string;
};
%token <info> ARROW
%token <info> LPAREN
%token <info> RPAREN
%token <info> LCURLY
%token <info> RCURLY
%token <info> COLON
%token <info> LBRACKET
%token <info> RBRACKET
%token <info> DOT
%token <info> STAR
%token <info> AT
%token <info> SLASH
%token <info> MODULUS
%token <info> PLUS
%token <info> MINUS
%token <info> LEQ
%token <info> LT
%token <info> GEQ
%token <info> EQ
%token <info> NEQ
%token <info> LEFT_SHIFT
%token <info> RIGHT_SHIFT
%token <info> ASSIGN
%token <info> MUL_ASSIGN
%token <info> DIV_ASSIGN
%token <info> MOD_ASSIGN
%token <info> ADD_ASSIGN
%token <info> SUB_ASSIGN
%token <info> LEFT_ASSIGN
%token <info> RIGHT_ASSIGN
%token <info> AND_ASSIGN
%token <info> XOR_ASSIGN
%token <info> OR_ASSIGN
%token <info> LOG_OR
%token <info> LOG_AND
%token <info> ARITH_OR
%token <info> ARITH_AND
%token <info> ARITH_XOR
%token <info> INC_OP
%token <info> DEC_OP
%token <info> BANG
%token <info> SEMI
%token <info> IF
%token <info> ELSE
%token <info> FOR
%token <info> WHILE
%token <info> CHAR
%token <info> SHORT
%token <info> INT
%token <info> LONG
%token <info> UNSIGNED
%token <info> SIGNED
%token <info> FLOAT
%token <info> DOUBLE
%token <info> VOID
%token <info> STRING
%token <info> STATIC
%token <info> STRUCT
%token <info> UNION
%token <info> CONST
%token <info> SIZEOF
%token <info> TYPEDEF
%token <info> RETURN_TOKEN
%token <info> PRINT
%token <info> COMMA
%token <info> DOTDOTDOT
%token <info> integer_constant
%token <info> string_constant
%token <info> floating_constant
%token <info> identifier_ref
%token <info> type_id
%token <info> ANY
%token <info> AS
%token <info> ATTRIBUTE
%token <info> BLOB
%token <info> BOOLEAN
%token <info> BREAK
%token <info> COLLECTION
%token <info> COLON_COLON
%token <info> COMPLEX
%token <info> COMPLEX32
%token <info> COMPLEX64
%token <info> COMPOSITE
%token <info> CONFIG
%token <info> CONTINUE
%token <info> DECIMAL
%token <info> DECIMAL128
%token <info> DECIMAL32
%token <info> DECIMAL64
%token <info> DOT_ARITH_AND
%token <info> DOT_ARITH_OR
%token <info> DOT_ARITH_XOR
%token <info> DOT_EQ
%token <info> DOT_GEQ
%token <info> DOT_GT
%token <info> DOT_LEFT_SHIFT
%token <info> DOT_LEQ
%token <info> DOT_LT
%token <info> DOT_MINUS
%token <info> DOT_MODULUS
%token <info> DOT_NEQ
%token <info> DOT_PLUS
%token <info> DOT_RIGHT_SHIFT
%token <info> DOT_SLASH
%token <info> DOT_STAR
%token <info> ENUM
%token <info> EXPRESSION
%token <info> FALSE
%token <info> FLOAT32
%token <info> FLOAT64
%token <info> FLOATINGPOINT
%token <info> FUNCTION
%token <info> GRAPH
%token <info> IN
%token <info> INPUT
%token <info> INT128
%token <info> INT16
%token <info> INT32
%token <info> INT64
%token <info> INT8
%token <info> INTEGRAL
%token <info> LIST
%token <info> LOGIC
%token <info> MAP
%token <info> MUTABLE
%token <info> NAMESPACE
%token <info> NUMERIC
%token <info> ONPUNCT
%token <info> ONTUPLE
%token <info> OPERATOR
%token <info> ORDERED
%token <info> OUTPUT
%token <info> PARAM
%token <info> PRIMITIVE
%token <info> PUBLIC
%token <info> QUESTION
%token <info> SET
%token <info> STATE
%token <info> STATEFUL
%token <info> STREAM
%token <info> STRING8
%token <info> STRING16
%token <info> TILDE
%token <info> TIMESTAMP
%token <info> TRUE
%token <info> TUPLE
%token <info> TYPE
%token <info> UINT128
%token <info> UINT16
%token <info> UINT32
%token <info> UINT64
%token <info> UINT8
%token <info> USE
%token <info> WINDOW
%type <reference> primitiveLiteral;
%type <reference> literal;
%type <reference> primitiveType;
%type <reference> type;
%type <reference> streamspec;
%type <reference> as_clause;
%type <reference> attributeDecl;
%type <reference> expr;
%type <reference> infixOp;
%type <reference> mappedOp;
%type <reference> infixExpr;
%type <reference> postfixExpr;
%type <reference> prefixOp;
%type <reference> prefixExpr;
%type <reference> compositeHead;
%type <reference> opOutput;
%type <reference> opInvokeHead;
%type <reference> opInvokeWindow;
%type <reference> opInvokeActual;
%type <reference> opActual;
%type <reference> opInvokeBody;
%type <reference> opInvoke;
%type <reference> invoke_logic_opt;
%type <reference> invoke_config_opt;
%type <reference> opInvokeOutput;
%type <reference> assign_expr;
%type <list> opInputs;
%type <list> opOutputs;
%type <list> portInputs;
%type <list> opInvokeActual_list;
%type <list> opInvokeOutput_list;
%type <list> opInvokeWindow_list;
%type <list> expr_list_comma;
%type <list> opInput_list;
%type <list> attributeDecl_list;
%type <list> invoke_actual_opt;
%type <list> invoke_window_opt;
%type <list> tupleBody;
%type <list> tupleType;
%type <list> compositeType;
%type <list> assign_expr_list;
%type <list> streamType;
%type <list> opInvoke_list;
%type <list> id_list_dot;
%type <list> invoke_output_opt;
%%
start :
compilationUnit {
printf("start?\n");
}
;
compilationUnit:
namespace useDirective_list comp_or_func_list {
printf("compilationUnit?\n");
}
;
comp_or_func_list
:comp_or_func {
printf("comp_or_func_list?\n");
}
|comp_or_func_list comp_or_func {
printf("comp_or_func_list?\n");
}
;
comp_or_func
:compositeDef {
printf("comp_or_func?\n");
}
|functionDef {
printf("comp_or_func?\n");
}
;
namespace:
NAMESPACE id_list_dot SEMI {
printf("namespace?\n");
}
;
id_list_dot
:identifier_ref {
$$ = malloc(sizeof(struct list_struct));
sm_ref atmp = spl_new_identifier();
atmp->node.identifier.id = $1.string;
$$->node = atmp;
$$->next = NULL;
}
|id_list_dot DOT identifier_ref {
sm_list tmp = $1;
while (tmp->next != NULL) {
tmp = tmp->next;
}
sm_ref tmp2 = spl_new_identifier();
tmp2->node.identifier.id = $3.string;
tmp->next = malloc(sizeof(struct list_struct));
tmp->next->node = tmp2;
tmp->next->next = NULL;
$$ = $1;
}
;
id_list_comma
:identifier_ref {
printf("id_list_comma?\n");
}
|id_list_comma COMMA identifier_ref {
printf("id_list_comma?\n");
}
;
useDirective_list
: /* empty */
|useDirective_list useDirective {
printf("useDirective_list?\n");
}
;
useDirective
: USE id_list_dot COLON_COLON STAR SEMI{
printf("useDirective?\n");
}
| USE id_list_dot COLON_COLON identifier_ref SEMI{
printf("useDirective?\n");
}
;
compositeDef:
compositeHead compositeBody {
printf("compositeDef?\n");
}
;
compositeHead
: public_opt COMPOSITE identifier_ref {
$$ = spl_new_identifier();
$$->node.identifier.id = $3.string;
$$->node.identifier.lx_srcpos = $3.lx_srcpos;
}
| public_opt COMPOSITE identifier_ref LPAREN compositeInOutList RPAREN {
printf("compositeHead?\n");
}
;
public_opt:
/*empty*/
| PUBLIC {
printf("public opt?\n");
}
;
compositeInOutList:
compositeInOut {
printf("compositeInOutList?\n");
}
| compositeInOutList SEMI compositeInOut {
printf("compositeInOutList?\n");
}
;
compositeInOut:
INPUT streamlist {
printf("compositeInOut?\n");
}
| OUTPUT streamlist {
printf("compositeInOut?\n");
}
;
streamlist:
streamspec {
printf("streamlist?\n");
}
|streamlist COMMA streamspec {
printf("streamlist?\n");
}
;
streamspec:
identifier_ref {
$$ = spl_new_identifier();
$$->node.identifier.id = $1.string;
$$->node.identifier.lx_srcpos = $1.lx_srcpos;
}
| streamType identifier_ref {
$$ = spl_new_identifier();
$$->node.identifier.id = $2.string;
$$->node.identifier.lx_srcpos = $2.lx_srcpos;
}
;
streamType:
STREAM LT tupleBody '>' {
$$ = $3;
}
;
compositeBody:
LCURLY param_opt type_opt graph_opt config_opt RCURLY {
printf("compositeBody?\n");
}
;
param_opt:
/*empty*/
| PARAM compositeFormal_list{
printf("param_opt?\n");
}
;
compositeFormal_list:
compositeFormal {
printf("compositeFormal_list?\n");
}
| compositeFormal_list compositeFormal {
printf("compositeFormal_list?\n");
}
type_opt:
/*empty*/
| TYPEDEF compositeTypeDef_list {
printf("type_opt?\n");
}
;
compositeTypeDef_list:
compositeTypeDef {
printf("compositeTypeDef_list?\n");
}
| compositeTypeDef_list compositeTypeDef {
printf("compositeTypeDef_list?\n");
}
;
graph_opt:
/*empty*/
| GRAPH opInvoke_list {
printf("printing program to main.c\n");
process_graph($2);
}
;
opInvoke_list:
opInvoke {
$$ = malloc(sizeof(struct list_struct));
$$->node = $1;
$$->next = NULL;
}
| opInvoke_list opInvoke {
sm_list tmp = $1;
while (tmp->next != NULL) {
tmp = tmp->next;
}
tmp->next = malloc(sizeof(struct list_struct));
tmp->next->node = $2;
tmp->next->next = NULL;
$$ = $1;
}
;
config_opt:
/*empty*/
| CONFIG configuration_list{
printf("config_opt?\n");
}
;
configuration_list:
configuration {
printf("configuration_list?\n");
}
| configuration_list configuration {
printf("configuration_list?\n");
}
;
compositeFormal:
ATTRIBUTE identifier_ref SEMI {
printf("compositeFormal?\n");
}
| EXPRESSION typeArgs_list identifier_ref SEMI /* Operator parameter modes */ {
printf("compositeFormal?\n");
}
| FUNCTION identifier_ref SEMI {
printf("compositeFormal?\n");
}
| OPERATOR identifier_ref SEMI {
printf("compositeFormal?\n");
}
| TYPE identifier_ref SEMI {
printf("compositeFormal?\n");
}
| ATTRIBUTE identifier_ref COLON opActual SEMI {
printf("compositeFormal?\n");
}
| EXPRESSION typeArgs_list identifier_ref COLON opActual SEMI /* Operator parameter modes */ {
printf("compositeFormal?\n");
}
| FUNCTION identifier_ref COLON opActual SEMI {
printf("compositeFormal?\n");
}
| OPERATOR identifier_ref COLON opActual SEMI {
printf("compositeFormal?\n");
}
| TYPE identifier_ref COLON opActual SEMI {
printf("compositeFormal?\n");
}
;
opInvokeActual:
identifier_ref COLON opActual SEMI {
$$ = spl_new_field();
$$->node.field.name = $1.string;
$$->node.field.sm_complex_type = $3;
}
;
opActual:
type {
printf("opActual?\n");
}
| expr_list_comma {
$$ = spl_new_field();
$$->node.field.name = "opActual";
$$->node.field.type_spec = $1;
}
;
expr_list_comma:
expr {
$$ = malloc(sizeof(struct list_struct));
$$->node = $1;
$$->next = NULL;
}
| expr_list_comma COMMA expr {
sm_list tmp = $1;
while (tmp->next != NULL) {
tmp = tmp->next;
}
tmp->next = malloc(sizeof(struct list_struct));
tmp->next->node = $3;
tmp->next->next = NULL;
$$ = $1;
}
;
/* expr_list_comma is config_clause_list */
configuration:
identifier_ref COLON expr_list_comma SEMI {
printf("configuration?\n");
}
;
opInvoke:
opInvokeHead opInvokeBody {
$$= spl_new_assignment_expression();
$$->node.assignment_expression.left=$1;
$$->node.assignment_expression.right=$2;
}
;
opInvokeHead:
opOutputs ASSIGN identifier_ref opInputs {
$$= spl_new_assignment_expression();
sm_ref tmp2= spl_new_field();
tmp2->node.field.name = "opInvokeHead";
tmp2->node.field.type_spec = $1;
$$->node.assignment_expression.left = tmp2;
sm_ref tmp= spl_new_field();
tmp->node.field.name = $3.string;
tmp->node.field.type_spec = $4;
$$->node.assignment_expression.right = tmp;
}
;
as_clause:
/*empty*/{
//do nothing
}
| AS identifier_ref {
$$ = spl_new_field();
$$->node.field.name = $2.string;
}
;
opOutputs:
opOutput {
$$ = malloc(sizeof(struct list_struct));
$$->node = $1;
$$->next = NULL;
}
| LPAREN RPAREN as_clause {
$$ = malloc(sizeof(struct list_struct));
$$->node = $3;
$$->next = NULL;
}
| LPAREN opOutput_list RPAREN as_clause {
printf("opOutputs?\n");
}
;
opOutput_list:
opOutput {
printf("opOutput_list?\n");
}
| opOutput_list SEMI opOutput {
printf("opOutput_list?\n");
}
;
opOutput:
streamType identifier_ref as_clause {
$$ = spl_new_field();
$$->node.field.type_spec = $1;
$$->node.field.name = $2.string;
}
;
opInputs:
LPAREN RPAREN {
$$ = NULL;
}
| LPAREN opInput_list RPAREN {
$$= $2;
}
;
opInput_list:
portInputs {
$$ = malloc(sizeof(struct list_struct));
sm_ref temp = spl_new_field();
temp->node.field.type_spec = $1;
temp->node.field.name = "input";
$$->node = temp;
$$->next = NULL;
}
| opInput_list SEMI portInputs {
sm_list tmp = $1;
while (tmp->next != NULL) {
tmp = tmp->next;
}
tmp->next = malloc(sizeof(struct list_struct));
sm_ref temp = spl_new_field();
temp->node.field.type_spec = $3;
temp->node.field.name = "input";
tmp->next->node = temp;
tmp->next->next = NULL;
$$ = $1;
}
;
portInputs:
id_list_dot as_clause {
$$=$1;
}
| streamType id_list_dot as_clause {
printf("portInputs?\n");
}
;
opInvokeBody:
LCURLY invoke_logic_opt invoke_window_opt invoke_actual_opt invoke_output_opt invoke_config_opt RCURLY {
sm_list temp_list = NULL;
if($2!=NULL){
printf("two\n");
fflush(stdout);
temp_list = malloc(sizeof(struct list_struct));
temp_list->node = $2;
temp_list->next = NULL;
}
if($3!=NULL){
sm_ref temp3 = spl_new_field();
temp3->node.field.type_spec = $3;
temp3->node.field.name = "window";
if(temp_list){
temp_list->next = malloc(sizeof(struct list_struct));
temp_list->next->node = temp3;
temp_list->next->next = NULL;
} else {
temp_list = malloc(sizeof(struct list_struct));
temp_list->node = temp3;
temp_list->next = NULL;
}
}
if($4!=NULL){
sm_ref temp3 = spl_new_field();
temp3->node.field.type_spec = $4;
temp3->node.field.name = "invoke_actual";
if(temp_list){
sm_list atemp=temp_list;
while(atemp->next){
atemp=atemp->next;
}
atemp->next = malloc(sizeof(struct list_struct));
atemp->next->node = temp3;
atemp->next->next = NULL;
} else {
temp_list = malloc(sizeof(struct list_struct));
temp_list->node = temp3;
temp_list->next = NULL;
}
}
if($5!=NULL){
sm_ref temp4 = spl_new_field();
temp4->node.field.type_spec = $5;
temp4->node.field.name = "invoke_output";
if(temp_list){
sm_list atemp=temp_list;
while(atemp->next){
atemp=atemp->next;
}
atemp->next = malloc(sizeof(struct list_struct));
atemp->next->node = temp4;
atemp->next->next = NULL;
} else {
temp_list = malloc(sizeof(struct list_struct));
temp_list->node = temp4;
temp_list->next = NULL;
}
}
//6th param ignored
sm_ref temp = spl_new_field();
temp->node.field.type_spec = temp_list;
temp->node.field.name = "invoke body";
$$=temp;
}
;
invoke_logic_opt:
/* empty */{
$$=NULL;
}
| LOGIC opInvokeLogic_list {
printf("invoke_logic_opt?\n");
}
;
invoke_window_opt:
/* empty */{
$$=NULL;
}
| WINDOW opInvokeWindow_list {
$$=$2;
}
;
invoke_actual_opt:
/* empty */{
$$=NULL;
}
| PARAM opInvokeActual_list {
$$=$2;
}
;
invoke_output_opt:
/* empty */{
$$=NULL;
}
| OUTPUT opInvokeOutput_list {
$$=$2;
}
;
invoke_config_opt:
/* empty */
| CONFIG configuration_list {
printf("invoke_config_opt?\n");
}
;
opInvokeLogic_list:
opInvokeLogic {
printf("opInvokeLogic_list?\n");
}
| opInvokeLogic_list opInvokeLogic {
printf("opInvokeLogic_list?\n");
}
;
opInvokeWindow_list:
opInvokeWindow {
$$ = malloc(sizeof(struct list_struct));
$$->node = $1;
$$->next = NULL;
}
| opInvokeWindow_list opInvokeWindow {
printf("opInvokeWindow_list?\n");
}
;
opInvokeActual_list:
opInvokeActual {
$$ = malloc(sizeof(struct list_struct));
$$->node = $1;
$$->next = NULL;
}
| opInvokeActual_list opInvokeActual {
sm_list tmp = $1;
while (tmp->next != NULL) {
tmp = tmp->next;
}
tmp->next = malloc(sizeof(struct list_struct));
tmp->next->node = $2;
tmp->next->next = NULL;
$$ = $1;
}
;
opInvokeOutput_list:
opInvokeOutput {
$$ = malloc(sizeof(struct list_struct));
$$->node = $1;
$$->next = NULL;
}
| opInvokeOutput_list opInvokeOutput {
sm_list tmp = $1;
while (tmp->next != NULL) {
tmp = tmp->next;
}
tmp->next = malloc(sizeof(struct list_struct));
tmp->next->node = $2;
tmp->next->next = NULL;
$$ = $1;
}
;
opInvokeLogic:
opInvokeCode {
printf("opInvokeLogic?\n");
}
| opInvokeState {
printf("opInvokeLogic?\n");
}
;
opInvokeCode:
ONTUPLE identifier_ref COLON stmt {
printf("opInvokeCode?\n");
}
| ONPUNCT identifier_ref COLON stmt {
printf("opInvokeCode?\n");
}
;
opInvokeState:
STATE COLON varDef {
printf("opInvokeState?\n");
}
| STATE COLON LCURLY varDef_list RCURLY {
printf("opInvokeState?\n");
}
;
varDef_list:
varDef {
printf("varDef_list?\n");
}
| varDef_list varDef {
printf("varDef_list?\n");
}
;
opInvokeWindow:
identifier_ref COLON expr_list_comma SEMI {
$$ = spl_new_field();
$$->node.field.name=$1.string;
$$->node.field.type_spec=$3;
}
;
opInvokeOutput:
identifier_ref COLON assign_expr_list SEMI {
$$=spl_new_field();
$$->node.field.name=$1.string;
$$->node.field.type_spec=$3;
}
;
assign_expr:
identifier_ref ASSIGN expr {
sm_ref tmp = spl_new_assignment_expression();
tmp->node.assignment_expression.right= $3;
sm_ref id = spl_new_identifier();
id->node.identifier.id=$1.string;
tmp->node.assignment_expression.left= id;
$$=tmp;
}
;
assign_expr_list:
assign_expr {
$$ = malloc(sizeof(struct list_struct));
$$->node = $1;
$$->next = NULL;
}
| assign_expr_list COMMA assign_expr {
sm_list tmp = $1;
while (tmp->next != NULL) {
tmp = tmp->next;
}
tmp->next = malloc(sizeof(struct list_struct));
tmp->next->node = $3;
tmp->next->next = NULL;
$$ = $1;
}
;
functionDef:
functionHead blockStmt {
printf("functionDef?\n");
}
;
functionHead:
functionModifier_list type identifier_ref LPAREN functionFormal_list RPAREN {
printf("functionHead?\n");
}
;
functionModifier_list:
/* empty */
| functionModifier_list PUBLIC {
printf("functionModifier_list?\n");
}
| functionModifier_list STATEFUL {
printf("functionModifier_list?\n");
}
;
functionFormal_list:
functionFormal {
printf("functionFormal_list?\n");
}
| functionFormal_list COMMA functionFormal {
printf("functionFormal_list?\n");
}
;
functionFormal:
mutable_opt type identifier_ref {
printf("functionFormal?\n");
}
;
/* !!!!!!!!! this is missing from the grammar on the web !!!!!!!!!!!!!!!!!!!!!!!*/
stmt:
varDef {
printf("stmt?\n");
}
| blockStmt {
printf("stmt?\n");
}
| exprStmt {
printf("stmt?\n");
}
| ifStmt {
printf("stmt?\n");
}
| forStmt {
printf("stmt?\n");
}
| whileStmt {
printf("stmt?\n");
}
| breakStmt {
printf("stmt?\n");
}
| continueStmt {
printf("stmt?\n");
}