Extension for the Alk
programming language. Right now, the following features are present:
- Recognition of files with the
.alk
extension - The option to directly run files with the
.alk
extension, with different options - The output is interpreted, any errors created will be shown directly on the code
- Syntax highlighting
- Auto-update and first install of the files needed to run
Alk
- In order to run an
Alk
file, you can press the run button in the top-right menu and choose the desired option (exhaustive or not).
- You can also run an
Alk
file by right clicking on the active editor and using theAlk
submenu.
- In order to stop a running program you can press the stop button in the top-right menu.
- Or right click on the active editor and use the option from the
Alk
submenu.
- The settings of
Alk
can be accessed using theAlk Settings
options from theAlk
submenu when right clicking. -
- The
Show Command
enables or disables showing the command used to run the algorithm in the output. - The
Metadata
option (equivalent of using-m
as argument in the command line) enables or disables showing metadata in the output. - The
Precision
option (equivalent of using-p "x"
, where"x"
is a number, as arguments in the command line) sets the precision that will be used when running the algorithm. - The
Input
options (equivalent of using-i "x"
, where"x"
is either the path of the input file or a string containing variable-value assignments) allow the use as input of either of file or a configuration directly written in the interface. TheInput Active
option must be checked if the algorithm to be executed has an input state.
To create input directly from the interface first thetext
option must be choosen inInput Mode
, and then key-value pairs can be added, removed and modified in theInput Text
setting.
To use a file as input first thefile
option must be choosen inInput Mode
, and then the name of the file must be entered in theInput Path
setting.
- The
Read the reference manual to review the Alk syntax. Also consider the Alk-by example wiki to understand how Alk behaves in real-scenarios.
If you want to also run the Alk
interpreter from the command line, it is strongly recommended to include the folder Linux_Mac
or Windows
in the PATH environment variable.
This allows you to call the the interpreter without mentioning the path to its location.
Note that in the following instructions, [ALK-PATH]
is a placeholder for the actual place where Alk
is.
In order to find the [ALK-PATH]
needed below, you can run an Alk
program through the extension with the Show Command
option enabled from the setting, and you will see the full path to the alki.sh
of alki.bat
script.
-
Linux/Mac OS:
export PATH=[ALK-PATH]/bin:$PATH
Note that this will set the PATH only for the current shell. Opening another shell will not have Alk set in PATH. For the change to be persistent, use:
echo 'PATH=[ALK-PATH]/bin:$PATH' >> ~/.bashrc
To test if it works, the following command can be ran:
alki.sh -h
-
Windows
- Search for
Edit the system environment variables
- Open the
System Properties
window and pressEnvironment variables...
- Select in the bottom grid (
System variables
) thePath
variable and pressEdit...
- Press
New...
- For
Variable name
putAlk
, and forVariable value
put[ALK-PATH]
To test if it works, the following command can be ran:
alki -h
- Search for
- First, you must create a file with the
.alk
extension. You can do that directly from Visual Studio Code, or from Windows Explorer.
- After creating the file, you can start typing the code for your program in it. For this example we will use a simple "Hello world" printing program.
- Now you will need to save the file. To to this you can either press
Ctrl + S
or manually go toFile -> Save
in Visual Studio Code. Any modifications made to the file will not be taken into consideration when running the program if you don't save!
- This program doesn't need any input, so you will need to make sure that all kinds of input are disabled in the settings. You can open the settings by right-clicking anywhere in the editor and clicking
Alk -> Alk Settings
.
- The settings for a program without input should look like this:
- Now that you made sure that the settings are ok, the settings tab may now be closed and you can now run the program by right-clicking anywhere in the editor and clicking
Alk -> Run Alk
, or by clicking the run button in the top-right corner of Visual Studio Code.
- The first steps are similar to the previous example, but now a different program will be used. This program will print the sum of
a
andb
, which will be provided from the input source. After configuring the input in the settings, running the program is the same as in the last example.
- Now you will need to go to settigs, and enable
Initial State
- Using the input from the settings
You will need to selectText
forInitial State Mode
, and you can start adding assignments in theInitial State Mode: As Text
setting.
To add a new assignment, you need to click onAdd Item
, and when you are done you need to click onOk
or pressEnter
.
- Using a file as input
First, you will need to create an input file. For this example a file namedinput.in
will be used. To create it, follow the same steps for creating a file from the first example. Inside the file, you can write all the assignments you need. After writing them, don't forget to save the file!
Now you will need to selectFile
forInitial State Mode
, and input the name of the file in theFile Path
option.