🆕 Changes in this release:
exit statement: exit Loop_Name.exit Loop_Name.(i)(j) (array of array) and (i, j) (multi-dimensional array) are no more treated as equivalent (this feature was a remnant of the Pascal syntax).+, -, & for strings) are visible without prefix only in the scope of a use HAT clause.Note that correct Ada programs, in relation to the above points, were already accepted and parsed correctly by HAC before that change.... read more
New blog post titled "HAC as an embedded compiler" here.
A program run by HAC can exchange data with the program running HAC, through dynamically registered call-backs
The compiler performs more compile-time range checks and optimizes away useless run-time checks when it is safe to do so.
-I option and another one through the ADA_INCLUDE_PATH environment variableHAC (HAC Ada Compiler) is a quick, small, open-source Ada
compiler, covering a subset of the Ada language.
HAC is itself fully programmed in Ada.
Main improvements since v.0.0996:
Main improvements since v.0.095:
The main improvement is the modularity: HAC recursively compiles all units needed to build a main program.
Currently only procedures and functions bodies are supported as units - no packages yet, no separate specifications.
An example can be found in exm/unit_a.adb
A screenshot of that example:
... read more
with and use context clauses are parsed properly (no more "placebo" parsing)use can be a local definition and has its real effect.HAC (HAC Ada Compiler) is a small, quick, open-source Ada compiler,
covering a subset of the Ada language.
HAC is itself fully programmed in Ada.
Web site: http://hacadacompiler.sf.net/
Source repository #1: https://sf.net/p/hacadacompiler/code/HEAD/tree/
Source repository #2: https://github.com/zertovitch/hac
Improvements:
HAC_Integer (internal name in HAC_Sys.Defs), i.e. HAC's Integer
type, is now 64 bit.
HAC_Float (i.e. Real in HAC programs) has now System.Max_Digits
digits accuracy.
Added range constraints, like: subtype Answer_Range is Character
range 'a' .. 'z'.
Added membership test, like: x [not] in a .. b.
Several additions to HAC_Pack.
Better I/O error handling.
The whole system (Compiler and VM run-time) builds on both
GNAT and ObjectAda64.... read more
Changes since v.0.07:
0.071
Discrete type range is stored in type definition; "subtype T1 is T2;"
0.072
Subtype_Indication (e.g. "for B in Boolean loop", "array (States) of Prob")
https://gautiersblog.blogspot.com/2020/06/hac-v0072-subtype-indication.html
0.073
The VM can be aborted via the Feedback procedure
0.074
Types: Time and Duration
0.075
Added Ada.Calendar-like functions
https://gautiersblog.blogspot.com/2020/10/hac-v0075-time-functions-goodies-for.html... read more
Errors are now propagated by HAC, as expected, down the call stack.
You get by default a detailed trace-back, like the following one. HAC's output is:
HAC VM: raised Constraint_Error
Out of range
Trace-back locations:
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift.Shift_n_add at line 18
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift at line 23
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift.Shift_n_add at line 16
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift at line 23
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift.Shift_n_add at line 16
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift at line 23
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift.Shift_n_add at line 16
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift at line 23
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift.Shift_n_add at line 16
exception_04.adb: Exception_04.Nest.NTF.Add_n_shift at line 23
exception_04.adb: Exception_04.Nest.NTF at line 27
exception_04.adb: Exception_04.Nest at line 34
exception_04.adb: Exception_04 at line 42... read more
As in the title!
An example here (exm/file_copy.adb):
with HAC_Pack; use HAC_Pack;
procedure File_Copy is
s : VString;
f1, f2 : File_Type;
begin
Open (f1, "file_copy.adb");
Create (f2, "file_copy.txt");
while not End_Of_File (f1) loop
Get_Line (f1, s);
Put_Line (f2, s);
end loop;
Close (f1);
Close (f2);
end File_Copy;
Recent changes:
| Rev. | Ver. | Fix? | Fix or improvement | Details, remarks | Date |
|---|---|---|---|---|---|
| 130 | Support for "Label: loop .. end loop Label;" | 18.04.2020 | |||
| 138 | Enumerated types can be used for CASE statements | 22.04.2020 | |||
| 160 | 0.04 | Added VString (variable-size string) | 02.05.2020 | ||
| 161 | 0.041 | VString: concatenation with "&" | 02.05.2020 | ||
| 163 | 0.042 | Command-line arguments | Argument_Count, Argument (the latter returns a VString) | 02.05.2020 | |
| 164 | 0.043 | VString: added comparison operators, Element, Length, Slice | 03.05.2020 | ||
| 168 | 0.044 | VString: added Index, "*", Trim; added Get_Env and Set_Env | 04.05.2020 | ||
| 171 | VString: added Shell_Execute, Index (VString, String), Image, Integer_Value, Float_Value | 06.05.2020 | |||
| 172 | 0.05 | VString: Get_Line | 06.05.2020 |
Recent changes:
| Rev. | Ver. | Fix? | Fix or improvement | Details, remarks | Date |
|---|---|---|---|---|---|
| 92 | Implemented first explicit type conversion (Integer to Float) | 31.03.2020 | |||
| 101 | Fix | Evaluation of enum values in arrays and records was wrong | 04.04.2020 | ||
| 104 | Fix | Unary minus for float values (was ignored) | Added opcode: k_Unary_MINUS_Float | 04.04.2020 | |
| 108 | HAC's default floating-point type is now double-precision and is called Real | Internal name in the HAC system: type HAC_Float is digits 15; | 05.04.2020 | ||
| 110 | HAC is now forbidding type coercion (implicit type conversion) | Coercion was only int -> float | 06.04.2020 | ||
| 112 | Test program HAC_Test is now THE command-line tool around HAC: HAX | 08.04.2020 | |||
| 120 | Support for typed constants | 12.04.2020 | |||
| 121 | Read-only mode for typed constants, "in" parameters, "for" loop variables | 12.04.2020 | |||
| 123 | Fix | Enumeration literals begin with position 0 (was 1) | 13.04.2020 | ||
| 124 | Enumerated types can be used for FOR control variables | 13.04.2020 | |||
| 128 | Fix | Only jump instructions are patched after IF or LOOP statements | 16.04.2020 | ||
| 129 | 0.03 | "Assembler" dump | From command-line: hax -a main.adb | 17.04.2020 |
Some effort has been put to stabilize the compiler when confronted to erroneous code.