Context language and compiler for Windows basically corresponds to versions 1.1 for DOS,
but some changes are present. Of course, absence of fully compatibility with the preceding
version is not good, but all changes are made to correct defects of DOS version.
Direct translation of DOS-versions 1.3 (the most full version of Context language)
to Windows is possible and was partly made, but this translation keep all defects
of DOS-version and make compiler source more complex. Context 2.0 - a new compiler,
but it uses some ideas, realized in DOS versions. Integrated syntax and semantic
analyzer are similar to used in DOS versions 1.0-1.3, but code generator is completely
separated from it. Analyzer produces syntax trees for all functions of program. It
requires more RAM, but today it is unessential.
Version with number 2.01 works in DOS and can be used for performing the first
compilation of Windows versions (2.02-2.12), but in real partly translated
version 1.3 was used.
Changes and additions in language
Using of one name for different global objects are prohibited,
for example, const and global variable can't have same name. Also
keywords can't be used as object names.
Empty blocks are prohibited, if empty block are necessary, it must contain
null operator. This improve program readability.
To organize infinite loop construction do ... end must be used instead of
while TRUE do ... end.
Short circuit boolean evaluation. For example see expression F()=0 | G()=0.
If function F() return zero, function G() not called.
Nongraphic characters in strings and character constants.
Presentations of nongraphic characters consists of tilde (~) and
graphic character. In current version next characters may be used:
~t - horizontal tabulation
~r - caret return
~n - new line
~0 - zero
~C - any other character C, for example, ~~ - tilde
Explicit type conversions. Construction [@]Type(Expression) are used.
In current version only conversions of char to byte, word and int are
Constant expressions may be used as constants
Simple global variables may be initialized
Second assignment operator (:=). It added because using of one
symbol as assignment and comparison is not good
File inclusion facility with include "File_name" directive. include
may appears only at global definitions level, each file are included
in program only once. For example, if file A are included into file B,
and files A and B are included into program, only one copy of file A
appears in program. Unreferenced code and data are eliminated by compiler.
Synonyms. For each object in program second name nay be defined,
for example synonym DWORD word
External functions. Each function from external DLL must be declared
as external DLL_name[.Function_name];
There are no function types, reference to function are assumed
as reference to void
Only direct recursion allowed
There are no build-in assembler
Code generator are relatively primitive
All this limitations are made to simplification of compiler. Future directions:
Base type real
Function types and function references
To produce executable files assembler FASM (www.flatassembler.net)
are used. Compiler was tested with FASM 1.49. Previous versions uses Borland TASM32 and TLINK32. The main
reason of this change is using of freeware product.