Menu

Tree [r1118] / trunk /
 History

HTTPS access


File Date Author Commit
 demo 2025-02-03 gdemont [r1079] (demos) Using distinctive name in a variable name
 doc 2025-12-06 gdemont [r1109] (examples) Added Advent of Code 2025, Day 06
 exm 2025-12-20 gdemont [r1116] (examples) Added Advent of Code 2025, Day 11
 obj 2020-12-08 gdemont [r312] Added Get (S : out String) and Get (File : File...
 src 2026-01-31 gdemont [r1118] (parser) Added a compile-time range check
 test 2025-12-20 gdemont [r1116] (examples) Added Advent of Code 2025, Day 11
 build.cmd 2024-12-09 gdemont [r1035] (examples) Added Advent of Code 2024, Day 09; m...
 debug.pra 2017-11-25 gdemont [r47] Improvement in the GNAT project file
 fast.cmd 2024-12-09 gdemont [r1035] (examples) Added Advent of Code 2024, Day 09; m...
 hac.gpr 2025-10-06 gdemont [r1097] (GNAT project file) Commented out `-f*-sections...
 hac_objectada.prj 2024-03-12 gdemont [r972] Updated ObjectAda project file
 profiling.cmd 2024-12-09 gdemont [r1035] (examples) Added Advent of Code 2024, Day 09; m...
 readme.md 2025-07-30 gdemont [r1091] (doc) Improved read-me
 save.hac 2024-01-09 gdemont [r954] Clarification around emitting errors/warnings/n...
 save_modif.hac 2025-10-05 gdemont [r1096] RC 0.42
 save_modif_and_untracked.hac 2023-06-24 gdemont [r804] (parser) Type and Subtype declarations are pars...
 small.cmd 2024-12-09 gdemont [r1035] (examples) Added Advent of Code 2024, Day 09; m...

Read Me

HAC - HAC Ada Compiler

HAC is perhaps the first open-source (albeit very
partial) Ada compiler fully programmed in Ada itself.

Complete description in: doc/hac.txt

Command-line flavor:

If you are impatient: in Alire (https://alire.ada.dev/),
do "alr get hac", then "alr run" from the hac* directory.

Alternatively: have GNAT installed (https://www.adacore.com/download),
then, on your preferred command-line interpreter:

  gnatmake -P hac

  cd exm
  ../hac gallery.adb

(if gnatmake doesn't work, try gprbuild;
for Windows, '\' is meant in place of '/' )

Editor / pre-built flavor:

Or, if you don't want to touch the command-line at all for playing
with HAC, you can download and use LEA (http://l-e-a.sf.net/).

Examples

You'll find hundreds of examples in the exm directory and
its subdirectories.

Here is the famous Hello World! File hello.adb:

with HAT;

procedure Hello is
begin
  HAT.Put ("Hello world!");
end Hello;

Another classic example (file fibo.adb):

with HAT;

procedure Fibo is

  function Fibonacci (P : Natural) return Positive is
  begin
    if P <= 2 then
      return 1;
    else
      return Fibonacci (P - 1) + Fibonacci (P - 2);
    end if;
  end Fibonacci;

  use HAT;

begin
  for i in 1 .. 22 loop
    Put_Line (Fibonacci (i));
  end loop;
end Fibo;

Enjoy!

License

HAC is free, open-source and released under the MIT license.

MongoDB Logo MongoDB