forked from ring-lang/ring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.template
1129 lines (929 loc) · 35.6 KB
/
index.template
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
<% eval(read("news.data")) %>
<div class="row">
<div class="col-sm-12 col-md-6">
<div id="introduction" class="panel-group">
<div class="panel panel-default">
<div class="panel-heading"><h4>Introduction</h4></div>
<div class="panel-body">
<p align="justify">
The Ring is an innovative and practical general-purpose multi-paradigm language.
The supported programming paradigms are imperative, procedural, object-oriented, declarative using nested structures, functional, meta programming and natural programming.
The language is portable (Windows, Linux, macOS, Android, etc.) and can be used to create Console, GUI, Web, Games and Mobile applications.
The language is designed to be simple, small, flexible and fast.
</p>
</div>
</div>
</div>
</div>
<div class="col-sm-12 col-md-6">
<div id="news" class="panel-group">
<div class="panel panel-info">
<div class="panel-heading"><h4>News</h4></div>
<div class="panel-body">
<table class="table table-striped">
<thead>
<tr>
<th width="40%">Date</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<% for x=1 to 3 %>
<tr>
<td><%= aNews[x][1] %></td>
<td><%= aNews[x][2] %></td>
</tr>
<% next %>
</tbody>
</table>
<div style="text-align:right;">
<a href="news.html">See more!</a>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<a href="#innovative" class="btn btn-default" data-toggle="collapse" style="width:100%">Innovative</a>
<div id="innovative" class="panel-group collapse in">
<div class="panel panel-primary">
<div class="panel-heading"><h4>Innovative</h4></div>
<div class="panel-body">
<div class="row">
<div class="col-sm-12 col-md-12">
<p>
The language comes with better support for Natural Language Programming and Declarative Programming. The innovation comes in supporting these paradigms with new practical techniques on the top of Object-Oriented Programming and Functional Programming. No need to know anything about (Compilers and Parsing). You get the language constructs ready for use to create domain-specific languages in a fraction of time.
</p>
<a id="ringarticle2" href="https://www.codeproject.com/Articles/1200766/Using-the-Natural-Language-Programming-Library-NLP" target="_blank" class="btn btn-default" style="width:100%">Natural Language Programming Library</a>
<a id="ringarticle3" href="https://www.codeproject.com/Articles/1138605/Natural-Language-Programming-in-the-Ring-Programmi" target="_blank" class="btn btn-default" style="width:100%">Natural Language Programming</a>
<a id="ringarticle4" href="https://www.codeproject.com/Articles/1137388/Syntax-Flexibility-in-the-Ring-Programming-Languag" target="_blank" class="btn btn-default" style="width:100%">Syntax Flexibility</a>
<a id="ringarticle" href="http://www.codeproject.com/Articles/1089887/The-Ring-Programming-Language" target="_blank" class="btn btn-default" style="width:100%">Ring Article</a>
</div>
</div>
</div>
</div>
</div>
<a href="#practical" class="btn btn-default" data-toggle="collapse" style="width:100%">Practical</a>
<div id="practical" class="panel-group collapse in">
<div class="panel panel-default">
<div class="panel-heading"><h4>Practical</h4></div>
<div class="panel-body">
<div class="row">
<div class="col-sm-12 col-md-12">
<p>
Many of the Ring libraries (StdLib, WebLib, Natural Library, Games Engine, etc.) and the Ring IDE (Ring Notepad, Form Designer, etc.) are written in the Ring language itself.
Ring is ready for use in production and increase the developers productivity.
</p>
<br>
<div class="col-xs-12">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
<li data-target="#myCarousel" data-slide-to="4"></li>
<li data-target="#myCarousel" data-slide-to="5"></li>
<li data-target="#myCarousel" data-slide-to="6"></li>
<li data-target="#myCarousel" data-slide-to="7"></li>
<li data-target="#myCarousel" data-slide-to="8"></li>
<li data-target="#myCarousel" data-slide-to="9"></li>
<li data-target="#myCarousel" data-slide-to="10"></li>
<li data-target="#myCarousel" data-slide-to="11"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item">
<img src="ringdemo1.png" alt="" width="1366" height="729">
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
<div class="item">
<img src="ringdemo2.png" alt="" width="1366" height="729">
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
<div class="item">
<img src="ringdemo3.png" alt="" width="1366" height="729">
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
<div class="item">
<img src="ringdemo4.jpg" alt="" width="1366" height="729">
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
<div class="item">
<img src="ringdemo5.png" alt="" width="1366" height="729">
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
<div class="item">
<img src="ringdemo6.png" alt="" width="1366" height="729">
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
<div class="item">
<img src="ringdemo8.png" alt="" width="1366" height="729">
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
<div class="item active">
<img src="ringdemo12.png" alt="" width="1366" height="729">
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
<div class="item">
<img src="ringdemo10.png" alt="" width="1366" height="729">
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
<div class="item">
<img src="ringdemo9.png" alt="" width="1366" height="729">
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
<div class="item">
<img src="ringdemo11.png" alt="" width="1366" height="729">
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
<div class="item">
<img src="ringdemo7.png" alt="" width="1366" height="729">
<div class="carousel-caption">
<h3></h3>
<p></p>
</div>
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="false"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="false"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<a id="why" href="#whyring" class="btn btn-default" data-toggle="collapse" style="width:100%">Why Ring?</a>
<div id="whyring" class="panel-group collapse in">
<div class="panel panel-default">
<div class="panel-heading"><h4>Why Ring?</h4></div>
<div class="panel-body">
<p align="justify">
The language is simple, trying to be natural, encourage organization and comes with transparent and visual implementation.
It comes with compact syntax and a group of features that enable the programmer to create natural interfaces and declarative
domain-specific languages in a fraction of time. It is very small, fast and comes with smart
garbage collector that puts the memory under the programmer control. It supports many programming paradigms, comes with useful and practical libraries.
The language is designed for productivity and developing high quality solutions that can scale.
<a href="doc1.6/faq.html#why-do-we-need-yet-another-programming-language-yapl" target="_blank"> Why? </a>
</p>
<br> <br>
<div class="panel panel-primary" id="productivityscal">
<div class="panel-heading"><h4> Designed for a Clear Goal</h4></div>
<div class="panel-body">
<p>
<ul>
<li>Applications programming language. <a href="doc1.6/ringapps.html" target="_blank"> Examples? </a> </li>
<li>Productivity and developing high quality solutions that can scale.</li>
<li>Small and fast language that can be embedded in C/C++ projects. <a href="doc1.6/embedding.html" target="_blank"> How? </a></li>
<li>Simple language that can be used in education and introducing Compiler/VM concepts. <a href="#education" target="_blank"> How? </a></li>
<li>General-Purpose language that can be used for creating domain-specific libraries, frameworks and tools. <a href="doc1.6/naturallibrary.html" target="_blank"> How? </a></li>
<li>Practical language designed for creating the next version of the Programming Without Coding Technology software. <a href="http://pwct.org" target="_blank"> What? </a></li>
</ul>
</p>
</div>
</div>
<div class="panel panel-primary" id="simple">
<div class="panel-heading"><h4> Simple </h4></div>
<div class="panel-body">
Ring is a very simple language, and has a very straightforward syntax. It encourages programmers to program without boilerplate code.
To print something using the standard output, We can use the 'See' command.
<a href="doc1.6/faq.html#why-ring-uses-see-give-but-and-ok-keywords" target="_blank"> Why? </a>
<p>
<pre>
<font color="purple">see</font> "Hello, World!"
</pre>
</p>
The Main function is optional and will be executed after the statements, and is useful for using the local scope.
<a href="doc1.6/faq.html#what-is-the-goal-of-including-the-main-function-in-ring" target="_blank"> Why? </a>
<p>
<pre>
<font color="purple">func</font> main
<font color="purple">see</font> "Hello, World!"
</pre>
</p>
Uses Dynamic Typing and Lexical scoping. No $ is required before the variable name, but we can use it!
<a href="doc1.6/syntaxflexibility.html#using-and-in-the-start-of-the-variable-name" target="_blank"> Why? </a>
<br>
You can use the '+' operator for string concatenation and the language is
weakly typed and will do simple implicit conversion between numbers and strings only based on the context.
<a href="doc1.6/faq.html#why-ring-is-weakly-typed" target="_blank"> Why? </a>
<p>
<pre>
nCount = 10 <font color="green"># Global variable</font>
<font color="purple">func</font> main
nID = 1 <font color="green"># Local variable</font>
<font color="purple">see</font> "Count = " + nCount + nl + " ID = " + nID
</pre>
</p>
</div>
</div>
<div class="panel panel-primary" id="natural">
<div class="panel-heading"><h4> Trying to be natural </h4></div>
<div class="panel-body">
Ring is not case-sensitive
<a href="doc1.6/faq.html#why-ring-is-not-case-sensitive" target="_blank"> Why? </a>
<p>
<pre>
<font color="purple">see</font> "Enter your name ? "
<font color="purple">give</font> name
<font color="purple">see</font> "Hello " + Name <font color="green"># Name is the same as name </font>
</pre>
</p>
The list index starts from 1
<a href="doc1.6/faq.html#why-the-list-index-start-from-1-in-ring" target="_blank"> Why? </a>
<p>
<pre>
aList = ["one","two","three"]
<font color="purple">see</font> aList[1] <font color="green"># print one</font>
</pre>
</p>
Call functions before definition
<p>
<pre>
one()
two()
three()
<font color="purple">func</font> one
<font color="purple">see</font> "One" + nl
<font color="purple">func</font> two
<font color="purple">see</font> "two" + nl
<font color="purple">func</font> three
<font color="purple">see</font> "three" + nl
</pre>
</p>
The assignment operator uses Deep copy (no references in this operation)
<a href="doc1.6/faq.html#why-the-assignment-operator-uses-deep-copy" target="_blank"> Why? </a>
<p>
<pre>
aList = ["one","two","three"]
aList2 = aList
aList[1] = 1
<font color="purple">see</font> alist[1] <font color="green"># print 1</font>
<font color="purple">see</font> aList2[1] <font color="green"># print one</font>
</pre>
</p>
Pass numbers and strings by value, but pass lists and objects by reference.
<br>
The for in loop can update the list items.
<p>
<pre>
<font color="purple">func</font> main
aList = [1,2,3]
update(aList)
<font color="purple">see</font> aList <font color="green"># print one two three</font>
<font color="purple">func</font> update aList
<font color="purple">for</font> x <font color="purple">in</font> aList
<font color="purple">switch</font> x
<font color="purple">on</font> 1 x = "one"
<font color="purple">on</font> 2 x = "two"
<font color="purple">on</font> 3 x = "three"
<font color="purple">off</font>
<font color="purple">next</font>
</pre>
</p>
Using Lists during definition
<p>
<pre>
aList = [ [1,2,3,4,5] , aList[1] , aList[1] ]
<font color="purple">see</font> aList <font color="green"># print 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5</font>
</pre>
</p>
Exit from more than one loop
<a href="doc1.6/faq.html#why-you-can-specify-the-number-of-loops-you-want-to-break-out-of" target="_blank"> Why? </a>
<p>
<pre>
<font color="purple">for</font> x = 1 <font color="purple">to</font> 10
<font color="purple">for</font> y = 1 <font color="purple">to</font> 10
<font color="purple">see</font> "x=" + x + " y=" + y + nl
<font color="purple">if</font> x = 3 <font color="purple">and</font> y = 5
<font color="purple">exit</font> 2 <font color="green"># exit from 2 loops</font>
<font color="purple">ok</font>
<font color="purple">next</font>
<font color="purple">next</font>
</pre>
</p>
</div>
</div>
<div class="panel panel-primary" id="encourageorg">
<div class="panel-heading"><h4> Encourage Organization </h4></div>
<div class="panel-body">
The language encourage organization, Forget bad days using languages where the programmer start with
function then class then function and a strange mix between things!
<br><br>
Each source file follow the next structure
<br><br>
<ul>
<li>Load Files</li>
<li>Statements and Global Variables</li>
<li>Functions</li>
<li>Packages and Classes</li>
</ul>
This enable us to use Packages, Classes and Functions without the need to use a keyword to end
these components.
<br> <br>
We can write one line comments and multi-line comments
<br>
The comment starts with # or //
<br>
Multi-line comments are written between /* and */
<p>
<pre>
<font color="green">/*
Program Name : My first program using Ring
Year : 2017
*/</font>
<font color="purple">see</font> "What is your name? " <font color="green"># print message on screen</font>
<font color="purple">give</font> cName <font color="green"># get input from the user</font>
<font color="purple">see</font> "Hello " + cName <font color="green"> # say hello!</font>
<font color="green">// See "Bye!"</font>
</pre>
</p>
</div>
</div>
<div class="panel panel-primary" id="libs">
<div class="panel-heading"><h4> Compact Syntax </h4></div>
<div class="panel-body">
<p>
The language is <b>not line sensitive</b>, you don't need to write ; after statements, also you don't need
to press ENTER or TAB, so we can write the next code
</p>
<p>
<pre>
<font color="purple">see</font> "The First Message" <font color="purple">see</font> " Another message in the same line! " + <font color="red">nl</font>
<font color="purple">see</font> "Enter your name?" <font color="purple">give</font> <font color="red">Name</font> <font color="purple">see</font> "Hello " + <font color="red">Name</font>
</pre>
</p>
<p>
The next code create a class called Point contains three attributes X,Y and Z.
<b>No keywords is used to end the package/class/function definition</b>.
Also, we can <b>write the attributes names directly below the class name</b>.
</p>
<p>
<pre>
<font color="purple">class</font> Point X Y Z
</pre>
</p>
<p>
We can <b>use classes and functions before their definition</b>, In this example we will
create new object, set the object attributes then print the object values.
</p>
<p>
<pre>
o1 = <font color="purple">new</font> point o1.x=10 o1.y=20 o1.z=30 <font color="purple">see</font> O1 <font color="purple">class</font> Point X Y Z
</pre>
</p>
<p>
Instead of using the dot '.' operator to access the object attributes and methods
<b>we can use braces { } to access the object, then we can use the object attributes and methods</b>.
</p>
<p>
<pre>
o1 = <font color="purple">new</font> point { x=10 y=20 z=30 } <font color="purple">see</font> O1 <font color="purple">class</font> Point X Y Z
</pre>
</p>
<p>
Now we will <b>call a method after accessing the object using { }</b>
</p>
<p>
<pre>
oPerson = <font color="purple">new</font> Person
{
Name = "Somebody"
Address = "Somewhere"
Phone = "0000000"
Print() <font color="green"># here we call the Print() method</font>
}
<font color="purple">class</font> Person Name Address Phone
<font color="purple">func</font> Print
<font color="purple">see</font> "Name :" + name + nl +
"Address :" + Address + nl +
"Phone : " + phone + nl
</pre>
</p>
<p>
When we use { } to access the object then write any attribute name, <b>the language
will check the class for any setter/getter methods that will be called automatically</b>.
</p>
<p>
<pre>
<font color="purple">new</font> Number {
<font color="purple">see</font> one <font color="green"># Execute GetOne()</font>
<font color="purple">see</font> two <font color="green"># Execute GetTwo()</font>
<font color="purple">see</font> three <font color="green"># Execute GetThree()</font>
}
<font color="purple">class</font> Number one two three
<font color="purple">func</font> GetOne
<font color="purple">see</font> "Number : One" + nl
<font color="purple">return</font> 1
<font color="purple">func</font> GetTwo
<font color="purple">see</font> "Number : Two" + nl
<font color="purple">return</font> 2
<font color="purple">func</font> GetThree
<font color="purple">see</font> "Number : Three" + nl
<font color="purple">return</font> 3
</pre>
</p>
</div>
</div>
<div class="panel panel-primary" id="libs">
<div class="panel-heading"><h4> Define Natural Statements based on Object-Oriented </h4></div>
<div class="panel-body">
<a href="doc1.6/faq.html#why-the-ability-to-define-your-own-languages-instead-of-just-handing-over-the-syntax-so-you-can-parse-it-using-whatever-code-you-like" target="_blank"> Why? </a>
<p>
After the object access using { } if the class contains a method called BraceEnd() it will be executed!
</p>
<p>
<pre>
TimeForFun = <font color="purple">new</font> journey
<font color="green"># The first surprise!</font>
<b>TimeForFun {
Hello it is me <font color="green"># What a beatiful programming world!</font>
}</b>
<font color="green"># Our Class</font>
<font color="purple">class</font> journey
hello=0 it=0 is=0 me=0
<font color="purple">func</font> GetHello
<font color="purple">See</font> "Hello" + nl
<font color="purple">func</font> braceEnd
<font color="purple">See</font> "Goodbye!" + nl
</pre>
</p>
<p>
We can <b>execute code written in strings using the Eval() function</b>
</p>
<p>
<pre>
cCode = "See 'Code that will be executed later!' "
Eval(cCode) <font color="green"># execute the code to print the message</font>
</pre>
</p>
<p>
<b>We can create a list then execute code generated from that list</b>
</p>
<p>
<pre>
aWords = ["hello","it","is","me"]
<font color="purple">for</font> word <font color="purple">in</font> aWords cCode=word+"=0" eval(cCode) <font color="purple">next</font>
</pre>
</p>
<p>
<b>We can read text files using the Read(cFileName) function</b> and we can write files using
the Write(cFileName,cString) function.
</p>
<p>
<pre>
<font color="purple">see</font> "Enter File Name:" <font color="purple">give</font> cFileName <font color="purple">see</font> read(cFileName) <font color="green"># Print the file content</font>
</pre>
</p>
<p>
The next example presents how to create a class that defines two instructions<br>
The first instruction is : I want window<br>
The second instruction is : Window title = Expression <br>
Also keywords that can be ignored like the ‘the’ keyword <br>
</p>
<p>
<pre>
<font color="purple">new</font> App
{
I want window
The window title = "hello world"
}
<font color="purple">class</font> App
<font color="green"># Attributes for the instruction I want window</font>
i want window
nIwantwindow = 0
<font color="green"># Attributes for the instruction Window title</font>
<font color="green"># Here we don't define the window attribute again</font>
title
nWindowTitle = 0
<font color="green"># Keywords to ignore, just give them any value</font>
the=0
<font color="purple">func</font> geti
<font color="purple">if</font> nIwantwindow = 0
nIwantwindow++
<font color="purple">ok</font>
<font color="purple">func</font> getwant
<font color="purple">if</font> nIwantwindow = 1
nIwantwindow++
<font color="purple">ok</font>
<font color="purple">func</font> getwindow
<font color="purple">if</font> nIwantwindow = 2
nIwantwindow= 0
<font color="purple">see</font> "Instruction : I want window" + nl
<font color="purple">ok</font>
<font color="purple">if</font> nWindowTitle = 0
nWindowTitle++
<font color="purple">ok</font>
<font color="purple">func</font> settitle cValue
<font color="purple">if</font> nWindowTitle = 1
nWindowTitle=0
<font color="purple">see</font> "Instruction : Window Title = " + cValue + nl
<font color="purple">ok</font>
</pre>
</p>
<p>
To complete the previous example, use read() to get the content of a file that contains
<pre>
I want window
The window title = "hello world"
</pre>
Then use eval() to execute the content of that file!.<br>
Also, you can update the methods GetWindow() and SetTitle() to create Real windows using the GUI Library<br>
</p>
</div>
</div>
<div class="panel panel-primary" id="libs">
<div class="panel-heading"><h4> Define Declarative Languages using Nested Structures based on Object-Oriented </h4></div>
<div class="panel-body">
<p>
<b>We learned how to use Natural statements to execute our code and using the same features
we can use nested structures to execute our code</b>.
</p>
<p>
The next example from the Web library, generate HTML document using the Bootstrap library.
No HTML code is written directly in this example, we created a similar language (just as example)
Then <b>using this declarative language that uses nested structures, we generated the HTML Document.</b>.
<br>
The idea in this example is that the <b>GetDiv() and GetH1() methods return an object that we can
access using {} and after each object access the method BraceEnd() will be executed to send the
generated HTML to the parent object until we reach to the root where BraceEnd() will print the output</b>.
</p>
<p>
<pre>
<font color="purple">load</font> "weblib.ring"
<font color="purple">import</font> System.Web
<font color="purple">func</font> Main
BootStrapWebPage()
{
div
{
classname = :container
div
{
classname = :jumbotron
H1 { text("Bootstrap Page") }
}
div
{
classname = :row
for x = 1 to 3
div
{
classname = "col-sm-4"
H3 { html("Welcome to the Ring programming language") }
P { html("Using a scripting language is very fun!") }
}
next
}
}
}
</pre>
</p>
<p>
The classes that power the declarative interface looks like this
</p>
<p>
<pre>
<xmp>
class Link from ObjsBase
title link
func braceend
cOutput = nl+GetTabs() + "<a href='" +
Link + "'> "+ Title + " </a> " + nl
class Div from ObjsBase
func braceend
cOutput += nl+'<div'
addattributes()
AddStyle()
getobjsdata()
cOutput += nl+"</div>" + nl
cOutput = TabMLString(cOutput)
</xmp>
</pre>
</p>
</div>
</div>
<br> <br>
<a name="education"></a>
<div class="panel panel-primary" id="transparentimplementation">
<div class="panel-heading"><h4> Transparent Implementation </h4></div>
<div class="panel-body">
Ring comes with transparent implementation. We can know what is happening in each compiler stage and
what is going on during the run-time by the Virtual Machine
Example : ring helloworld.ring -tokens -rules -ic
<p>
<pre>
<font color="purple">see</font> "Hello, World!"
</pre>
</p>
Output
<p>
<pre>
==================================================================
Tokens - Generated by the Scanner
==================================================================
Keyword : SEE
Literal : Hello, World!
EndLine
==================================================================
==================================================================
Grammar Rules Used by The Parser
==================================================================
Rule : Program --> {Statement}
Line 1
Rule : Factor --> Literal
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
Rule : BitOrXOR --> BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement --> 'See' Expr
==================================================================
==================================================================
Byte Code - Before Execution by the VM
==================================================================
PC OPCode Data
1 FuncExE
2 PushC Hello, World!
3 Print
4 ReturnNull
==================================================================
Hello, World!
</pre>
</p>
</div>
</div>
<div class="panel panel-primary" id="visualimplementation">
<div class="panel-heading"><h4> Visual Implementation </h4></div>
<div class="panel-body">
The Ring programming language is designed using the <a href="http://doublesvsoop.sourceforge.net" target="_blank">PWCT visual programming tool </a>
and you will find the visual source of the language in the folder
"visualsrc" - *.ssf files and the generated source code (In the C Language) in the
src folder and the include folder. <a href="http://github.com/ring-lang/ring" target="_blank">Forke me on GitHub</a>
<br><br>
The next screen shot from the ring_vm.ssf file (Generate ring_vm.c and ring_vm.h)
<br><br>
<div class="text-center"><img src="ringvisualsrc1.jpg" width="600"></div>
<br><br>
The next screen shot from the ring_list.ssf file (Generate ring_list.c and ring_list.h)
<br><br>
<div class="text-center"><img src="ringvisualsrc2.jpg" width="600"></div>
</div>
</div>
<div class="panel panel-primary" id="smartgc">
<div class="panel-heading"><h4> Smart Garbage Collector </h4></div>
<div class="panel-body">
Avoid memory problems :-
<br><br>
<ul>
<li>Invalid Memory Access</li>
<li>Memory leaks</li>
<li>Uninitialized Memory Access</li>
<li>Dangling pointer</li>
</ul>
Rules :-
<br><br>
<ul>
<li>Global variables always stay in the memory, until you delete these variables using the assignment statement.</li>
<li>Local variables always deleted after the end of the function.</li>
<li>The programmer have full control on when to delete the variable from the memory using the Assignment statement.</li>
<br>
Example:
<pre>
aList = [1,2,3,4,5]
aList = "nice"
</pre>
After the second line directly, The list [1,2,3,4,5] will be deleted from the memory and we will have a string "nice"
<br><br>
<li>The programmer can call the function callgc() to force running the garbage collector.</li>
<li>If we have a reference to a variable (when we pass objects and lists to functions), then deleting variables will be based on reference counting, if no references everything will be deleted, but if we have a reference, the data will stay in memory.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<a href="#features" class="btn btn-default" data-toggle="collapse" style="width:100%">Features</a>
<div id="features" class="panel-group collapse in">
<div class="panel panel-default">
<div class="panel-heading"><h4>Features</h4></div>
<div class="panel-body">
<div class="row">
<div class="col-sm-12 col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">Free and Innovative</div>
<div class="panel-body">
<ul>
<li>Free Open Source (MIT License)</li>
<li>Declarative programming on the top of Object-Oriented programming</li>
<li>No explicit end for statements (No ; or ENTER is required)</li>
<li>For in get item by reference not value, you can read/edit the item</li>
<li>Use exit to go outside from more than one loop</li>
<li>No keyword to end Functions, Classes and Packages</li>
<li>using { } to access objects and use attributes/methods as variables/functions</li>
<li>Clear program structure (Statements then functions then packages & classes)</li>
<li>Optional Printing for Tokens/Grammar/Byte-Code during execution</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-12 col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">Powerful Implementation</div>
<div class="panel-body">
<ul>
<li>Hybrid Implementation (Compiler+VM)</li>
<li>The compiler + The Virtual Machine are 15,000 lines of C code</li>
<li>The other 500,000 lines of code are related to libraries!</li>
<li>Written in ANSI C (The code is generated)</li>
<li>Developed using Visual Programming (PWCT)</li>
<li>Portable (Windows, Linux & macOS, Android, etc.)</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-12 col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">Simple</div>
<div class="panel-body">
<ul>
<li>Comments (One line & Multi-line)</li>
<li>Not Case-Sensitive</li>
<li>Structure Programming</li>
<li>Rich control structures & Operators</li>
<li>Procedures/Functions</li>
<li>Main Function (optional)</li>
<li>Call Function before the definition</li>
<li>Recursion</li>
<li>Multi-line literals</li>
<li>Access (read/write) string letter by index</li>
<li>The list index start from 1</li>
<li>Range operator ex: 1:10</li>
<li>First Class Variables, Lists, Objects and Functions</li>
<li>Store/Copy Lists/Objects by value (Deep Copy)</li>
<li>Pass Lists/Objects by reference</li>
<li>8-bit clean, work on binary data directly</li>
</ul>
</div>
</div>
</div>
</div>
<br> <br>
<div class="row">
<div class="col-sm-12 col-md-4">
<div class="panel panel-primary">
<div class="panel-heading"> Dynamic</div>
<div class="panel-body">
<ul>
<li>Dynamic Typing</li>
<li>Weakly typed</li>
<li>Lexical Scoping (Global, Local & Object State)</li>
<li>Default scope for variables inside functions (Local)</li>
<li>Default scope for variables outside functions (global)</li>
<li>Garbage Collector - Automatic Memory Management (Escape Analysis and Reference Counting)</li>
<li>Exception Handling</li>
<li>Eval() to execute code during run-time</li>