{"id":13410272,"url":"https://github.com/AdaCore/libadalang","last_synced_at":"2025-03-14T15:32:30.743Z","repository":{"id":37458234,"uuid":"47627172","full_name":"AdaCore/libadalang","owner":"AdaCore","description":"Ada semantic analysis library.","archived":false,"fork":false,"pushed_at":"2024-10-29T10:38:50.000Z","size":31890,"stargazers_count":146,"open_issues_count":15,"forks_count":42,"subscribers_count":40,"default_branch":"master","last_synced_at":"2024-10-29T12:36:14.138Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.adacore.com","language":"Ada","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AdaCore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-08T14:28:22.000Z","updated_at":"2024-10-29T10:39:14.000Z","dependencies_parsed_at":"2024-02-29T12:46:02.048Z","dependency_job_id":"26d2cd60-1a20-4204-949a-9e52772e3195","html_url":"https://github.com/AdaCore/libadalang","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaCore%2Flibadalang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaCore%2Flibadalang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaCore%2Flibadalang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaCore%2Flibadalang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdaCore","download_url":"https://codeload.github.com/AdaCore/libadalang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243600767,"owners_count":20317330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:05.933Z","updated_at":"2025-03-14T15:32:29.173Z","avatar_url":"https://github.com/AdaCore.png","language":"Ada","funding_links":[],"categories":["Libraries"],"sub_categories":["Parsers, Scanners, Linters, Analysers, Interpreters and Prettyprinters"],"readme":"Libadalang\n==========\n\nLibadalang is a library for parsing and semantic analysis of Ada code. It is\nmeant as a building block for integration into other tools. (IDE, static\nanalyzers, etc.)\n\nLibadalang provides mainly the following services to users:\n\n* Complete syntactic analysis with error recovery, producing a precise syntax\n  tree when the source is correct, and a best effort tree when the source is\n  incorrect.\n\n* Semantic queries on top of the syntactic tree, such as, but not limited to:\n  * Resolution of references (what a reference corresponds to)\n  * Resolution of types (what is the type of an expression)\n  * General cross references queries (find all references to this entity)\n\nLibadalang does not (at the moment) provide full legality checks for the Ada\nlanguage.  If you want such a functionality, you’ll need to use a full Ada\ncompiler, such as GNAT.\n\nWhile it can be used in Ada (2012+) and Python (3.9 or Python 3.10) Libadalang\nalso provides a low-level C API (meant to write bindings to other languages)\nand an experimental OCaml API.\n\nIf you have problems building or using Libadalang, or want to suggest\nenhancements, please open [a GitHub\nissue](https://github.com/AdaCore/libadalang/issues/). We also gladly accept\n[pull requests](https://github.com/AdaCore/libadalang/pulls)!\n\nStatus of the project\n---------------------\n\nLibadalang is still in development and we allow ourselves some headroom in\nterms of breaking backwards compatibility. If you want to use a stable version\nof Libadalang, you'll need to build from one of the stable branches, such as\n[19.1](https://github.com/AdaCore/libadalang/tree/19.1).\n\nLibadalang currently:\n\n* Is able to parse 100% of Ada 2012 syntax, and presents a well formed tree for\n  it. Support for Ada 2022 constructs is a work in progress.\n\n* Is able to recover most common syntax errors. The error messages are\n  behind those of GNAT, but the recovery will potentially work better in many\n  situations.\n\n* Provides name resolution/navigation.\n\n* Is able to handle some very simple incremental processing. Reparsing a source\n  A and querying xref on a source B that depends on A is handled efficiently.\n\nHow to use Libadalang\n---------------------\n\nThere are several ways to get Libadalang:\n\n* Build it using the [Libadalang Alire\n  crate](https://alire.ada.dev/crates/libadalang).  This will only let you\n  build the current and the previous releases (i.e. not the development\n  version), but is by far the easiest way, as [Alire](https://alire.ada.dev/)\n  automatically deals with dependencies.\n\n* Build it from Git repository sources: install all dependencies, generate its\n  code and to build it. Please refer to the [User\n  Manual](user_manual/building.rst) for detailed instructions.\n\n* **Important**: if you are an AdaCore customer with a GNAT Pro subscription,\n  please get Libadalang through GNATtracker, as this is the only version of\n  Libadalang that is covered by your support contract.\n\nTo learn how to use the API from Libadalang's the development branch, you can\nread the [AdaCore Live\nDocs](http://docs.adacore.com/live/wave/libadalang/html/libadalang_ug/index.html)\n(updated daily).\n\nQuick overview\n--------------\n\nLibadalang has a Python API, for easy prototyping and explorative programming.\nIt ships with an executable named `playground`, that allows you to analyze Ada\nfiles and play with them in an interactive Python console.\n\nGiven the following `main.adb` Ada file:\n\n~~~ada\nwith Ada.Text_IO; use Ada.Text_IO;\n\nprocedure Main is\nbegin\n    Put_Line (\"Hello World\");\nend Main;\n~~~\n\nYou can start the playground on it:\n\n~~~sh\n% playground main.adb\n\n--\n-- libadalang playground\n--\n\nThe file(s) passed as argument have been put into the `u` variable, or units if\nthere are multiple.\n\nEnjoy!\n\nIn [1]: print(u.root.text)\nwith Ada.Text_IO; use Ada.Text_IO;\n\nprocedure Main is\nbegin\n    Put_Line (\"Hello World\");\nend Main;\n\nIn [2]: print(u.root.findall(mdl.CallExpr))\n[\u003cCallExpr 5:5-5:29\u003e]\n\nIn [3]: print(u.root.findall(mdl.CallExpr)[0].text)\nPut_Line (\"Hello World\")\n~~~\n\nThe playground embeds the [IPython](https://ipython.org/) interactive Python\nconsole, so you have a modern interactive programming environment. You can use\ntab completion to explore the Libadalang API.\n\nLibadalang and ASIS\n-------------------\n\nASIS is widely used for static analysis of Ada code, and is an ISO standard. It\nis still the go-to tool if you want to create a tool that analyses Ada code.\nAlso, as explained above, Libadalang is not mature yet, and cannot replace ASIS\nin tools that require semantic analysis.\n\nHowever, there are a few reasons you might eventually choose to use Libadalang\ninstead of ASIS:\n\n1. The ASIS standard has not yet been updated to the 2012 version of Ada. More\n   generally, the advantages derived from ASIS being a standard also means that\n   it will evolve very slowly.\n\n2. Syntax only tools will derive a lot of advantages on being based on\n   Libadalang:\n\n   * Libadalang will be completely tolerant to semantic errors. For example, a\n     pretty-printer based on Libadalang will work whether your code is\n     semantically correct or not, as long as it is syntactically correct.\n\n   * Provided you only need syntax, Libadalang will be much faster than ASIS'\n     main implementation (AdaCore's ASIS), because ASIS always does complete\n     analysis of the input Ada code.\n\n3. The design of Libadalang's semantic analysis is lazy. It will only process\n   semantic information on-demand, for specific portions of the code. It means\n   that you can get up-to-date information for a correct portion of the code\n   even if the file contains semantic errors.\n\n4. Libadalang has bindings to C and Python, and its design makes it easy to\n   bind to new languages.\n\n5. Libadalang is suitable to write tools that work on code that is evolving\n   dynamically. It can process code and changes to code incrementally. Thus, it\n   is suitable as an engine for an IDE, unlike AdaCore's ASIS implementation.\n\n6. Libadalang is not tied to a particular compiler version. This combined with\n   its staged and error tolerant design means that you can use it to detect\n   bugs in Ada compilers/tools.\n\nImplementation\n--------------\n\nThe Libadalang project is based on the\n[Langkit](https://github.com/AdaCore/langkit) framework, so its\nAda/Python/C/OCaml source code is not checked in this repository: it is instead\ngenerated from the Langkit language specification that you can find in\n[ada/](ada/). This language specification, while embedded in Python syntax, is\nmostly its own language, the Langkit DSL, that is used to specify the part of\nAda syntax and semantics that are of interest to us.\n\nSee the [Developer Manual](dev_manual) for more information about Libadalang's\ndevelopment.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAdaCore%2Flibadalang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAdaCore%2Flibadalang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAdaCore%2Flibadalang/lists"}