-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1556 lines (1199 loc) · 51.8 KB
/
index.html
File metadata and controls
1556 lines (1199 loc) · 51.8 KB
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
<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="next" href="download/">
<link rel="icon" href="assets/images/favicon.png">
<meta name="generator" content="mkdocs-1.4.3, mkdocs-material-9.1.19">
<title>Emfatic</title>
<link rel="stylesheet" href="assets/stylesheets/main.eebd395e.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
<style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
<link rel="stylesheet" href="assets/stylesheets/extra.css">
<link rel="stylesheet" href="assets/stylesheets/mermaid.css">
<link rel="stylesheet" href="assets/javascript/google-code-prettify/prettify.css">
<link rel="stylesheet" href="https://unpkg.com/mermaid@8.5.1/dist/mermaid.css">
<script>__md_scope=new URL(".",location),__md_hash=e=>[...e].reduce((e,_)=>(e<<5)-e+_.charCodeAt(0),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
</head>
<body dir="ltr">
<script>var palette=__md_get("__palette");if(palette&&"object"==typeof palette.color)for(var key of Object.keys(palette.color))document.body.setAttribute("data-md-color-"+key,palette.color[key])</script>
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" for="__drawer"></label>
<div data-md-component="skip">
<a href="#eclipse-emfatic" class="md-skip">
Skip to content
</a>
</div>
<div data-md-component="announce">
</div>
<header class="md-header md-header--shadow" data-md-component="header">
<nav class="md-header__inner md-grid" aria-label="Header">
<a href="." title="Emfatic" class="md-header__button md-logo" aria-label="Emfatic" data-md-component="logo">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54Z"/></svg>
</a>
<label class="md-header__button md-icon" for="__drawer">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></svg>
</label>
<div class="md-header__title" data-md-component="header-title">
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
Emfatic
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
Home
</span>
</div>
</div>
</div>
<label class="md-header__button md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
</label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
<label class="md-search__icon md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
</label>
<nav class="md-search__options" aria-label="Search">
<button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"/></svg>
</button>
</nav>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" data-md-scrollfix>
<div class="md-search-result" data-md-component="search-result">
<div class="md-search-result__meta">
Initializing search
</div>
<ol class="md-search-result__list" role="presentation"></ol>
</div>
</div>
</div>
</div>
</div>
<div class="md-header__source">
<a href="https://github.com/eclipse-emfatic/emfatic" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg>
</div>
<div class="md-source__repository">
Emfatic @ GitHub
</div>
</a>
</div>
</nav>
</header>
<div class="md-container" data-md-component="container">
<main class="md-main" data-md-component="main">
<div class="md-main__inner md-grid">
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
<label class="md-nav__title" for="__drawer">
<a href="." title="Emfatic" class="md-nav__button md-logo" aria-label="Emfatic" data-md-component="logo">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54Z"/></svg>
</a>
Emfatic
</label>
<div class="md-nav__source">
<a href="https://github.com/eclipse-emfatic/emfatic" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg>
</div>
<div class="md-source__repository">
Emfatic @ GitHub
</div>
</a>
</div>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item md-nav__item--active">
<input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
<label class="md-nav__link md-nav__link--active" for="__toc">
Home
<span class="md-nav__icon md-icon"></span>
</label>
<a href="." class="md-nav__link md-nav__link--active">
Home
</a>
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#packages" class="md-nav__link">
Packages
</a>
<nav class="md-nav" aria-label="Packages">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#main-package" class="md-nav__link">
Main Package
</a>
</li>
<li class="md-nav__item">
<a href="#sub-packages" class="md-nav__link">
Sub-Packages
</a>
</li>
<li class="md-nav__item">
<a href="#main-package-imports" class="md-nav__link">
Main Package Imports
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#classifiers" class="md-nav__link">
Classifiers
</a>
<nav class="md-nav" aria-label="Classifiers">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#classes" class="md-nav__link">
Classes
</a>
</li>
<li class="md-nav__item">
<a href="#data-types" class="md-nav__link">
Data Types
</a>
</li>
<li class="md-nav__item">
<a href="#enumerated-types" class="md-nav__link">
Enumerated Types
</a>
</li>
<li class="md-nav__item">
<a href="#map-entries" class="md-nav__link">
Map Entries
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#type-expressions" class="md-nav__link">
Type Expressions
</a>
<nav class="md-nav" aria-label="Type Expressions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#basic-types" class="md-nav__link">
Basic Types
</a>
</li>
<li class="md-nav__item">
<a href="#multiplicity-expressions" class="md-nav__link">
Multiplicity Expressions
</a>
</li>
<li class="md-nav__item">
<a href="#escaping-keywords" class="md-nav__link">
Escaping Keywords
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#structural-and-behavioral-features" class="md-nav__link">
Structural and Behavioral Features
</a>
<nav class="md-nav" aria-label="Structural and Behavioral Features">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#modifiers" class="md-nav__link">
Modifiers
</a>
</li>
<li class="md-nav__item">
<a href="#attributes" class="md-nav__link">
Attributes
</a>
</li>
<li class="md-nav__item">
<a href="#references" class="md-nav__link">
References
</a>
</li>
<li class="md-nav__item">
<a href="#operations" class="md-nav__link">
Operations
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#annotations" class="md-nav__link">
Annotations
</a>
<nav class="md-nav" aria-label="Annotations">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#annotation-labels" class="md-nav__link">
Annotation Labels
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#about" class="md-nav__link">
About
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="download/" class="md-nav__link">
Download
</a>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_3" >
<label class="md-nav__link" for="__nav_3" id="__nav_3_label" tabindex="0">
Community
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_3_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_3">
<span class="md-nav__icon md-icon"></span>
Community
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="https://projects.eclipse.org/projects/modeling.emft.emfatic/who" class="md-nav__link">
Who is developing Emfatic?
</a>
</li>
<li class="md-nav__item">
<a href="https://www.eclipse.org/forums/index.php/f/19/" class="md-nav__link">
Forum
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#packages" class="md-nav__link">
Packages
</a>
<nav class="md-nav" aria-label="Packages">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#main-package" class="md-nav__link">
Main Package
</a>
</li>
<li class="md-nav__item">
<a href="#sub-packages" class="md-nav__link">
Sub-Packages
</a>
</li>
<li class="md-nav__item">
<a href="#main-package-imports" class="md-nav__link">
Main Package Imports
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#classifiers" class="md-nav__link">
Classifiers
</a>
<nav class="md-nav" aria-label="Classifiers">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#classes" class="md-nav__link">
Classes
</a>
</li>
<li class="md-nav__item">
<a href="#data-types" class="md-nav__link">
Data Types
</a>
</li>
<li class="md-nav__item">
<a href="#enumerated-types" class="md-nav__link">
Enumerated Types
</a>
</li>
<li class="md-nav__item">
<a href="#map-entries" class="md-nav__link">
Map Entries
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#type-expressions" class="md-nav__link">
Type Expressions
</a>
<nav class="md-nav" aria-label="Type Expressions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#basic-types" class="md-nav__link">
Basic Types
</a>
</li>
<li class="md-nav__item">
<a href="#multiplicity-expressions" class="md-nav__link">
Multiplicity Expressions
</a>
</li>
<li class="md-nav__item">
<a href="#escaping-keywords" class="md-nav__link">
Escaping Keywords
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#structural-and-behavioral-features" class="md-nav__link">
Structural and Behavioral Features
</a>
<nav class="md-nav" aria-label="Structural and Behavioral Features">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#modifiers" class="md-nav__link">
Modifiers
</a>
</li>
<li class="md-nav__item">
<a href="#attributes" class="md-nav__link">
Attributes
</a>
</li>
<li class="md-nav__item">
<a href="#references" class="md-nav__link">
References
</a>
</li>
<li class="md-nav__item">
<a href="#operations" class="md-nav__link">
Operations
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#annotations" class="md-nav__link">
Annotations
</a>
<nav class="md-nav" aria-label="Annotations">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#annotation-labels" class="md-nav__link">
Annotation Labels
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#about" class="md-nav__link">
About
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content" data-md-component="content">
<article class="md-content__inner md-typeset">
<h1 id="eclipse-emfatic">Eclipse Emfatic<a class="headerlink" href="#eclipse-emfatic" title="Permanent link">¶</a></h1>
<p>Emfatic is a textual syntax for <a href="http://www.eclipse.org/emf">EMF Ecore</a>
(meta-)models. This page details the syntax of Emfatic and the mapping between
Emfatic declarations and the corresponding Ecore constructs.</p>
<p><img alt="" src="assets/images/emfatic-editor.png" /></p>
<h2 id="packages">Packages<a class="headerlink" href="#packages" title="Permanent link">¶</a></h2>
<p>Emfatic programs are shown in boxes as in the example
below:</p>
<pre class="prettyprint lang-emf"><code>package test;
class Foo { }</code></pre>
<p>When compiled, the program above will produce a model with an <code>EPackage</code>
named "test" containing a single <code>EClass</code> named <code>Foo</code>.</p>
<p>As is probably clear from the first Emfatic program above, the keyword
package introduces an Ecore <code>EPackage</code> and the identifier following it
maps to the <code>name</code> attribute of the generated <code>EPackage</code>.</p>
<h3 id="main-package">Main Package<a class="headerlink" href="#main-package" title="Permanent link">¶</a></h3>
<p>The only thing required in an Emfatic source file is a package
declaration. This required element is called the main package
declaration and the <code>EPackage</code> it defines will contain (directly or
indirectly) all of the other elements of the generated Ecore model.
Thus the simplest possible Emfatic program would look something like
this:</p>
<pre class="prettyprint lang-emf"><code>package p;</code></pre>
<p>Specifying values for the <code>EPackage</code> attributes <code>nsURI</code> and <code>nsPrefix</code>
is done like this:</p>
<pre class="prettyprint lang-emf"><code>@namespace(uri="http://www.eclipse.org/emf/2002/Ecore", prefix="ecore")
package ecore;</code></pre>
<p>Note that Emfatic is case-sensitive in most contexts (reflecting the
underlying case-sensitivity of Ecore), however the identifiers
<code>namespace</code>, <code>uri</code> and <code>prefix</code> in the text above could be written in any
case. Also note that the order of declaration for uri and prefix is not
important. The syntax of the <code>@namespace</code> declaration is actually a
special case of the more general syntax for declaring EAnnotations,
which will be described in full detail <a href="#annotations">below</a>.</p>
<h3 id="sub-packages">Sub-Packages<a class="headerlink" href="#sub-packages" title="Permanent link">¶</a></h3>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>While Ecore and Emfatic support nested/sub-packages, <a href="https://eclipsesource.com/blogs/2013/03/19/emf-dos-and-donts-5/">their use is discouraged</a> as many tools that build on top of EMF don't work well with them.</p>
</div>
<p>Ecore allows packages to be nested inside packages. In Emfatic, the
syntax for nested packages differs from that of the main package.
Nested package declarations are followed by a curly-brace bracketed
region which encloses the nested package contents. The example below
demonstrates package nesting.</p>
<pre class="prettyprint lang-emf"><code>package main;
package sub1 {
}
package sub2 {
package sub2_1 { }
package sub2_2 { }
}</code></pre>
<p>In the Ecore model generated from the above program, the top-level
package named <code>main</code> will contain two packages, <code>sub1</code> and <code>sub2</code>,
and package <code>sub2</code> will contain the packages <code>sub2_1</code> and <code>sub2_2</code>.</p>
<h3 id="main-package-imports">Main Package Imports<a class="headerlink" href="#main-package-imports" title="Permanent link">¶</a></h3>
<p>Import statements allow for types defined in external Ecore models to be
referenced. All import statements must immediately follow the main
package declaration. The example below demonstrates the basic syntax of
import statements. The double-quoted string literal following the
import keyword must contain the URI of an Ecore model.</p>
<pre class="prettyprint lang-emf"><code>package main;
import "platform:/resource/proj1/foo.ecore";
import "http://www.eclipse.org/emf/2002/Ecore";
package sub { }</code></pre>
<p>Note that Ecore.ecore is automatically imported, so the second import in
the program above is not really necessary.</p>
<h2 id="classifiers">Classifiers<a class="headerlink" href="#classifiers" title="Permanent link">¶</a></h2>
<h3 id="classes">Classes<a class="headerlink" href="#classes" title="Permanent link">¶</a></h3>
<p>The Emfatic syntax for class declarations is very similar to Java,
however a few quirks are required to allow for all of the possibilities
of Ecore. The example below containing four simple class declarations
demonstrates the use of the keywords <code>class</code>, <code>interface</code> and <code>abstract</code>
and also introduces Emfatic comments (Emfatic allows both styles of Java
comments). The comments detail the mapping from Emfatic to the <code>EClass</code>
attributes <code>interface</code> and <code>abstract</code>.</p>
<pre class="prettyprint lang-emf"><code>package main;
class C1 { } // isInterface=false, isAbstract=false
abstract class C2 { } // isInterface=false, isAbstract=true
interface I1 { } // isInterface=true, isAbstract=false
abstract interface I2 { } // isInterface=true, isAbstract=true</code></pre>
<p>Inheritance is specified with the keyword <code>extends</code>. Unlike Java, there
is no <code>implements</code> keyword to distinguish inheritance from interface
implementation. The example below defines an inheritance hierarchy.</p>
<pre class="prettyprint lang-emf"><code>package main;
class A { }
class B { }
class C extends A, B { }
class D extends C { }</code></pre>
<p>If necessary, the value of the <code>EClassifier</code> attribute
<code>instanceClassName</code> can be specified. The class
<code>EStringToStringMapEntry</code> from Ecore.ecore provides an example of this:</p>
<pre class="prettyprint lang-emf"><code>class EStringToStringMapEntry : java.util.Map$Entry {
// ... contents omitted ...
}</code></pre>
<p>Note that if the class both extends other classes and specifies a value
for <code>instanceClassName</code>, the extends clause must precede the <code>instanceClassName</code> clause.</p>
<h3 id="data-types">Data Types<a class="headerlink" href="#data-types" title="Permanent link">¶</a></h3>
<p>Declaring an <code>EDataType</code> is fairly simple. Here are some familiar
examples from Ecore.ecore:</p>
<pre class="prettyprint lang-emf"><code>datatype EInt : int;
datatype EIntegerObject : java.lang.Integer;
transient datatype EJavaObject : java.lang.Object;
datatype EFeatureMapEntry : org.eclipse.emf.ecore.util.FeatureMap$Entry;
datatype EByteArray : "byte[]"; // Note: [ and ] are not legal identifier characters and must be in quotes</code></pre>
<p>First note that as with classes, the value of the <code>EClassifier</code>
attribute <code>instanceClassName</code> follows the colon after the name of the
datatype. However specifying <code>instanceClassName</code> is required for
datatypes (while it is optional for classes).</p>
<p>The keyword <code>transient</code> in the third datatype declaration above
indicates that the value of the <code>EDataType</code> <code>serializable</code> attribute
should be set to false. This is a good time to point out that the
modifier keywords introduced so far (<code>abstract</code> and <code>interface</code>) are
applied to reverse the default Ecore attribute values (by default
<code>EClass</code> attributes <code>abstract</code> and <code>interface</code> are both false). In the
case of the <code>EDataType</code> attribute <code>serializable</code>, the default value is
true so Emfatic uses a keyword, <code>transient</code>, that means the opposite of
serializable.</p>
<p>The last two datatypes illustrate a subtle syntactic point. The value
specified for the <code>instanceClassName</code> attribute must either be a valid
qualified identifier (a dot or dollar-sign separated list of identifiers
such as <code>java.lang.Object</code> in the third datatype above) or it must be
enclosed in double quotes. The datatype EFeatureMapEntry contains the
character '<code>$</code>' which, following Java syntactic rules, is a legal
qualified identifier separator. The datatype EByteArray contains the
characters '<code>[</code>' and '<code>]</code>' which are not legal in a qualified
identifier.</p>
<p>The overall point to make about qualified identifier versus
double-quoted syntax for <code>instanceClassName</code> is that the typical
datatype declaration can use the former and thus should be easier to
read and edit, while the latter is available when needed and allows for
arbitrary string text to be placed in the generated Ecore model. There
are some other contexts where the Emfatic programmer has the option to
use either a qualified identifier or double-quoted string (see the
section on Annotations below for another example of this).</p>
<h3 id="enumerated-types">Enumerated Types<a class="headerlink" href="#enumerated-types" title="Permanent link">¶</a></h3>
<p>The example below demonstrates the Emfatic syntax that maps to <code>EEnum</code>
and <code>EEnumLiteral</code>. Note that the simple assignment expressions specify
the <code>value</code> attribute of each generated <code>EEnumLiteral</code>.</p>
<pre class="prettyprint lang-emf"><code>enum E {
A=1;
B=2;
C=3;
}</code></pre>
<p>In fact, specifying enumeration literal values is optional and Emfatic
generates reasonable values when they are left unspecified. The code
and comments below describe the rules for this.</p>
<pre class="prettyprint lang-emf"><code>enum E {
A; // = 0 (if not specified, first literal has value 0)
B = 3;
C; // = 4 (in general, unspecified values are 1 greater than previous value)
D; // = 5
}</code></pre>
<h3 id="map-entries">Map Entries<a class="headerlink" href="#map-entries" title="Permanent link">¶</a></h3>
<p>MapEntry classes (such as <code>EStringToStringMapEntry</code> in Ecore.ecore) can
be specified in either of two ways. The "longhand" way is to declare
a class with features named <code>key</code> and <code>value</code> and with
<code>[instanceClass=java.util.Map$Entry]</code> as suggested at the end of section
2.1 above. But there is a convienent shorthand notation which achieves
the same result:</p>
<pre class="prettyprint lang-emf"><code>mapentry EStringToStringMapEntry : String -> String;</code></pre>
<p>The expression following the colon gives the type of the MapEntry <code>key</code>
structural feature followed by the <code>-></code> operator, followed by the type
of the <code>value</code> structural feature. Type expressions can be more complex
than shown in the example above and are detailed fully in the next
section.</p>
<h2 id="type-expressions">Type Expressions<a class="headerlink" href="#type-expressions" title="Permanent link">¶</a></h2>
<p>The most basic Ecore elements that haven't yet been explored in Emfatic
are the structural and behavioral class features represented by the
Ecore classes <code>EAttribute</code>, <code>EReference</code>, <code>EOperation</code> and
<code>EParameter</code>. These four Ecore classes are all derived from
<code>ETypedElement</code> which means that instances of them have some type (which
is an <code>EClassifier</code>) and inherit the other characteristics of
<code>ETypedElement</code>, like multiplicity. Before we can describe each
specific kind of class feature, we need to show how types are
represented syntactically, because that applies (more or less) to all of
them.</p>
<p>Type expressions have two parts. First is a simple identifier or a
qualified identifier (a dot-separated list of simple identifiers like
<code>a.b.c</code>) that identifies some <code>EClassifier</code>. The <code>EClassifier</code>
identified may be defined in the same Emfatic source file as the type
expression, or it may be in one of the imported Ecore models (specified
in import statements).</p>
<p>Let's skip ahead a little by looking at some attribute declarations so
that we can talk about their type expressions:</p>
<pre class="prettyprint lang-emf"><code>package test;
datatype D1 : int;
package P {
datatype D2 : int;
}
class C {
attr D1 d1;
attr P.D2 d2;
attr ecore.EString s1;
attr String s2;
}</code></pre>
<p>The class named <code>C</code> above declares four attributes with the names
<code>d1</code>, <code>d2</code>, <code>s1</code> and <code>s2</code>. Note that Emfatic follows Java
syntactic style in placing type expression before the name. However
unlike Java field declarations, Emfatic uses a keyword - <code>attr</code> - to
introduce an attribute. (The keyword <code>attr</code> and similar keywords to
introduce references and operations will explained in more detail in the
following sub-sections).</p>
<p>The type expression for <code>d1</code> is <code>D1</code> which identifies the datatype <code>D1</code>.
Because <code>C</code> and <code>D1</code> are in the same package (<code>test</code>), this simple expression
is fine.</p>
<p>The type expression for <code>d2</code> is <code>P.D2"</code> In this case a qualified
identifier expression is necessary to identify datatype <code>D2</code> inside
package <code>P</code>.</p>
<p>The type expression for s1 is <code>ecore.EString</code>. This identifies the
datatype <code>EString</code> in package <code>ecore</code> (recall that model Ecore.ecore is
implicitly imported in all Emfatic programs).</p>
<p>The type expression for <code>s2</code> is <code>String</code>. The identifier <code>String</code> is
actually a special shorthand for <code>ecore.EString</code>, so <code>s1</code> and <code>s2</code> have the
same type.</p>
<h3 id="basic-types">Basic Types<a class="headerlink" href="#basic-types" title="Permanent link">¶</a></h3>
<p>A number of the types defined in Ecore.ecore have <a href="https://github.com/eclipse-emfatic/emfatic/blob/master/bundles/org.eclipse.emf.emfatic.core/src/org/eclipse/emf/emfatic/core/util/EmfaticBasicTypes.java">shorthand notation in
Emfatic</a>. The table below lists the Emfatic shorthand and the
corresponding Ecore.ecore type name for each of these basic types as
well as the corresponding Java type or class. </p>
<table>
<thead>
<tr>
<th>Emfatic Keyword</th>
<th>Ecore EClassifier name</th>
<th>Java type name</th>
</tr>
</thead>
<tbody>
<tr>
<td>boolean</td>
<td>EBoolean</td>
<td>boolean</td>
</tr>
<tr>
<td>Boolean</td>
<td>EBooleanObject</td>
<td>java.lang.Boolean</td>
</tr>
<tr>
<td>byte</td>
<td>EByte</td>
<td>byte</td>
</tr>
<tr>
<td>Byte</td>
<td>EByteObject</td>
<td>java.lang.Byte</td>
</tr>
<tr>
<td>char</td>
<td>EChar</td>
<td>char</td>
</tr>
<tr>
<td>Character</td>
<td>ECharacterObject</td>
<td>java.lang.Character</td>
</tr>
<tr>
<td>double</td>
<td>EDouble</td>
<td>double</td>