File: catsparse_syntax.sats

package info (click to toggle)
ats2-lang 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 40,064 kB
  • sloc: ansic: 389,637; makefile: 7,123; lisp: 812; sh: 657; php: 573; python: 387; perl: 365
file content (783 lines) | stat: -rw-r--r-- 14,323 bytes parent folder | download | duplicates (4)
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
(* ****** ****** *)
//
// CATS-parsemit
//
(* ****** ****** *)
//
// HX-2014-07-02: start
//
(* ****** ****** *)
//
#define
ATS_PACKNAME"CATS-PARSEMIT"
//
(* ****** ****** *)

#staload "./catsparse.sats" // opened

(* ****** ****** *)
//
castfn
synent_encode {a:type} (x: a): synent
castfn
synent_decode {a:type} (x: synent): (a)
//
(* ****** ****** *)
//
fun
synent_decode2{a:type} (x: &synent >> _?): a
//
(* ****** ****** *)
//
fun synent_null {a:type} (): a // = null
//
fun synent_is_null {a:type} (x: a):<> bool
fun synent_isnot_null {a:type} (x: a):<> bool
//
(* ****** ****** *)
//
fun
i0dex_make_sym (loc: loc_t, sym: symbol): i0de
fun
i0dex_make_string (loc: loc_t, name: string): i0de
//
(* ****** ****** *)

fun s0exp_ide (loc: loc_t, id: i0de): s0exp
fun s0exp_list (loc: loc_t, s0es: s0explst): s0exp
fun s0exp_appid (id: i0de, s0e: s0exp): s0exp

(* ****** ****** *)
//
// HX: for constructing primvals
//
(* ****** ****** *)
//
fun d0exp_ide (id: i0de): d0exp
//
fun d0exp_list (loc: loc_t, d0es: d0explst): d0exp
//
fun d0exp_appid (id: i0de, d0e_arg: d0exp): d0exp
fun d0exp_appexp (d0e_fun: d0exp, d0e_arg: d0exp): d0exp
//
(* ****** ****** *)
//
fun
ATSPMVint_make
(
  tok_kwd: token, tok: i0nt, tok_end: token
) : d0exp // end-of-fun
fun
ATSPMVintrep_make
(
  tok_kwd: token, tok: i0nt, tok_end: token
) : d0exp // end-of-fun
//
(* ****** ****** *)
//
fun
ATSPMVbool_make
(
  tok_kwd: token, tfv: bool, tok_end: token
) : d0exp // end-of-fun
//
(* ****** ****** *)
//
fun
ATSPMVfloat_make
(
  tok_kwd: token, tok: f0loat, tok_end: token
) : d0exp // end-of-fun
//
(* ****** ****** *)
//
fun
ATSPMVstring_make
(
  tok_kwd: token, tok: s0tring, tok_end: token
) : d0exp // end-of-fun
//
(* ****** ****** *)
//
fun
ATSPMVi0nt_make
(
  tok_kwd: token, tok: i0nt, tok_end: token
) : d0exp // end-of-fun
//
fun
ATSPMVf0loat_make
(
  tok_kwd: token, tok: f0loat, tok_end: token
) : d0exp // end-of-fun
//
(* ****** ****** *)
//
fun
ATSPMVempty_make
  (tok_kwd: token, tok_end: token): d0exp
//
fun
ATSPMVextval_make
  (tok_kwd: token, toks: tokenlst, tok_end: token): d0exp
//
(* ****** ****** *)
//
fun
ATSPMVrefarg0_make
(
  tok_kwd: token, d0e: d0exp, tok_end: token
) : d0exp // end-of-fun
//
fun
ATSPMVrefarg1_make
(
  tok_kwd: token, d0e: d0exp, tok_end: token
) : d0exp // end-of-fun
//
(* ****** ****** *)

fun
ATSPMVfunlab_make
(
  tok_kwd: token, flab: label, tok_end: token
) : d0exp // end-of-fun

(* ****** ****** *)

fun
ATSPMVcfunlab_make
(
  tok_kwd: token
, knd: signed, flab: label, arg: d0exp, tok_end: token
) : d0exp // end-of-fun

