r/ada • • 1d ago

New Release ANN: Ada syntax analyzer v1.1

The current version provides a full Ada 2022 syntax analyzer library. The analyzer parses the source and creates the syntax tree and cross reference of defining identifiers in the source. Both structures are allocated in an arena pool storage and can be released as a whole. The code source can be file, stream or a user-defined container implementing multi-line source interface. Unicode is fully supported as well as Unicode identifiers normalization checks.

https://www.dmitry-kazakov.de/ada/ada_syntax_analyzer.htm

Changes to the preious version:

  • Get_Source_Description function was added to the cross-reference of contexts;
  • Context table of contents was added for fast search of defining identifiers. The function Find was added for the purpose;
  • Declaration context contains a reference to the node that contains it;
  • Accept statement has operation to get the declaration context of the task body it nested in;
  • The task body node has the list of all nested accept statements;
  • Conflicting declarations that cannot be overloaded are now detected and reported as errors;
  • Nodes enumeration type reordered for easier classification;
  • The function Find was added to find directly visible defining identifiers;
  • The procedures Pop and Push were added to push and pop defining identifiers onto the argument stack.
10 Upvotes

2 comments sorted by

1

u/AzulithLDA 1d ago

How does it differ from Libadalang?

2

u/Dmitry-Kazakov 22h ago

It is a totally unrelated project meant to illustrate the parsing framework. Redesigned (from MACRO-11) in Ada 95 in 2004, with an Ada expressions parser on to of it. Recently I decided to upgrade it to full Ada 2022 with all bells and whistles, mainly for fun.

It is a self-contained library written in pure Ada 95 that does not require anything else. And in no way Python, C, scripting or executables are involved.

It does not do full semantic analysis. Nor does it implement ASIS. There are subprograms for finding defining identifiers in declaration contexts and there is a cross-reference searchable by source location and/or names. That is all.

I do not know Libadalang enough but since it is claimed to support semantic queries, it should use the Ada standard library in some form or another, e.g. the package Standard at least.

I am considering an interface of a compiler-independent Ada library to keep artefacts of compilation units. But this is a lot of work, and before that done, no further semantic queries are possible.