-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1190 lines (1092 loc) · 42.6 KB
/
index.html
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
<html>
<head>
<title>Synt - Docs</title>
<link rel="icon" href="Logo.png">
<meta name="description" content="Documentation for Synt">
<meta property="og:url" content="https://docs.synt.ml/">
<meta property="og:type" content="website">
<meta property="og:title" content="Synt - Docs">
<meta property="og:description" content="Documentation for Synt">
<meta property="og:image" content="/Banner.png">
<meta name="twitter:card" content="summary_large_image">
<meta property="twitter:domain" content="">
<meta property="twitter:url" content="https://docs.synt.ml/">
<meta name="twitter:title" content="Synt - Docs">
<meta name="twitter:description" content="Documentation for Synt">
<meta name="twitter:image" content="/Banner.png">
<link rel="stylesheet" href="style.css">
<script src="https://kit.fontawesome.com/a63f2fde7e.js" crossorigin="anonymous"></script>
<script src="script.js" defer></script>
</head>
<body>
<div class="container">
<div class="topics-bar" id="topics-bar">
<center onclick="view_topic('top');">
<img src="Logo.png" alt="Synt Docs Logo" width="80%"><br>
<sd>Synt Docs</sd>
</center>
<tb onclick="view_topic('general-synt');">General</tb>
<t1 onclick="view_topic('what-is-synt');">What is Synt?</t1>
<t1 onclick="view_topic('examples');">Examples</t1>
<t1 onclick="view_topic('installation');">Installation</t1>
<t2 onclick="view_topic('download-synt');">Download</t2>
<t2 onclick="view_topic('move-synt');">Move to Path</t2>
<t2 onclick="view_topic('add-synt-to-path');">Add to Path</t2>
<t1 onclick="view_topic('modes');">Modes</t1>
<t2 onclick="view_topic('file-mode');">File</t2>
<t2 onclick="view_topic('interactive-mode');">Interactive</t2>
<t2 onclick="view_topic('compile-mode');">Compile</t2>
<t2 onclick="view_topic('quit-mode');">Quit</t2>
<t2 onclick="view_topic('spyc-mode');">SPyC</t2>
<t2 onclick="view_topic('spyc-run-mode');">SPyC Run</t2>
<tb onclick="view_topic('learn-synt');">Learn Synt</tb>
<t1 onclick="view_topic('what-is-console');">Console Basics</t1>
<t1 onclick="view_topic('code-parsing');">Code Iterations</t1>
<t1 onclick="view_topic('commenting-algs');">Commenting</t1>
<t2 onclick="view_topic('alg-comment');">General</t2>
<t2 onclick="view_topic('query-comment');">Info</t2>
<t2 onclick="view_topic('ai-comment');">Command</t2>
<t1 new onclick="view_topic('basic-algs');">Basic</t1>
<t2 onclick="view_topic('version-alg');">Version</t2>
<t2 onclick="view_topic('end-alg');">End</t2>
<t2 onclick="view_topic('output-alg');">Output</t2>
<t2 onclick="view_topic('input-alg');">Input</t2>
<t1 new onclick="view_topic('var-algs');">Variables</t1>
<t2 onclick="view_topic('var-means');">Meaning</t2>
<t2 onclick="view_topic('var-types');">Types</t2>
<t2 onclick="view_topic('var-decl');">Creation</t2>
<t2 onclick="view_topic('var-ref');">Using</t2>
<t2 onclick="view_topic('coll-ref');">Collection Items</t2>
<t1 new onclick="view_topic('func-algs');">Functions</t1>
<t2 onclick="view_topic('func-means');">Meaning</t2>
<t2 onclick="view_topic('func-decl');">Creation</t2>
<t2 onclick="view_topic('func-ref');">Using</t2>
<t2 onclick="view_topic('func-syntax');">Call Syntax</t2>
<t2 onclick="view_topic('func-rtrn');">Return Values</t2>
<t1 new onclick="view_topic('opr-algs');">Operator</t1>
<t2 onclick="view_topic('opr-add');">Add</t2>
<t2 onclick="view_topic('opr-sub');">Subtract</t2>
<t2 onclick="view_topic('opr-mul');">Multiply</t2>
<t2 onclick="view_topic('opr-div');">Divide</t2>
<t2 onclick="view_topic('opr-pow');">Power</t2>
<t1 new onclick="view_topic('logic-algs');">Logic</t1>
<t2 onclick="view_topic('logic-chk');">Check</t2>
<t2 onclick="view_topic('logic-cond');">Condition</t2>
<t2 onclick="view_topic('logic-opr');">Operators</t2>
<t1 new onclick="view_topic('str-spl');">Special Characters</t1>
<t1 new onclick="view_topic('loop-algs');">Loop</t1>
<t2 onclick="view_topic('repeat-alg');">Repeat</t2>
<t2 onclick="view_topic('loop-alg');">Loop</t2>
<t1 new onclick="view_topic('itr-algs');">Iterable Functions</t1>
<t2 onclick="view_topic('count-alg');">Count</t2>
<t2 onclick="view_topic('insert-alg');">Insert</t2>
<t2 onclick="view_topic('remove-alg');">Remove</t2>
<t2 onclick="view_topic('delete-alg');">Delete</t2>
<t1 new onclick="view_topic('file-algs');">File</t1>
<t2 onclick="view_topic('read-alg');">Read</t2>
<t2 onclick="view_topic('write-alg');">Write</t2>
<t1 new onclick="view_topic('time-algs');">Time</t1>
<t2 onclick="view_topic('synt-ticking');">Ticks</t2>
<t2 onclick="view_topic('synt-time');">Time</t2>
<t2 onclick="view_topic('reset_tick-alg');">Reset Tick</t2>
<t2 onclick="view_topic('pause_tick-alg');">Pause Tick</t2>
<t2 onclick="view_topic('resume_tick-alg');">Resume Tick</t2>
<t2 onclick="view_topic('get_tick-alg');">Get Tick</t2>
<t1 new onclick="view_topic('console-algs');">Console</t1>
<t2 onclick="view_topic('console-alg');">Console</t2>
<t2 onclick="view_topic('clear-alg');">Clear</t2>
<t1 new onclick="view_topic('debug-algs');">Debug</t1>
<t2 onclick="view_topic('info-alg');">Variable Type</t2>
<t2 onclick="view_topic('restore-alg');">Restore</t2>
<t2 onclick="view_topic('error-alg');">Error</t2>
<t2 onclick="view_topic('warn-alg');">Warn</t2>
<t1 new onclick="view_topic('ex-res-algs');">Modules</t1>
<t2 onclick="view_topic('module-alg');">Importing</t2>
</div>
<div class="content" id="content">
<div id="top" class="banner">
<h1 id="title">
<img src="Logo.png" alt="Synt">
Synt Docs
</h1>
</div>
<h1 id="general-synt">
General
</h1>
<h2 id="what-is-synt">
What is Synt?
</h2>
<p>
Synt is a <highlight>programming language</highlight> and it is very suitable for beginners.
Code is <highlight>easy</highlight> and really <highlight>simple</highlight>.
<highlight>Syntax</highlight> is <highlight>user friendly</highlight> are really <highlight>readable</highlight> for person who can read and understand English.
<br><br>
Synt is <highlight>free</highlight> and <highlight>open source</highlight>.
It is made with <highlight>Python</highlight>.
Synt is the <highlight>next gen</highlight> programming language.
It is made so that updates are <highlight>easy</highlight> and <highlight>fast</highlight>.
Synt is made to make <highlight>software and game development</highlight> <highlight>easier</highlight> and <highlight>faster</highlight>.
<br><br>
For the history of Synt, it was initiated by <a href="https://attaditya.is-a.dev/"><highlight>Attachment Aditya</highlight></a> in year <highlight>2020</highlight>.
It was initially expected to be worked for about <highlight>1-2 Months</highlight>.
Later as time went by, it was expanded to be a larger project.
It will most probably be getting updated and expanded in the future.
</p>
<h2 id="examples">
Examples
</h2>
<h3>
Hello Synt
</h3>
<p>
<p class="code">
output "Hello Synt!"
</p class="code">
</p>
<h3>
Create Variables
</h3>
<p>
<p class="code">
var number my_num1 0
</p class="code">
</p>
<h3>
Add Numbers
</h3>
<p>
<p class="code">
var number my_sum 0
add my_sum 10 20 30 40 50 60
</p class="code">
</p>
<h3>
Variable Referencing
</h3>
<p>
<p class="code">
var text name "Synt"
output "Hello #name#!!! Welcome Back!!!"
</p class="code">
</p>
<h2 id="installation">
Installation
</h2>
<p>
Synt is created in a way so that it can be run in any systems.
However, the major focus is for <highlight>Windows</highlight>.
For other system Synt has <highlight>Python Source Code</highlight> which can be run to use Synt.
In future, there might be versions of Synt targetted for other platforms.
<br><br>
This section is focussing to install synt on <highlight>Windows</highlight>.
<br><br>
For other platforms you need to have <highlight>Python</highlight> installed on your system.
After that install the <highlight>Source Code</highlight> of Synt from <highlight>GitHub</highlight>.
Run the <highlight>Python Source Code</highlight> using <highlight>Python</highlight> to use Synt.
</p>
<h3 id="download-synt">
Download Synt
</h3>
<p>
Download <highlight>Synt Executable</highlight> for you through <a href="https://synt.ml/#downloads"><highlight>Official Synt Site</highlight></a>.
</p>
<h3 id="move-synt">
Move to Path
</h3>
<p>
Installing Synt just means moving it to the <highlight>Path</highlight> you want it to be.
It can be done manually.
This allows Synt to be used portably.
<br><br>
Generally, for <highlight>Windows</highlight>, it is recommended for <highlight>Apps</highlight> to be installed in <highlight>Programs Files</highlight>.
Although this is not mandatory, it is on the user where to install it.
<br><br>
<p class="code">
Suggested Synt Folder: <highlight>C:\Program Files\Synt</highlight>
</p>
</p>
<h3 id="add-synt-to-path">
Add to Path
</h3>
<p>
Although you might have installed synt in the <highlight>Path</highlight> you want it to be in, but you still need to access it.
To access synt, you may need to use the <highlight>Path</highlight> again and again to refer to the <highlight>Synt Executable</highlight> that will run Synt Code.
<br><br>
A simple solution is to add the <highlight>Path</highlight> to your <highlight>Path</highlight> in your <highlight>Environment Variables</highlight>.
This might sound complicated, but it isn't really that hard.
<br><br>
First of all, copy the <highlight>Folder Path</highlight> you want to add to your <highlight>Path</highlight> to your <highlight>Environment Variables</highlight>.
Now, open your <highlight>Environment Variables</highlight>.
To do so, start <highlight>Run</highlight>(<highlight>Windows Key</highlight> + <highlight>R</highlight>).
In run, type <highlight>sysdm.cpl</highlight>.
Once this causes the <highlight>System Properties</highlight> to open, click on <highlight>Advanced</highlight>.
Now, click on <highlight>Environment Variables</highlight>.
Under <highlight>System Variables</highlight>, click on <highlight>Path</highlight> and click on <highlight>Edit</highlight>.
Now, click on <highlight>New</highlight> and then paste the <highlight>Folder Path</highlight>.
Finally, click on <highlight>Apply</highlight> and <highlight>OK</highlight> on all windows till all <highlight>System Properties</highlight> windows are closed.
<br><br>
Synt is now globally added to <highlight>Path</highlight>. You can just refer <highlight>Synt</highlight> to run Synt.
</p>
<h2 id="modes">
Modes
</h2>
<p>
On using Synt without console arguments, it asks you for modes.
Synt has two major running modes.
<highlight>File Mode</highlight> and <highlight>Interactive Mode</highlight>.
Apart from modes that can run code, there are more modes.
<highlight>Quit Mode</highlight> and <highlight>Compile Mode</highlight> are two of them.
Synt also allows code to convert into SPyC (SyntPythonCompiler) that can be run with <highlight>Python</highlight>.
</p>
<h3 id="file-mode">
File Mode
</h3>
<p>
To run an existing code using <highlight>File Mode</highlight> is suggested.
This mode will ask you file path.
It is the complete file location to your code file.
Once code completed it closes.
<br><br>
This mode can be also accesed from directly passing <highlight>source code file path</highlight> in command line arguments.
The mode key is <highlight>*f</highlight> and <highlight>*file</highlight>.
<br><br>
<p class="code">
synt *f
</p>
<p class="code">
synt *file
</p>
<p class="code">
synt "main.synt"
</p>
</p>
<h3 id="interactive-mode">
Interactive Mode
</h3>
<p>
<highlight>Interactive Mode</highlight> or <highlight>Synteractive</highlight> is a good mode to learn and test commands.
This mode allows you to type and run code at same time.
As it runs at same time, it doesn't close until closing through code or force close.
<br><br>
The mode key is <highlight>*i</highlight> and <highlight>*interactive</highlight>.
<br><br>
<p class="code">
synt *i
</p>
<p class="code">
synt *interactive
</p>
</p>
<h3 id="compile-mode">
Compile Mode
</h3>
<p>
<highlight>Compile Mode</highlight> is a <highlight>command line arguments</highlight> based mode.
This mode <highlight>compiles</highlight> from <highlight>synt code</highlight> to an <highlight>distributable</highlight> application.
<br><br>
The mode key is <highlight>*c</highlight> and <highlight>*compile</highlight>.
<br><br>
<p class="code">
synt *c "main.synt"
</p>
<p class="code">
synt *compile "main.synt"
</p>
</p>
<h3 id="quit-mode">
Quit Mode
</h3>
<p>
<highlight>Quit Mode</highlight> just closes Synt.
<br><br>
The mode key is <highlight>*q</highlight> and <highlight>*quit</highlight>.
<br><br>
<p class="code">
synt *q
</p>
<p class="code">
synt *quit
</p>
</p>
<h3 id="spyc-mode">
SPyC Mode
</h3>
<p>
<highlight>SPyC Mode</highlight> is a <highlight>command line arguments</highlight> based mode.
This mode compiles from <highlight>synt code</highlight> to <highlight>Python Source Code</highlight>.
<br><br>
The mode key is <highlight>*spyc</highlight>.
<br><br>
<p class="code">
synt *spyc "main.synt"
</p>
</p>
<h3 id="spyc-run-mode">
SPyC Run Mode
</h3>
<p>
<highlight>SPyC Run Mode</highlight> is a <highlight>command line arguments</highlight> based mode.
This mode directly exports and runs the <highlight>SPyC Output</highlight>.
<br><br>
The mode key is <highlight>**spyc</highlight>.
<br><br>
<p class="code">
synt **spyc "main.synt"
</p>
</p>
<h1 id="learn-synt">
Learn Synt
</h1>
<h2 id="what-is-console">
What is Console?
</h2>
<p>
The console is the main window that opens when Synt or Synt Code is run.
It is the place where you can type and run code in Interactive Mode.
In file mode you can use console to see the outputs of code and give code inputs.
</p>
<h2 id="code-parsing">
How Synt Reads Code?
</h2>
<p>
First, obviously, Synt gets the code it needs to run.
This code can also be called as <highlight>source code</highlight>.
<br><br>
Then, Synt breaks the code into <highlight>blocks</highlight>.
The <highlight>blocks</highlight> into <highlight>tokens</highlight>.
<br><br>
Synt uses these blocks and tokens to recognize and execute corresponding commands and code.
Synt runs <highlight>block after block</highlight>.
</p>
<h2 id="commenting-algs">
Commenting in Synt
</h2>
<p>
There are three <highlight>Commenting Character</highlight> options in synt.
The functioning and working of all three is same.
All of them will be ignored during execution.
These are classified on the basis of organizing and how they are supposed to be used.
</p>
<h3 id="alg-comment">
General Comments
</h3>
<p>
Such comment is an algorithm in synt that will be ignored.
It has no use except for being used as placeholders and of course to comment in between code.
<br><br>
<p class="code">
comment This is a comment. This will be ignored in execution.
</p>
<p class="code">
$ This is a comment. This will be ignored in execution.
</p>
</p>
<h3 id="query-comment">
Info Comments
</h3>
<p>
This type of comment is used to <highlight>organize</highlight> code.
This should be generally used to convey what the following code is about and what it should do.
<br><br>
<p class="code">
? This is a query comment. This will be ignored in execution.
</p>
</p>
<h3 id="ai-comment">
Command Comments
</h3>
<p>
This type of comment is used when using an <highlight>AI</highlight> to write or analyze code.
Its content will depend on the <highlight>AI's</highlight> and <highlight>custom mods</highlight> that are used.
<br><br>
<p class="code">
> This is an AI command comment. If any AI or mod installed, this might do something.
> It won't do anything in execution.
</p>
</p>
<h2 id="basic-algs">
Basic Algorithms of Synt
</h2>
<p>
There are a few basic functions or so called <highlight>Algorithms</highlight> in synt.
These include basic <highlight>input</highlight> and <highlight>output</highlight> functions, as well as <highlight>version</highlight> function and <highlight>end</highlight> function.
These are the most primitive functions in synt.
</p>
<h3 id="version-alg">
Version
</h3>
<p>
This function just outputs the <highlight>version</highlight> of synt in console.
<br><br>
<p class="code">
version
</p>
</p>
<h3 id="end-alg">
End
</h3>
<p>
This function just ends/pauses the execution of synt.
<br><br>
<p class="code">
end
</p>
</p>
<h3 id="output-alg">
Output
</h3>
<p>
This function outputs the <highlight>arguments</highlight> passed into the function to the console.
<br><br>
<p class="code">
output "Hello Synt!"
</p>
</p>
<h3 id="input-alg">
Input
</h3>
<p>
This function is slightly more complex than the <highlight>output</highlight> function.
The first argument it takes is the <highlight>Output Variable</highlight>.
This is the variable that the <highlight>Input</highlight> will be stored in.
The second argument is the <highlight>Input Prompt</highlight>.
This is basically the text that should output before user is asked to input something.
<br><br>
<p class="code">
input input_var "Enter your input:"
</p>
</p>
<h2 id="var-algs">
Dynamic Programming in Synt with Variables
</h2>
<h3 id="var-means">
What is a Variable in Synt?
</h3>
<p>
Synt allows your program to be more <highlight>dynamic</highlight> with the help of <highlight>variables</highlight>.
<highlight>Variables</highlight> are a <highlight>sets of characters</highlight> that contain some <highlight>value</highlight> inside them.
It can also be said as <highlight>naming</highlight> some value and then using the name instead of value later on.
</p>
<h3 id="var-types">
Different Types of Variables
</h3>
<p>
Synt offers a few types of basic <highlight>variables</highlight>.
These include <highlight>number</highlight>, <highlight>decimal</highlight>, <highlight>text</highlight>, <highlight>binary</highlight>, <highlight>collection</highlight> and <highlight>nothing</highlight>.
<br><br>
A <highlight>number</highlight> is a <highlight>number</highlight> that can be <highlight>positive</highlight>, <highlight>negative</highlight> or <highlight>zero</highlight>.
It can't contain anything apart from <highlight>numeric characters</highlight> and <highlight>negative sign</highlight>.
A <highlight>decimal</highlight> is just like a <highlight>number type</highlight> that can contain <highlight>decimal point</highlight>.
A <highlight>text</highlight> is a <highlight>set of characters</highlight> enclosed between <highlight>double quotes(")</highlight>.
A <highlight>binary</highlight> is a <highlight>number</highlight> that can only contain <highlight>on</highlight> and <highlight>off</highlight>.
It can also be considered as <highlight>TRUE</highlight> or <highlight>FALSE</highlight> values, <highlight>0</highlight> or <highlight>1</highlight> and <highlight>empty</highlight> or <highlight>non-empty</highlight> values.
A <highlight>collection</highlight> is a <highlight>set of items</highlight> enclosed between <highlight>square brackets([])</highlight> and separated by <highlight>new line(\n)</highlight>.
These can contain other types inside themselves.
A <highlight>nothing</highlight> is a <highlight>variable</highlight> that has no value.
<br><br>
<p class="code">
number ..., -3, -2, -1, 0, 1, 2, 3, ...
decimal ..., -3.5, -2.5, -1.5, 0.5, 1.5, 2.5, 3.5, ...
text "hello", "yo", "SYNT!!!!", "SYYYYYYYYYYYYYYYYYYYNT!!!!", ...
binary on, off
nothing
collection [
<indent></indent>"Text Type"
<indent></indent>"Another Text Type"
<indent></indent>10
<indent></indent>-10
<indent></indent>0
<indent></indent>0.72
<indent></indent>-55.22
<indent></indent>on
<indent></indent>off
]
</p>
</p>
<h3 id="var-decl">
Making a Variable
</h3>
<p>
To make a variable, you can use the <highlight>var</highlight> function.
<br><br>
<p class="code">
var type var_name "var_value!"
</p>
</p>
<h3 id="var-ref">
Using a Variable
</h3>
<p>
To use a variable, you can use the <highlight>variable name</highlight> enclosed between <highlight>hash(#)</highlight>.
<br><br>
<p class="code">
output "Use a variable like #var_name#"
</p>
</p>
<h3 id="coll-ref">
Using an Item in a Collection
</h3>
<p>
To get an item from a collection, first refer collection as a variable and then mention the <highlight>item index number</highlight> enclosed between <highlight>< ></highlight> just immediately after the collection variable reference.
<highlight>item index number</highlight> is the amount of items in a collection before the item you want to get.
In simple terms the <highlight>item index number</highlight> is the <highlight>position</highlight> of the item in the collection minus 1.
<br><br>
<p class="code">
output "Lets say collection coll_name has item #coll_name#<0> and #coll_name#<1>!"
</p>
</p>
<h2 id="func-algs">
Avoiding Redundancy in Synt with Functions
</h2>
<p>
Repitition of code is a <highlight>bad practice</highlight> and can make your code cost more time to execute.
Synt however offers the ability to <highlight>avoid</highlight> this by using <highlight>functions</highlight>.
</p>
<h3 id="func-means">
Declaring a Function
</h3>
<p>
A <highlight>function</highlight> is a <highlight>set of instructions</highlight> that can be called/referenced to execute the <highlight>instructions</highlight> inside it for which it was defined.
</p>
<h3 id="func-decl">
Making a Function
</h3>
<p>
<highlight>custom functions</highlight> are defined by using the <highlight>alg</highlight> function.
They take name of list that will contain arguments which can later be used inside the instructions and the function name as parameters.
The <highlight>instructions</highlight> are enclosed between <highlight>{ }</highlight>.
<br><br>
<p class="code">
alg func_name argument_collection {
<indent></indent>output "Created a function. Calling first argument of the function. #argument_collection#<0>!"
}
</p>
</p>
<h3 id="func-ref">
Using a Function
</h3>
<p>
After the function is defined it can be called simply by using the <highlight>function name</highlight> at the start of the line like other functions.
<br><br>
<p class="code">
func_name
</p>
</p>
<h3 id="func-syntax">
Proper Syntax for a calling a custom Function in Synt
</h3>
<p>
<highlight>custom functions</highlight> can be called in Synt easily but they also take more parameters like the <highlight>return value variable</highlight> and the <highlight>arguments</highlight> passed.
<br><br>
<p class="code">
func_name return_variable arg1 arg2 ...
</p>
</p>
<h3 id="func-rtrn">
Returning a Value from a Function
</h3>
<p>
To return a value from a function, use the <highlight>result</highlight> function.
<br><br>
<p class="code">
alg func_name argument_collection {
<indent></indent>output "Created a function. Calling first argument of the function. #argument_collection#<0>!"
<indent></indent>result "Returned value!"
}
</p>
</p>
<h2 id="opr-algs">
Synt Mathematical Operations
</h2>
<p>
Synt allows user to perform some simple and complex mathematical operations on numbers, decimals, texts and other types.
</p>
<h3 id="opr-add">
Adding Numbers
</h3>
<p>
To add two numbers, use the <highlight>add</highlight> function.
<br><br>
<p class="code">
add output_variable 2 3
? this sets output_variable to 5
</p>
</p>
<h3 id="opr-sub">
Subtracting Numbers
</h3>
<p>
To subtract two numbers, use the <highlight>subtract</highlight> function.
<br><br>
<p class="code">
subtract output_variable 2 3
? this sets output_variable to -1
</p>
</p>
<h3 id="opr-mul">
Multiplying Numbers
</h3>
<p>
To multiply two numbers, use the <highlight>multiply</highlight> function.
<br><br>
<p class="code">
multiply output_variable 2 3
? this sets output_variable to 6
</p>
</p>
<h3 id="opr-div">
Dividing Numbers
</h3>
<p>
To divide two numbers, use the <highlight>divide</highlight> function.
<br><br>
<p class="code">
divide output_variable 6 3
? this sets output_variable to 2
</p>
</p>
<h3 id="opr-pow">
Power
</h3>
<p>
To get the power of a number, use the <highlight>power</highlight> function.
<br><br>
<p class="code">
power output_variable 2 3
? this sets output_variable to 8
</p>
</p>
<h2 id="logic-algs">
Conditional Programming with Synt
</h2>
<p>
In many cases, you may want to perform some action based on some condition.
Synt provides a way to do this with conditional programming.
<br><br>
Synt has two functions for these cases.
The first one can be used to check if a condition is true or false.
The second one can be used to perform an action if the condition is true or false.
</p>
<h3 id="logic-chk">
Check and Return
</h3>
<p>
To check if a condition is true or false, use the <highlight>check</highlight> function.
<br><br>
<p class="code">
check output_var compare_var_1 check_operation compare_var_2
? this sets output_var to on if the condition is true, and to off if the condition is false
</p>
</p>
<h3 id="logic-cond">
Check and Perform
</h3>
<p>
To perform an action if a condition is true or false, use the <highlight>condition</highlight> function.
<br><br>
<p class="code">
condition compare_var_1 check_operation compare_var_2 {
<indent></indent>output "Condition is true!"
} {
<indent></indent>output "Condition is false!"
}
? this will output "Condition is true!" if the condition is true else "Condition is false!"
</p>
<p class="code">
condition compare_var_1 check_operation compare_var_2 true_action false_action
? this will execute the true_action if the condition is true else the false_action
</p>
</p>
<h3 id="logic-opr">
All Conditional Operations
</h3>
<p>
Here's the list of all the conditional operations that can be used with <highlight>check</highlight> and <highlight>conditional</highlight> functions:
<br><br>
<p class="code">
"equals to" equals =
"not equals to" not !=
"greater than" greater >
"less than" less <
"greater than equal to" notless >=
"less than equal to" notgreater <=
"contains" contains <-
"does not contain" notcontains !<-
"starts with" starts _%
"does not start with" notstarts !_%
"ends with" ends %_
"does not end with" notends !%_
</p>
</p>
<h2 id="str-spl">
Special Characters
</h2>
<p>
Sometimes a character might be needed in a text but it can't be used directly.
In such cases special character keywords are used which will replace the keyword with the special character.
<br><br>
Here's the list of special characters that can be used in Synt:
<br><br>
<p class="code">
#NEWLINE '\n'
#INDENT '\t'
#BACKSPACE '\b'
#START '\r'
#SPACE ' '
#LEFTSQUARE '['
#RIGHTSQUARE ']'
#LEFTCURLY '{'
#RIGHTCURLY '}'
#COMMA ','
#DOT '.'
#SEMICOLON ';'
#COLON ':'
#EQUAL '='
#HASH '#'
#QUESTION '?'
#EXCLAMATION '!'
#QUOTE '"'
#APOSTROPHE "'"
</p>
</p>
<h2 id="loop-algs">
Repitition and Looping Code
</h2>
<p>
When some code or function is needed to repeated <highlight>simultaneously</highlight> with some or no variation then the writing everything <highlight>manually</highlight> is really difficult.
And when repitition to be done according to a variable or till the condition is true, that is dynamically changing to a variable, then the writing is even more difficult.
<br><br>
To make the writing of such code easier, Synt also allows another common feature in programming languages called <highlight>looping</highlight>.
<br><br>
<highlight>Loops</highlight> are used to repeat a block of code a number of times.
<br><br>
In Synt, there are two types of loops.
One is <highlight>statically repeating</highlight> and the other is <highlight>dynamically repeating</highlight>.
<br><br>
Loops that are <highlight>statically repeating</highlight> just follow a given number of times and then stop.
These don't update the argument dynamically and are just a method to reduce <highlight>code redundancy</highlight>.
This type of loop can be used with the <highlight>repeat</highlight> function.
<br><br>
Loops that are <highlight>dynamically repeating</highlight> are used to repeat a block of code a number of times that isn't fixed.
These are used to update the argument dynamically.
This type of loop can be used with the <highlight>loop</highlight> function.
</p>
<h3 id="repeat-alg">
Statically Repeating Loops
</h3>
<p>
The <highlight>repeat</highlight> function is used to repeat a block of code a given number of times.
<br><br>
<p class="code">
alg func args {
<indent></indent>output "Hello Synt!"
}
repeat 10 func
? executes func 10 times
</p>
</p>
<h3 id="loop-alg">
Dynamically Repeating Loops
</h3>
<p>
The <highlight>loop</highlight> function is used to repeat a block of code a number of times that is dynamically changing.
<br><br>
<p class="code">
? count down
var number cd 10
var binary do_it
alg func args {
<indent></indent>output #cd#
<indent></indent>subtract cd #cd# 1
<indent></indent>check do_it cd >= 0
}
loop do_it func
? count downs to 0
</p>
</p>
<h2 id="itr-algs">
Functions for Collections and Other Iterables
</h2>
<p>
Iterables are the variable types that are made up of multiple values.
These include <highlight>text</highlight> composed of <highlight>characters</highlight> and <highlight>collections</highlight> containing <highlight>items</highlight>.
<br><br>
Sometimes you need to use an iterable to store multiple values and data.
In such cases you would need to get length, add, remove and do other stuff with the iterable.
Synt allows such functions.
</p>
<h3 id="count-alg">
Length of an Iterable
</h3>
<p>
To get the <highlight>length</highlight> of an <highlight>iterable</highlight>, you can use the <highlight>count</highlight> function.
<br><br>
<p class="code">
var number len
count len obj
? returns the length of obj, obj is predefined
</p>
</p>
<h3 id="insert-alg">
Inserting an Item to an Iterable
</h3>
<p>
To insert an <highlight>item</highlight> into an <highlight>iterable</highlight>, you can use the <highlight>insert</highlight> function.
<br><br>
<p class="code">
insert obj item index
? inserts item into obj at index, obj is predefined
</p>
</p>
<h3 id="remove-alg">
Removing an Item from an Iterable
</h3>
<p>
To remove an <highlight>item</highlight> from an <highlight>iterable</highlight>, you can use the <highlight>remove</highlight> function.
<br><br>
<p class="code">
remove obj item limit
? removes item from obj, obj is predefined, removes limit amount of item
</p>
</p>
<h3 id="delete-alg">
Removing an Item at Given Index from an Iterable
</h3>
<p>
To remove an <highlight>item</highlight> at a given <highlight>index</highlight> from an <highlight>iterable</highlight>, you can use the <highlight>delete</highlight> function.
<br><br>
<p class="code">
delete obj index
? removes item at index from obj, obj is predefined
</p>
</p>
<h2 id="file-algs">
Reading and Writing Files
</h2>
<p>
Synt allows you to access local files on your computer.
This could be helpful to create cache for next run or to save data.
<br><br>
Synt can read and write files.
</p>
<h3 id="read-alg">
Reading a File
</h3>
<p>
To read a file, you can use the <highlight>read</highlight> function.
Just note that the file should exists.
<br><br>
<p class="code">
var text data
read data "file.txt"
? reads "file.txt" and stores it in data
</p>
</p>
<h3 id="write-alg">
Writing a File
</h3>
<p>
To write a file, you can use the <highlight>write</highlight> function.
If file does not exist, it will be created.
If file does exist, it will be overwritten.
<br><br>
<p class="code">
write "file.txt" data
? writes data to "file.txt"
</p>
</p>
<h2 id="time-algs">
Synt Time and Ticking
</h2>
<h3 id="synt-ticking">
Ticks in Synt
</h3>
<p>
Synt has a customizable <highlight>tick system</highlight> that allows using and calculating time slightly easier.
One tick is equal to one millisecond.
Ticks can be reset, paused and resumed.
It can also be set to a specific value.
</p>
<h3 id="synt-time">
Time in Synt
</h3>
<p>
Synt also has a <highlight>time system</highlight>.
This system can not take any inputs.
It is made only for outputs.
It isn't affected by ticks.
</p>