(* ****** ****** *)
//
fun
ATSPMVcastfn_make
(
  tok_kwd: token
, fid: i0de, s0e_res: s0exp, arg: d0exp, tok_end: token
) : d0exp // end-of-fun
//
(* ****** ****** *)
//
fun
ATSCSTSPmyloc_make
(
  tok_kwd: token, tok: s0tring, tok_end: token
) : d0exp // end-of-fun
//
(* ****** ****** *)
//
fun
ATSCKiseqz_make
  (tok_kwd: token, d0e: d0exp, tok_end: token): d0exp
fun
ATSCKisneqz_make
  (tok_kwd: token, d0e: d0exp, tok_end: token): d0exp
//
fun
ATSCKptriscons_make
  (tok_kwd: token, d0e: d0exp, tok_end: token): d0exp
fun
ATSCKptrisnull_make
  (tok_kwd: token, d0e: d0exp, tok_end: token): d0exp
//
(* ****** ****** *)
//
fun
ATSCKpat_int_make
(
  tok_kwd: token, d0e: d0exp, int: d0exp, tok_end: token
) : d0exp // end-of-fun
//
fun
ATSCKpat_bool_make
(
  tok_kwd: token, d0e: d0exp, bool: d0exp, tok_end: token
) : d0exp // end-of-fun
//
fun
ATSCKpat_string_make
(
  tok_kwd: token, d0e: d0exp, bool: d0exp, tok_end: token
) : d0exp // end-of-fun
//
fun
ATSCKpat_con0_make
(
  tok_kwd: token, d0e: d0exp, tag: signed, tok_end: token
) : d0exp // end-of-fun
//
fun
ATSCKpat_con1_make
(
  tok_kwd: token, d0e: d0exp, tag: signed, tok_end: token
) : d0exp // end-of-fun
//
(* ****** ****** *)
//
fun
ATSSELcon_make
(
  tok_kwd: token
, d0e: d0exp, s0e: s0exp, lab: label
, tok_end: token
) : d0exp // end of [ATSSELcon_make]
//
fun
ATSSELrecsin_make
(
  tok_kwd: token
, d0e: d0exp, s0e: s0exp, lab: label
, tok_end: token
) : d0exp // end of [ATSSELrecsin_make]
//
fun
ATSSELboxrec_make
(
  tok_kwd: token
, d0e: d0exp, s0e: s0exp, lab: label
, tok_end: token
) : d0exp // end of [ATSSELboxrec_make]
//
fun
ATSSELfltrec_make
(
  tok_kwd: token
, d0e: d0exp, s0e: s0exp, lab: label
, tok_end: token
) : d0exp // end of [ATSSELfltrec_make]
//
(* ****** ****** *)

fun
ATSextfcall_make
(
  tok_kwd: token
, d0e_fun: i0de, d0e_arg: d0exp
, tok_end: token
) : d0exp // end of [ATSextfcall_make]

(* ****** ****** *)

fun
ATSextmcall_make
(
  tok_kwd: token
, d0e_obj: d0exp
, d0e_mtd: d0exp, d0e_arg: d0exp
, tok_end: token
) : d0exp // end of [ATSextmcall_make]

(* ****** ****** *)

fun
ATSfunclo_fun_make
(
  tok_kwd: token
, d0e: d0exp, arg: s0exp, res: s0exp
, tok_end: token
, d0argopt: d0expopt
) : d0exp // end of [ATSfunclo_fun_make]

(* ****** ****** *)

fun
ATSfunclo_clo_make
(
  tok_kwd: token
, d0e: d0exp, arg: s0exp, res: s0exp
, tok_end: token
, d0argopt: d0expopt
) : d0exp // end of [ATSfunclo_clo_make]

(* ****** ****** *)
//
fun tyfld_make (s0e: s0exp, id: i0de): tyfld
//
fun tyrec_make
  (tok_beg: token, xs: tyfldlst, tok_end: token): tyrec
//
(* ****** ****** *)
//
fun
fkind_extern (tok1: token, tok2: token): fkind
fun
fkind_static (tok1: token, tok2: token): fkind
//
(* ****** ****** *)
//
fun f0arg_none (s0e: s0exp): f0arg
fun f0arg_some (s0e: s0exp, id: i0de): f0arg
//
fun
f0marg_make
  (tok_beg: token, f0as: f0arglst, tok_end: token): f0marg
