Following the implementation of trace-backs in HAC, this feature is now included in the LEA editor.
Better showing an example. Suppose your Ada program has a bug that was not detected at compile-time (it happens sometimes), like an array index being out-of-range. In this case HAC will raise a Constraint_Error exception (as expected from any Ada system).
Once you have closed the message box about the unhandled exception, the message list will display the trace-back, that is the chain of all subprogram calls at the moment the error has happened. Here we have an example with recursive calls, and the error was planted for the moment where the parameter Level is 0. For your comfort, you can click on a line of the trace-back and LEA will find the correct file and the correct line as well!
From now on, LEA has got the uber-gadget: a samples collection. Are you looking for an example to start a script, or an algorithm, or some other inspiration? The menu selection "Actions → Code sample" will offer you a choice of programs of various sizes. Actually, they are examples from the HAC project (the HAC compiler is embedded in LEA). You don't even need to fish those examples in the Internet: they are embedded within LEA as well. In a few clicks, an example will pop in a LEA window and you can run it immediately.
LEA (Lightweight Editor for Ada) is a free, open-source software. It can be found here.
Feedback is appreciated. Don't hesitate to sponsor the project with a small donation (from the link above: "Donate" link).
Enjoy!
New menu entry: Code sample (click to enlarge image)
Today, HAC has a few more functions, from Ada.Calendar. I have added them in order to translate a Windows cmd script to Ada (with HAC_Pack). More precisely, it's "save.cmd", which takes a snapshot of the sources of the HAC system and other key files. This snapshot is a Zip archive and has a time stamp in its name, like "hac-2020-10-20-20-27-36-.zip". Hence the addition of standard functions like Year, Month, etc. The script is very practical for making backups between commits via subversion or git, and for other purposes. Now the script is called "save.adb" and does the same job, but not only on Windows, but also on Linux or other Operating Systems. Since the Zip compression is also programmed in Ada (Zip-Ada), you have in that script example a cool situation of Ada invading your computer 😊.
Here, a screenshot of the added functions running from the LEA editor (hum, also a full Ada software, by the way!):
HAC 0.075 running from LEA. Click to enlarge.
More to come soon with some subprograms stemming from Ada.Directories.
HAC is free and open-source, you can find it here and here.
Perhaps you were already confronted to this problem:
You have "housekeeping" shell scripts for cleaning files, building tools, listing results, etc. .
You would like to have the project, that these scripts are serving, running on multiple systems: Linux, MacOS, Windows, ... Especially for highly portable Ada projects, it is almost a must.
But in the end, you have lots of duplicate scripts: for each script one version for Linux, one version for Windows.
One practical example of script simplification can be found in the Zip-Ada project.
In the test directory, there were test_za.cmd and test_za.sh, meant to do the same thing: testing the compression side of the library. But the scripts were out of sync, and it was a pain to make them converge. So it was a perfect opportunity to switch to HAC, which has since its 0.076 version standard subprograms for file management. The unified script is test_za.adb, can be run with the hac test_za.adb command.
Now test_rz.cmd and test_rz.sh (for testing the Zip archive recompression tool, ReZip) are also unified, and so are make_za.cmd and make_za.sh for building everything.
More generally HAC scripts have tremendous advantages:
They are plain Ada, so there is no need to learn a new language.
If you need it, they can be compiled with an Ada compiler. It can be for different reasons:
You need performance (nested loops, for instance). You'll get C-level performance, at least with the GNAT compiler.
You need more functionalities that are not present in HAC.
You are afraid HAC is not developed or supported further.
Here are a few screenshots:
The screenshots are taken from TeXCAD and LEA - other Ada projects 😏...
wavy green bags contain 1 posh black bag, 1 faded green bag, 4 wavy red bags.
dotted chartreuse bags contain 1 light beige bag.
dark white bags contain 2 dotted white bags.
...
There are hundreds of such rules.
The puzzles involve recursion, which makes them fun.
You can see below HAC at work on the problem, from the LEA editor.
There is also a "full Ada" version. I began with that one, because the current limitations of HAC would have been too time-consuming (in terms of development time) for submitting a solution quickly enough. The limitations are not around recursion, that HAC masters like a big one, but mostly around the enumeration type I/O which is currently non-existent in HAC (v.0.081).
Click to enlarge
Solutions will be soon be posted on the HAC repositories.
A bit of brush-up after our last post about the new modularity features of HAC (the HAC Ada Compiler), we can announce the release of version 0.095.
We have tested since then parameters to units, and the use of functions instead of procedures as units.
All that with the LEA editor, in order to experiment the behaviour of compile-time errors and run-time errors. In contrast to the command-line tool called "hac" where everything is forgotten once the command is run, whatever the outcome, in an integrated editor the compiler needs to close files properly in every case - also on errors, because the editor will open them to show the error locations. Similarily, the builder needs to clear the library information between two builds. The improvements to be made to HAC for a smooth functioning were straightforward. Just a couple of statements to add here and there.
A demo of HAC's current modularity support, in one picture:
Click to enlarge
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.
As a follow-up of another post about converting bash (Linux) or cmd (Windows) scripts to HAC scripts, here is a fresh example.
I needed to improve an existing cmd script for benchmarking compression software, with the possibility of switching various subsets separately: that is re-run this subset of methods, or that other subset, or the full tests (long!), etc.
Of course, if you use a real language instead of command-line interpreter ones, there is an obvious solution: you can define a set and you can programmatically flip the membership switches.
In Ada, it looks like
type Category is ( Reduce_Shrink, Deflate, Deflate_External, BZip2_External, PPMd_External, LZMA_7z, LZMA_3, TAR, Preselection );
cat_set : array (Category) of Boolean;
The good news is that you can run an Ada program exactly like a script by using HAC (the HAC Ada Compiler). That is, it runs immediately (with HAC), and HAC doesn't drop .ali, .o, .bexch, .tmp, .exe files which are too much waste for the sake of running a small script-like job.
Below are screenshots of the quick development of bench.adb using the LEA editor, where you can punch F4 to check eventual errors. If there is one, you get instantly to the offending line / column point.
This script is part of the Zip-Ada project and is very helpful for developing and testing new compression methods.
Some news about the GWindows Ada programming framework, more specifically, the GWindows.Scintilla package.
Scintilla is a powerful text editor widget that is behind, among others, LEA and Notepad++.
The Scintilla notifications work now on 64 bit
platforms. Of course the compatibility is kept for 32 bit, so if you
need to build your application for a 32 bit target, the Scintilla widgets will
continue to work as before.
Method names are now "de-camel-cased". For instance
you have now: "Move_Caret_Inside_View" instead of a cryptic
"MoveCaretInsideView". The naming convention is now consistent with the
rest of the GWindows framework, GNAT's run-time and most Ada libraries.
GWindows can be found on SourceForge here and on GitHub here.
Finally, here is a cute screenshot of the Scintilla sample (gwindows\samples\scintilla\sci_example.adb) running, with its source code shown by LEA - so again, GWindows.Scintilla in action!
- 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.
Package examples and modularity tests have been added. Particularly, a new PDF producer package with a few demos is located in the ./exm/pdf directory.
This version is essentialy a rework of LEA's ergonomy - we had recently the chance of having a group of young first-time programmers and first-time LEA users to test it!
The main addition is the green Build & Run button, which matches a (less intuitive) menu entry and the F9 key.
Click screenshot to enlarge
Another addition is a dedicated box for the "User_Abort" internal Virtual Machine exception, so that the LEA user doesn't take the exception message for an actual error (which would be the case for any other exception).
The new version has two main new features: - Tabs (screenshot below) - LEA doesn't write scilexer.dll as a file; thus, it runs as a portable application (in the sense: you can run it from a read-only drive directly, without installation)
Note for subscribers: if you are interested in my Ada programming articles only, you can use this RSS feed link.
Just as a teaser for the next Advent of Code in 10 1/2 months, we would like to show a few pictures related to last edition. The 25 puzzles, data and solutions can be found here and here. They are programmed with HAC (the HAC Ada Compiler), thus in a small subset of the Ada language. The HAC compiler is very fast, so you run your program without noticing it was ever compiled, which is perfect for completing a programming puzzle.
Day 22 run with HAC (here, embedded in the LEA environment)
However, the program will run substantially slower than compiled with a native, optimizing compiler like GNAT.
This is not an issue for most Advent of Code puzzles, but for some, it is, especially on the later days. Fortunately, changing from HAC to GNAT is trivial (just switch compilers), unlike the traditional reprogramming of Python prototypes in C++, for instance.
The pictures
Day 8's data is a map representing the height of trees. Once the puzzle was solved, I was curious how the forest looked like. Note that different users get different data, so you are unlikely to find a visualisation of exactly your data on the internet.
Day 12's puzzle is a shortest path problem with specific rules and a nice data - a terrain with a hill - which seems designed to trap depth-first-search algorithms into an almost infinite search. The yellowish path is the shortest from the green dot, elevation 'a', to blue dot, elevation 'z'.
The pinkish path is the shortest from the blue dot to any dot with elevation 'a'. Fortunately Dijkstra's algorithm (and perhaps others) allows for such a special criterion regarding the end point.
Click to enlarge
For day 22’s puzzle, a walk on a cube’s surface is involved, so it is helpful to sketch it on a piece of paper, cut it and glue the faces. A banana skin of that puzzle is that the example’s layout may be different from the data’s layout. We slipped on that one and ended up gluing and programming the face-to-face transitions for two layouts…
Click to enlarge
Other Adaists’ solutions, discussions and pictures can be found here and in the "2022 Day x" threads in the same forum.
Note for subscribers: if you are interested in my Ada programming articles only, you can use this RSS feed link.
Today, a topic that is guaranteed frivolous: a new colour theme for LEA (a Lightweight Editor for Ada).
Actually, it is a serious subject if you spend a large share of your time at programming (for work, for fun, or both...). For the theoretically brighter season (spring and summer), some prefer to give up the trendy Dark Side mode (which not so long ago was considered as horribly old-fashioned):
...and use a dark-font-bright-background scheme.
However, the contrast is a bit violent. A convincing and carefully designed low-contrast theme is called Solarized Light (which can be turned, with an astute swap within the same 8-colours palette for base colours, into a dark-backgrounded Solarized Dark). The theme is described here.
The Solarized Light theme is incorporated since today in LEA.
Enjoy!
LEA, a Lightweight Editor for Ada, aims to provide an easy,
script-world-like, "look & feel" for developing Ada projects of any
size and level, while enabling access to full-scale development tools
like GNAT.