Menu

HAC Ada Compiler / News: Recent posts

HAC v0.41

🆕 Changes in this release:

  • Improved some compilation diagnostics.
  • Improved support for the String type.
  • Added the 25 Advent of Code 2024 solutions as examples and regression tests (now 122 in total).
  • Added new demos that output PDF files.
Posted by Gautier de Montmollin 2025-03-15

HAC v0.40

  • Source stream is buffered: ~3x faster build on large sources
  • HAT: added Create_Directory, Create_Path and Delete_Directory
  • Added warning on variables read before they are written
Posted by Gautier de Montmollin 2024-10-12

HAC v.0.30

  • New target: HAC_Sys.Targets.AMD64_Windows_Console_FASM (embryonic, but produces a "hello world" executable)
  • New target: HAC_Sys.Targets.Semantics for a smart editor (e.g. LEA) with helpers for auto-complete and navigation to declarations and bodies.
  • New compilation diagnostics: warnings and notes.
  • Added 25 new regression tests (Advent of Code)
  • Several fixes
Posted by Gautier de Montmollin 2024-03-21

HAC v.0.26

  • You can use a loop's name for the exit statement: exit Loop_Name.
  • You can exit multiple, nested, loops, by using exit Loop_Name.
  • Ada semantics are better verified:
    • Array indexing (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).
    • Separation between Type and Subtype declarations (anonymous types are allowed only in the few cases foreseen by the language).
    • Operators of the HAT package (+, -, & 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

Posted by Gautier de Montmollin 2023-07-08

HAC v.0.21

  • Added Virtual Machine Variables, another mean for exchanging data between the HAC program and the program hosting the VM.
  • SmallAda's tasking is working again in its HAC reincarnation - at least, for some simple tasks.
  • HAL becomes HAT (HAC Ada Toolbox), to avoid name collision with HAL = "Hardware Abstraction Layer".
Posted by Gautier de Montmollin 2022-09-24

HAC as an embedded compiler

New blog post titled "HAC as an embedded compiler" here.

Posted by Gautier de Montmollin 2022-07-11

HAC v.0.2

  • A program run by HAC can exchange data with the program running HAC, through dynamically registered call-backs

    • see package HAC_Sys.Interfacing and demos:
      src/apps/exchange_native_side.adb
      src/apps/exchange_hac_side.adb
  • The compiler performs more compile-time range checks and optimizes away useless run-time checks when it is safe to do so.

Posted by Gautier de Montmollin 2022-06-27

HAC v.0.11

  • Check if all cases are covered in a CASE statement (required by Ada standard)
  • Added compile-time range checks
  • Added VM instructions that do the work of two or more other instructions
  • Search and handling of WITH-ed sources is abstracted; source streams don't need to be files
  • Command-line tool (hac[.exe]) has now a source search path via a new -I option and another one through the ADA_INCLUDE_PATH environment variable
Posted by Gautier de Montmollin 2022-06-19

HAC v.0.1

HAC (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:

  • packages and subpackages are now supported
  • modularity: packages and subprograms can be standalone
    library units, stored in individual files with
    GNAT's naming convention, and accessed from other units
    via the WITH clause
  • validity checks were added for a better detection of
    uninitialized variables.... read more
Posted by Gautier de Montmollin 2022-05-14

HAC v.0.0996

Main improvements since v.0.095:

  • range checks on discrete subtype assignment (:=) and conversion
  • short-circuit logical operators: "and then", "or else"
  • for S = Scalar subtype: S'First, S'Last, S'Succ, S'Pred, S'Pos, S'Val, S'Image, S'Value, S'Range attributes
  • for A = array object or array subtype: A'First [(N)], A'Last [(N)], A'Range [(N)], A'Length [(N)] attributes
  • "&", "<", ">", "=", "/=" operators defined for the String type (additionally to HAL.VString type)
  • CASE choices admit ranges
  • forward declarations for subprograms... read more
Posted by Gautier de Montmollin 2022-01-22

HAC 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

Posted by Gautier de Montmollin 2021-04-07

HAC v.0.09

  • with and use context clauses are parsed properly (no more "placebo" parsing)
  • use can be a local definition and has its real effect.
  • HAC_Pack becomes HAL (HAC Ada Library)
Posted by Gautier de Montmollin 2021-01-10

HAC v.0.085

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

Posted by Gautier de Montmollin 2021-01-10

Advent of Code 2020 with HAC and LEA

A screenshot of HAC in action (via the LEA editor) for the Advent of Code:

More details here.

Posted by Gautier de Montmollin 2020-12-02

HAC v.0.076

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

Posted by Gautier de Montmollin 2020-12-02

HAC v.0.07 - Exceptions and trace-backs

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

Posted by Gautier de Montmollin 2020-06-03

Ann: HAC v.0.06 - Text File I/O

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;
Posted by Gautier de Montmollin 2020-06-03

HAC v.0.05 - Type VString (variable-size string)

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
Posted by Gautier de Montmollin 2020-05-07

HAC v.0.03

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
Posted by Gautier de Montmollin 2020-04-17

New HAC snapshot uploaded (2018-04-17)

Some effort has been put to stabilize the compiler when confronted to erroneous code.

Posted by Gautier de Montmollin 2018-04-17
MongoDB Logo MongoDB