//
(* ****** ****** *)
//
fun f0head_get_f0arglst (fhd: f0head): f0arglst
//
fun
f0head_make (res: s0exp, id: i0de, marg: f0marg): f0head
//
(* ****** ****** *)
//
fun tmpvar_is_sta (tmp: symbol): bool
fun tmpvar_is_arg (tmp: symbol): bool
fun tmpvar_is_apy (tmp: symbol): bool
fun tmpvar_is_env (tmp: symbol): bool
fun tmpvar_is_tmp (tmp: symbol): bool
fun tmpvar_is_tmpret (tmp: symbol): bool
//
(* ****** ****** *)
//
fun tmpvar_is_axrg (tmp: symbol): bool
fun tmpvar_is_axpy (tmp: symbol): bool
//
fun tmpvar_is_local (tmp: symbol): bool
//
(* ****** ****** *)
//
fun
tmpdec_make_none
(
  tok_kwd: token, tmp: i0de, tok_end: token
) : tmpdec // end-of-fun
fun
tmpdec_make_some
(
  tok_kwd: token, tmp: i0de, s0e: s0exp, tok_end: token
) : tmpdec // end-of-fun
//
(* ****** ****** *)
//
// HX: for constructing instructions
//
(* ****** ****** *)
//
fun ATSif_make
(
  tok_if: token
, _test: d0exp, _then: instr, _else: instropt
) : instr // end of [ATSif_make]
//
fun ATSthen_make
(
  tok_then: token, inss: instrlst, tok_end: token
) : instr // end of [ATSthen_make]
//
fun ATSelse_make
(
  tok_else: token, inss: instrlst, tok_end: token
) : instr // end of [ATSelse_make]
//
(* ****** ****** *)
//
fun ATSifthen_make
(
  tok_ifthen: token
, _test: d0exp, _then: instrlst, tok_end: token
) : instr // end-of-fun
//
fun ATSifnthen_make
(
  tok_ifnthen: token
, _test: d0exp, _then: instrlst, tok_end: token
) : instr // end-of-fun
//
(* ****** ****** *)

fun
ATSbranchseq_make
(
  tok_kwd: token, inss: instrlst, tok_end: token
) : instr // end-of-function

(* ****** ****** *)

fun
caseofseq_get_tmplablst (x: instr): labelist

(* ****** ****** *)

fun
ATScaseofseq_make
(
  tok_kwd: token, inss: instrlst, tok_end: token
) : instr // end-of-function

(* ****** ****** *)

fun
funbodyseq_get_funlab (ins0: instr): label

(* ****** ****** *)

fun
ATSfunbodyseq_make
(
  tok_kwd: token, inss: instrlst, tok_end: token
) : instr // end-of-function

(* ****** ****** *)
//
fun
ATSreturn_make
  (tok_kwd: token, tmp: i0de, tok_end: token): instr
fun
ATSreturn_void_make
  (tok_kwd: token, tmp: i0de, tok_end: token): instr
//
(* ****** ****** *)
//
fun
instrlst_skip_linepragma (inss: instrlst): instrlst
//
(* ****** ****** *)
//
fun
ATSlinepragma_make
  (tok_kwd: token, line: token, file: token): instr
//
(* ****** ****** *)
//
fun
ATSINSlab_make
  (tok_kwd: token, tmp: i0de, tok_end: token): instr
//
fun
ATSINSgoto_make
  (tok_kwd: token, tmp: i0de, tok_end: token): instr
//
(* ****** ****** *)
//
fun
ATSINSflab_make
  (tok_kwd: token, tmp: i0de, tok_end: token): instr
//
fun
ATSINSfgoto_make
  (tok_kwd: token, tmp: i0de, tok_end: token): instr
//
(* ****** ****** *)
//
fun
ATSINSfreeclo_make
  (tok_kwd: token, d0e: d0exp, tok_end: token): instr
//
fun
ATSINSfreecon_make
  (tok_kwd: token, d0e: d0exp, tok_end: token): instr
