Synt Docs
General
What is Synt?
Synt is a
Synt is
For the history of Synt, it was initiated by
Examples
Hello Synt
output "Hello Synt!"
Create Variables
var number my_num1 0
Add Numbers
var number my_sum 0 add my_sum 10 20 30 40 50 60
Variable Referencing
var text name "Synt" output "Hello #name#!!! Welcome Back!!!"
Installation
Synt is created in a way so that it can be run in any systems.
However, the major focus is for
This section is focussing to install synt on
For other platforms you need to have
Download Synt
Download
Move to Path
Installing Synt just means moving it to the
Generally, for
Suggested Synt Folder:
Add to Path
Although you might have installed synt in the
A simple solution is to add the
First of all, copy the
Synt is now globally added to
Modes
On using Synt without console arguments, it asks you for modes.
Synt has two major running modes.
File Mode
To run an existing code using
This mode can be also accesed from directly passing
synt *f
synt *file
synt "main.synt"
Interactive Mode
The mode key is
synt *i
synt *interactive
Compile Mode
The mode key is
synt *c "main.synt"
synt *compile "main.synt"
Quit Mode
The mode key is
synt *q
synt *quit
SPyC Mode
The mode key is
synt *spyc "main.synt"
SPyC Run Mode
The mode key is
synt **spyc "main.synt"
Learn Synt
What is Console?
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.
How Synt Reads Code?
First, obviously, Synt gets the code it needs to run.
This code can also be called as
Then, Synt breaks the code into
Synt uses these blocks and tokens to recognize and execute corresponding commands and code.
Synt runs
Commenting in Synt
There are three
General Comments
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.
comment This is a comment. This will be ignored in execution.
$ This is a comment. This will be ignored in execution.
Info Comments
This type of comment is used to
? This is a query comment. This will be ignored in execution.
Command Comments
This type of comment is used when using an
> This is an AI command comment. If any AI or mod installed, this might do something. > It won't do anything in execution.
Basic Algorithms of Synt
There are a few basic functions or so called
Version
This function just outputs the
version
End
This function just ends/pauses the execution of synt.
end
Output
This function outputs the
output "Hello Synt!"
Input
This function is slightly more complex than the
input input_var "Enter your input:"
Dynamic Programming in Synt with Variables
What is a Variable in Synt?
Synt allows your program to be more
Different Types of Variables
Synt offers a few types of basic
A
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 [
Making a Variable
To make a variable, you can use the
var type var_name "var_value!"
Using a Variable
To use a variable, you can use the
output "Use a variable like #var_name#"
Using an Item in a Collection
To get an item from a collection, first refer collection as a variable and then mention the
output "Lets say collection coll_name has item #coll_name#<0> and #coll_name#<1>!"
Avoiding Redundancy in Synt with Functions
Repitition of code is a
Declaring a Function
A
Making a Function
alg func_name argument_collection {
Using a Function
After the function is defined it can be called simply by using the
func_name
Proper Syntax for a calling a custom Function in Synt
func_name return_variable arg1 arg2 ...
Returning a Value from a Function
To return a value from a function, use the
alg func_name argument_collection {
Synt Mathematical Operations
Synt allows user to perform some simple and complex mathematical operations on numbers, decimals, texts and other types.
Adding Numbers
To add two numbers, use the
add output_variable 2 3 ? this sets output_variable to 5
Subtracting Numbers
To subtract two numbers, use the
subtract output_variable 2 3 ? this sets output_variable to -1
Multiplying Numbers
To multiply two numbers, use the
multiply output_variable 2 3 ? this sets output_variable to 6
Dividing Numbers
To divide two numbers, use the
divide output_variable 6 3 ? this sets output_variable to 2
Power
To get the power of a number, use the
power output_variable 2 3 ? this sets output_variable to 8
Conditional Programming with Synt
In many cases, you may want to perform some action based on some condition.
Synt provides a way to do this with conditional programming.
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.
Check and Return
To check if a condition is true or false, use the
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
Check and Perform
To perform an action if a condition is true or false, use the
condition compare_var_1 check_operation compare_var_2 {
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
All Conditional Operations
Here's the list of all the conditional operations that can be used with
"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 !%_
Special Characters
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.
Here's the list of special characters that can be used in Synt:
#NEWLINE '\n' #INDENT '\t' #BACKSPACE '\b' #START '\r' #SPACE ' ' #LEFTSQUARE '[' #RIGHTSQUARE ']' #LEFTCURLY '{' #RIGHTCURLY '}' #COMMA ',' #DOT '.' #SEMICOLON ';' #COLON ':' #EQUAL '=' #HASH '#' #QUESTION '?' #EXCLAMATION '!' #QUOTE '"' #APOSTROPHE "'"
Repitition and Looping Code
When some code or function is needed to repeated
To make the writing of such code easier, Synt also allows another common feature in programming languages called
In Synt, there are two types of loops.
One is
Loops that are
Loops that are
Statically Repeating Loops
The
alg func args {
Dynamically Repeating Loops
The
? count down
var number cd 10
var binary do_it
alg func args {
Functions for Collections and Other Iterables
Iterables are the variable types that are made up of multiple values.
These include
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.
Length of an Iterable
To get the
var number len count len obj ? returns the length of obj, obj is predefined
Inserting an Item to an Iterable
To insert an
insert obj item index ? inserts item into obj at index, obj is predefined
Removing an Item from an Iterable
To remove an
remove obj item limit ? removes item from obj, obj is predefined, removes limit amount of item
Removing an Item at Given Index from an Iterable
To remove an
delete obj index ? removes item at index from obj, obj is predefined
Reading and Writing Files
Synt allows you to access local files on your computer.
This could be helpful to create cache for next run or to save data.
Synt can read and write files.
Reading a File
To read a file, you can use the
var text data read data "file.txt" ? reads "file.txt" and stores it in data
Writing a File
To write a file, you can use the
write "file.txt" data ? writes data to "file.txt"
Synt Time and Ticking
Ticks in Synt
Synt has a customizable
Time in Synt
Synt also has a
Resetting Ticks
To reset ticks, you can use the
reset_tick ? resets ticks
Pausing Ticks
To pause ticks, you can use the
pause_tick ? pauses ticks
Resuming Ticks
To resume ticks, you can use the
resume_tick ? resumes ticks
Getting Ticks
To get ticks, you can use the
var number this_tick get_tick this_tick ? returns ticks and stores it in this_tick
Handling Running Console with Synt
When Synt is unable to do something directly, you might think to access console to run it through other means. This is possible because Synt has the ability to access the console it is being run on. You can also use console commands to change the other console properties.
Run Console Commands
Synt has a
console "command" ? runs "command" in console
Clearing Console
To clear the console, you can use the
clear ? clears console
Debugging in Synt
Synt has an useful set of
Get Variable Type
To get the type of a variable, you can use the
var number this_number var text type info type this_number ? returns type of this_number and stores it in type
Continuing Program after Error
To continue the program after an error, you can use the
restore ? continues program after error
Custom Error Messages
To create a custom error message, you can use the
error "message" ? displays error with "message" as content
Custom Warning Messages
To create a custom warning message, you can use the
warn "message" ? displays warning with "message" as content
Modules and External Resources
Sometimes you want to organize your code in modules or other files that need to be run. Synt allows you to import and run modules. When you import a module, it will run the code in the module. If there are any custom functions in the module, they will be available in the main file and while running in other modules that will be imported orderwise next.
Importing Local Files as Modules
To import a local file as a module, you can use the
module "module_name" ? imports file "module_name.synt" as module and runs it