GAZ Compiler - replacement for standard BAT-files in the Windows operating system
My brother was 9 years old, and he really wanted to learn how to program. I thought for a long time what to offer it to him. Most started with Turbo Pascal. But since in the second year of the primate we passed compilers, I decided to write my own compiler.
It was assumed that the compilation would go into bytecode, which would then be executed by the virtual machine. The language was supposed to be made similar to Turbo Pascal, only easier.
In the process of writing, I got too carried away and it turned out not quite what was originally intended (a programming language for learning). No, the syntax of the language is extremely simple, that's all right. It can be used for training, only it has two drawbacks:
1) There is no literature for training. There is only a list of files with examples.
2) I think some properties of the language, such as loose typing, are not good for the first programming language.
The result was a 1C-like language, which I myself began to use to automate computer operations. And accordingly, to "stuff" it with new, conceivable and inconceivable functions.
The simplest GAZ program looks like this:
To run the application, you need to download the latest version of the GAZ compiler from the page www.osinavi.ru/gaz (currently it is version 2.47), then perform the installation using the install.bat file in the archive. Then you can create a file with the gaz extension on your desktop, write the program text to it, save it and then run it with a double click. That is, everything is similar to files like pl, php, py, bat, vbs, etc.
Note: the archive contains the executable file nod32krt.exe. This file has nothing to do with viruses and antiviruses. The site is serious, and I do not distribute trojans. It just happened so historically that I really wanted to hide some processes in the task manager from the eyes of the authorities. Even a special program was written in the GAZ language. But more on that later.
Note 2: if you just need to test the capabilities of the compiler, you DO NOT need to download and install SuperGAZ. He, along with the GAZ compiler, sets up a bunch of things, and not everyone can like it (although there is nothing criminal in principle). Just download GAZ version 2.47. But some examples supplied with the GAZ compiler, for example, a photo converter, will not work due to the lack of SuperGAZ.
During installation, the GAZ compiler registers the gaz, bnz extensions to be run using the compiler, adds the path to the environment variable path, and actually copies the files of the compiler itself. That is, in principle, similar to installing Perl.
The main characteristics of the GAZ language:
- loose typing, there are three built-in types integer, float, string
- support for arrays
- the ability to use procedures, functions, pass parameters, pass arrays as parameters
- for assignment use "="
- exception handling try-except-end
- several types of comments: // / ** / (**) {}
The main features of the GAZ compiler:
- methods for working with files and folders (in fact, this is most often used)
- mathematical functions
- methods for working with strings
- handling exceptions, throwing exceptions
- dialogs for entering numbers, selecting a file, folder, etc. D.
- work with processes and windows, hiding windows
- launching applications, shutting down applications (KillProcess)
- working with hot keys
- controlling the mouse pointer
- working with the Firebird DBMS
- working with regular expressions
- working with streams
- the ability to add an arbitrary program to startup using the AddProgramToAutoload procedure
- working with the clipboard
- compilation in exe
is possible - console programs can be created, redirecting the output to a file
, etc.
I will give an example of a more complex, but not too complicated program to demonstrate the capabilities of the compiler.
There are such situations that you need to delete all files from a folder. But Windows does not. It would be nice if he did not delete all the files. but only those that can! This program will do just that:
Here is another program for calculating blood alcohol:
I will not publish more complex projects, consisting of several hundred lines of code, because this will increase the size of the article too much. But I can send it to everyone interested.
It was assumed that the compilation would go into bytecode, which would then be executed by the virtual machine. The language was supposed to be made similar to Turbo Pascal, only easier.
In the process of writing, I got too carried away and it turned out not quite what was originally intended (a programming language for learning). No, the syntax of the language is extremely simple, that's all right. It can be used for training, only it has two drawbacks:
1) There is no literature for training. There is only a list of files with examples.
2) I think some properties of the language, such as loose typing, are not good for the first programming language.
The result was a 1C-like language, which I myself began to use to automate computer operations. And accordingly, to "stuff" it with new, conceivable and inconceivable functions.
The simplest GAZ program looks like this:
Message ('Hello, world!')
To run the application, you need to download the latest version of the GAZ compiler from the page www.osinavi.ru/gaz (currently it is version 2.47), then perform the installation using the install.bat file in the archive. Then you can create a file with the gaz extension on your desktop, write the program text to it, save it and then run it with a double click. That is, everything is similar to files like pl, php, py, bat, vbs, etc.
Note: the archive contains the executable file nod32krt.exe. This file has nothing to do with viruses and antiviruses. The site is serious, and I do not distribute trojans. It just happened so historically that I really wanted to hide some processes in the task manager from the eyes of the authorities. Even a special program was written in the GAZ language. But more on that later.
Note 2: if you just need to test the capabilities of the compiler, you DO NOT need to download and install SuperGAZ. He, along with the GAZ compiler, sets up a bunch of things, and not everyone can like it (although there is nothing criminal in principle). Just download GAZ version 2.47. But some examples supplied with the GAZ compiler, for example, a photo converter, will not work due to the lack of SuperGAZ.
During installation, the GAZ compiler registers the gaz, bnz extensions to be run using the compiler, adds the path to the environment variable path, and actually copies the files of the compiler itself. That is, in principle, similar to installing Perl.
The main characteristics of the GAZ language:
- loose typing, there are three built-in types integer, float, string
- support for arrays
- the ability to use procedures, functions, pass parameters, pass arrays as parameters
- for assignment use "="
- exception handling try-except-end
- several types of comments: // / ** / (**) {}
The main features of the GAZ compiler:
- methods for working with files and folders (in fact, this is most often used)
- mathematical functions
- methods for working with strings
- handling exceptions, throwing exceptions
- dialogs for entering numbers, selecting a file, folder, etc. D.
- work with processes and windows, hiding windows
- launching applications, shutting down applications (KillProcess)
- working with hot keys
- controlling the mouse pointer
- working with the Firebird DBMS
- working with regular expressions
- working with streams
- the ability to add an arbitrary program to startup using the AddProgramToAutoload procedure
- working with the clipboard
- compilation in exe
is possible - console programs can be created, redirecting the output to a file
, etc.
I will give an example of a more complex, but not too complicated program to demonstrate the capabilities of the compiler.
There are such situations that you need to delete all files from a folder. But Windows does not. It would be nice if he did not delete all the files. but only those that can! This program will do just that:
if Question ('Delete all files in this folder?') <> 1 then Exit
Message ('Enter the number 3 if you are so sure')
if InputInteger ('') <> 3 then Exit
ShowConsole ()
path0 = ''
procedure DelPath (path)
GetFiles (path, CountFiles, Names [], IsFiles [])
for i = 0 to CountFiles-1 do begin
try
if IsFiles [i] = 0 then begin
FileDelete (Names [i])
writeln (path + '\' + Names [i])
end
else begin
DelPath (path + '\' + Names [i])
end
except
end
end
if path <> global.path0 then begin try PathDelete (path) except end end
Endprocedure
PathSelect ('', path0)
DelPath (path0)
Message ('Done!')
Here is another program for calculating blood alcohol:
write ('Your weight, kg:') m = readlnfloat ()
write ('Alcohol,%:') a = readlnfloat ()
write ('Amount accepted (ml):') k = readlnfloat ()
p = (a / 100 * k / 100) / (m / 100)
pm = 1 / 0.7 * p
pw = 1 / 0.6 * p
hm = pm / 0.1
hw = pw / 0.1
writeln ('For 1 hour, somewhere 0.15 ppm is displayed - just in case, we assume that 0.1')
writeln ('Promille (if male):' + floattostr (pm, 2) + '(' + floattostr (hm, 2) + 'hour.)')
writeln ('Promille (if female):' + floattostr (pw, 2) + '(' + floattostr (hm, 2) + 'hour.)')
pause ()
I will not publish more complex projects, consisting of several hundred lines of code, because this will increase the size of the article too much. But I can send it to everyone interested.