//
(* ****** ****** *)
//
fun
ATSINSmove_make
(
  tok_kwd: token, tmp: i0de, d0e: d0exp, tok_end: token
) : instr // end of [ATSINSmove_make]
//
fun
ATSINSmove_void_make
(
  tok_kwd: token, tmp: i0de, d0e: d0exp, tok_end: token
) : instr // end of [ATSINSmove_void_make]
//
(* ****** ****** *)
//
fun
ATSINSmove_nil_make
(
  tok_kwd: token, tmp: i0de, tok_end: token
) : instr // end of [ATSINSmove_nil_make]
//
fun
ATSINSmove_con0_make
(
  tok_kwd: token, tmp: i0de, tag: token, tok_end: token
) : instr // end-of-function
//
(* ****** ****** *)
//
fun
ATSINSmove_con1_make
(
  tok_kwd: token, inss: instrlst, tok_end: token
) : instr // end-of-function
//
fun
ATSINSmove_con1_new_make
(
  tok_kwd: token, tmp: i0de, s0e: s0exp, tok_end: token
) : instr // end-of-function
//
fun
ATSINSstore_con1_tag_make
(
  tok_kwd: token, tmp: i0de, tag: token, tok_end: token
) : instr // end-of-function
//
fun
ATSINSstore_con1_ofs_make
(
  tok_kwd: token
, tmp: i0de, s0e: s0exp, lab: label, d0e: d0exp
, tok_end: token
) : instr // end-of-function
//
(* ****** ****** *)
//
fun
ATSINSmove_boxrec_make
(
  tok_kwd: token, inss: instrlst, tok_end: token
) : instr // end-of-function
//
fun
ATSINSmove_boxrec_new_make
(
  tok_kwd: token, tmp: i0de, s0e: s0exp, tok_end: token
) : instr // end-of-function
//
fun
ATSINSstore_boxrec_ofs_make
(
  tok_kwd: token
, tmp: i0de, s0e: s0exp, lab: label, d0e: d0exp
, tok_end: token
) : instr // end-of-function
//
(* ****** ****** *)
//
fun
ATSINSmove_fltrec_make
(
  tok_kwd: token, inss: instrlst, tok_end: token
) : instr // end-of-function
//
fun
ATSINSstore_fltrec_ofs_make
(
  tok_kwd: token
, tmp: i0de, s0e: s0exp, lab: label, d0e: d0exp
, tok_end: token
) : instr // end-of-function
//
(* ****** ****** *)
//
fun
ATSINSmove_delay_make
(
  tok_kwd: token
, tmp: i0de, s0e_res: s0exp, d0e: d0exp (*thunk*)
, tok_end: token
) : instr // end-of-function
//
fun
ATSINSmove_lazyeval_make
(
  tok_kwd: token
, tmp: i0de, s0e_res: s0exp, d0e: d0exp (*lazyval*)
, tok_end: token
) : instr // end-of-function
//
fun
ATSINSmove_ldelay_make
(
  tok_kwd: token
, tmp: i0de, s0e_res: s0exp, d0e: d0exp (*thunk*)
, tok_end: token
) : instr // end-of-function
//
fun
ATSINSmove_llazyeval_make
(
  tok_kwd: token
, tmp: i0de, s0e_res: s0exp, d0e: d0exp (*lazyval*)
, tok_end: token
) : instr // end-of-function
//
(* ****** ****** *)
//
fun
ATStailcalseq_make
(
  tok_kwd: token, inss: instrlst, tok_end: token
) : instr // end-of-function
//
fun
ATSINSmove_tlcal_make
(
  tok_kwd: token, argx: i0de, d0e: d0exp, tok_end: token
) : instr // end-of-function
//
fun
ATSINSargmove_tlcal_make
(
  tok_kwd: token, arg0: i0de, argx: i0de, tok_end: token
) : instr // end-of-function
//
(* ****** ****** *)

fun
ATSINSextvar_assign_make
(
  tok_kwd: token, ext: d0exp, d0e_r: d0exp, tok_end: token
) : instr // end of [ATSINSextvar_assign_make]
fun
ATSINSdyncst_valbind_make
(
  tok_kwd: token, d2cst: i0de, d0e_r: d0exp, tok_end: token
) : instr // end of [ATSINSdyncst_valbind_make]

(* ****** ****** *)
//
fun
ATSINScaseof_fail_make
  (tok_kwd: token, errmsg: token, tok_end: token): instr
//
fun
ATSINSdeadcode_fail_make (tok_kwd: token, tok_end: token): instr
//
(* ****** ****** *)
//
fun
ATSdynload_make (tok_kwd: token, tok_end: token): instr
fun
ATSdynloadset_make (tok_kwd: token, id: i0de, tok_end: token): instr
fun
ATSdynloadfcall_make (tok_kwd: token, id: i0de, tok_end: token): instr
//
fun
ATSdynloadflag_sta_make (tok_kwd: token, id: i0de, tok_end: token): instr
fun
ATSdynloadflag_ext_make (tok_kwd: token, id: i0de, tok_end: token): instr
//
(* ****** ****** *)
//
fun
f0body_classify (f0body): int
//
fun
f0body_get_tmpdeclst (f0body): tmpdeclst
//
fun
f0body_get_bdinstrlst (f0body): instrlst
//
(* ****** ****** *)

fun
f0body_make
(
  tok_beg: token, tmps: tmpdeclst, inss: instrlst, tok_end: token
) : f0body // end-of-fun

(* ****** ****** *)

fun f0decl_none (head: f0head): f0decl
fun f0decl_some (head: f0head, body: f0body): f0decl

(* ****** ****** *)
//
fun d0ecl_include
  (tok_beg: token, fname: s0tring): d0ecl
//
fun d0ecl_typedef
  (tok_beg: token, tyrec: tyrec, id: i0de): d0ecl
//
fun d0ecl_assume
  (tok_beg: token, name: i0de, tok_end: token): d0ecl
//
fun
d0ecl_dyncst_mac
  (tok_beg: token, name: i0de, tok_end: token): d0ecl
//
fun
d0ecl_dyncst_extfun
(
  tok_beg: token
, name: i0de, arg: s0explst, res: s0exp, tok_end: token
) : d0ecl // end of [d0ecl_dyncst_extfun]
//
fun
d0ecl_dyncst_valdec
(
  tok_beg: token, name: i0de, s0e: s0exp, tok_end: token
) : d0ecl // end of [d0ecl_dyncst_valdec]
fun
d0ecl_dyncst_valimp
(
  tok_beg: token, name: i0de, s0e: s0exp, tok_end: token
) : d0ecl // end of [d0ecl_dyncst_valimp]
//
(* ****** ****** *)
//
fun d0ecl_statmp_none
  (tok_kwd: token, tmp: i0de, tok_end: token): d0ecl
fun d0ecl_statmp_some
  (tok_kwd: token, tmp: i0de, opt: s0exp, tok_end: token): d0ecl
//
(* ****** ****** *)
//
fun d0ecl_fundecl (knd: fkind, f0d: f0decl): d0ecl
//
(* ****** ****** *)
//
fun
d0ecl_ifdef
(
  tok_kwd: token, id: i0de, d0cs: d0eclist, tok_end: token
) : d0ecl // end of [d0ecl_ifdef]
//
fun
d0ecl_ifndef
(
  tok_kwd: token, id: i0de, d0cs: d0eclist, tok_end: token
) : d0ecl // end of [d0ecl_ifdef]
//
(* ****** ****** *)
//
fun
d0ecl_extcode
  (tok_kwd: token, extcode: tokenlst, tok_end: token): d0ecl
//
(* ****** ****** *)

fun
d0ecl_closurerize
(
  tok_kwd: token
, fl: label, env: s0exp, arg: s0exp, res: s0exp, tok_end: token
) : d0ecl // end of [d0ecl_closurerize]

(* ****** ****** *)
//
fun
d0ecl_dynloadflag_init
  (tok_kwd: token, flag: i0de, tok_end: token): d0ecl
//
fun
d0ecl_dynloadflag_minit
  (tok_kwd: token, flag: i0de, tok_end: token): d0ecl
//
(* ****** ****** *)
//
fun
d0ecl_dynexn_dec
  (tok_kwd: token, idexn: i0de, tok_end: token): d0ecl
fun
d0ecl_dynexn_extdec
  (tok_kwd: token, idexn: i0de, tok_end: token): d0ecl
fun
d0ecl_dynexn_initize
(
  tok_kwd: token, idexn: i0de, fullname: s0tring, tok_end: token
) : d0ecl // end of [d0ecl_dynexn_initize]
//
(* ****** ****** *)

(* end of [catsparse_syntax.sats] *)