adacore / langkit Goto Github PK
View Code? Open in Web Editor NEWLanguage creation framework.
Home Page: https://www.adacore.com
License: Other
Language creation framework.
Home Page: https://www.adacore.com
License: Other
Generating source for libgprlang ...
Generation complete!
Building the generated source code ...
gcc -c -fPIC -gnatwa -gnatyg -g -O0 -gnatwe -gnata -gnatef langkit_support-adalog-main_support.ads
+===========================GNAT BUG DETECTED==============================+
| GPL 2016 (20160515-49) (x86_64-pc-linux-gnu) GCC error: |
| in process_type, at ada/gcc-interface/trans.c:9616 |
| Error detected at langkit_support-adalog-unify_one_side.ads:105:9 [langkit_support-adalog-unify.ads:51:4 [langkit_support-adalog-eq_same.ads:33:4 [langkit_support-adalog-main_support.ads:8:4]]]|
| Please submit a bug report by email to [email protected]. |
| GAP members can alternatively use GNAT Tracker: |
| http://www.adacore.com/ section 'send a report'. |
| See gnatinfo.txt for full info on procedure for submitting bugs. |
| Use a subject line meaningful to you and us to track the bug. |
| Include the entire contents of this bug box in the report. |
| Include the exact command that you entered. |
| Also include sources listed below. |
| Use plain ASCII or MIME attachment(s). |
+==========================================================================+
I ran git bisect; it reports 91cf97e is the first bad commit
commit 91cf97e
Author: Pierre-Marie de Rodat [email protected]
Date: Mon Feb 13 18:05:58 2017 +0100
astdoc: add documentation for structure types
TN: Q213-023
I don't understand the code well enough to investigate further
Obviously a noddy question, but not one I can seem to solve. I need to install libadalang so installing this is essential. My GNAT directory is in /opt as the community edition gives. Seems like whichever prefix value I choose I can't seem to get the libadalang installer to find it. Where it is supposed to be if I've got everything in /opt/GNAT?
This is mainly triggered by use on macOS via Alire.
On macOS, we have to use relocatable builds because static SALs don’t work (gprbuild issue 97), and this means that we need to provide libgmp.dylib
.
The macOS compilers available via Alire don’t search /usr/local
by default, which means that we have to tell gprbuild where to look, and the only obvious mechanism is via LDFLAGS
.
Please see also libadalang issue 958.
In PyYAML before 4.1, the yaml.load() API could execute arbitrary code. In other words, yaml.safe_load is not used.
I don't know the status after 4.1, however in gentoo with pyyaml 5.1 I cannot run test for the yaml.load() use
A few months ago, I wrote a Python parser leveraging Langkit.
Since we want to evolve toward langkit truly being a meta language framework with more than one language, I thought it would make sense to at least version control and run simple tests for the Python parser.
While running
python ada/manage.py generate -P
I got
File "/Volumes/Miscellaneous2/libadalang/venv/src/langkit/langkit/documentation.py", line 27, in <module>
from typing import (Any, Callable, Dict, List, Optional, Protocol, Set,
ImportError: cannot import name 'Protocol' from 'typing' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/typing.py)
Looks as though we need Python 3.8 now, not the 3.7+ noted in the README?
It seems to me that packages
in setup.py
should also include langkit.lexer
.
Otherwise, the directory langkit/lexer
is not copied when installing, and the compilation
of libadalang fails down the road...
Thanks !
I have cloned the repository via:
git clone https://github.com/AdaCore/langkit.git
and then followed the instructions to build the code. I typed in:
pip install .
and this worked fine. I then typed in:
python manage.py build-langkit-support --library-types=static,static-pic,relocatable
and the following set of error messages are displayed:
error: "langkit_support-adalog-abstract_relation.adb" must be recompiled ("langkit_support-adalog.ads" has been modified)
error: "langkit_support-adalog-debug.adb" must be recompiled ("langkit_support-adalog.ads" has been modified)
error: "langkit_support-adalog-eq_same.adb" must be recompiled ("langkit_support-adalog.ads" has been modified)
error: "langkit_support-adalog-logic_ref.adb" must be recompiled ("langkit_support-adalog.ads" has been modified)
error: "langkit_support-adalog-logic_var.ads" must be recompiled ("langkit_support-adalog.ads" has been modified)
error: "langkit_support-adalog-main_support.adb" must be recompiled ("langkit_support-adalog.ads" has been modified)
error: "langkit_support-adalog-operations.adb" must be recompiled ("langkit_support-adalog.ads" has been modified)
error: "langkit_support-adalog-predicates.adb" must be recompiled ("langkit_support-adalog.ads" has been modified)
error: "langkit_support-adalog-pure_relations.adb" must be recompiled ("langkit_support-adalog.ads" has been modified)
error: "langkit_support-adalog-relations.adb" must be recompiled ("langkit_support-adalog.ads" has been modified)
error: "langkit_support-adalog-unify.adb" must be recompiled ("langkit_support-adalog.ads" has been modified)
error: "langkit_support-adalog-unify_lr.adb" must be recompiled ("langkit_support-adalog.ads" has been modified)
error: "langkit_support-adalog-unify_one_side.adb" must be recompiled ("langkit_support-adalog.ads" has been modified)
error: "langkit_support-adalog.ads" has been modified and must be recompiled
error: "langkit_support-diagnostics-output.adb" must be recompiled ("langkit_support-diagnostics.ads" has been modified)
error: "langkit_support-diagnostics.adb" must be recompiled ("langkit_support-diagnostics.ads" has been modified)
error: "langkit_support-errors.ads" has been modified and must be recompiled
error: "langkit_support-file_readers.adb" must be recompiled ("langkit_support-diagnostics.ads" has been modified)
error: "langkit_support-generic_api-analysis.adb" must be recompiled ("langkit_support-diagnostics.ads" has been modified)
error: "langkit_support-generic_api.adb" must be recompiled ("langkit_support-diagnostics.ads" has been modified)
error: "langkit_support-internal.ads" must be recompiled ("langkit_support-diagnostics.ads" has been modified)
error: "langkit_support-lexical_envs.ads" has been modified and must be recompiled
error: "langkit_support-lexical_envs_impl.adb" must be recompiled ("langkit_support-errors.ads" has been modified)
error: "langkit_support-slocs.adb" must be recompiled ("langkit_support-slocs.ads" has been modified)
error: "langkit_support-symbols-precomputed.adb" must be recompiled ("langkit_support-symbols.ads" has been modified)
error: "langkit_support-symbols.adb" must be recompiled ("langkit_support-symbols.ads" has been modified)
error: "langkit_support-text.adb" must be recompiled ("langkit_support-text.ads" has been modified)
error: "langkit_support-token_data_handlers.adb" must be recompiled ("langkit_support-slocs.ads" has been modified)
gprlib: invocation of /opt/ides/gnat/2020/bin/gnatbind failed
gprbuild: could not build library for project langkit_support
Traceback (most recent call last):
File "/home/xxx/Programs/Development-Tools/GNAT/langkit/manage.py", line 291, in <module>
args.func(args, unknown_args)
File "/home/xxx/Programs/Development-Tools/GNAT/langkit/manage.py", line 87, in wrapper
fn(args)
File "/home/xxx/Programs/Development-Tools/GNAT/langkit/manage.py", line 118, in build_langkit_support
subprocess.check_call(base_argv + [f"-XLIBRARY_TYPE={library_type}"])
File "/usr/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['gprbuild', '-P', '/home/xxx/Programs/Development-Tools/GNAT/langkit/support/langkit_support.gpr', '-p', '-j4', '-XBUILD_MODE=dev', '-XLIBRARY_TYPE=relocatable']' returned non-zero exit status 4.
I have tried the command without the --library-types to build only one library type, but the error message is the same. What am I doing wrong ?
Create an example project:
create-project.py repro
Change ExampleNode
to Length
:
$ sed -ie 's/ExampleNode/Length/' repro/language/parser.py
$ cd repro && python3 ./manage.py make
[...]
Compile
[Ada] parse.adb
parse.adb:137:44: "Length" is not visible
parse.adb:137:44: multiple use clauses cause hiding
parse.adb:137:44: hidden declaration at libreprolang-analysis.ads:88
parse.adb:137:44: hidden declaration at a-strunb.ads:92
compilation of parse.adb failed
gprbuild: *** compilation phase failed
Build failed: error while running gprbuild -p -j8 -P/home/senier/tmp/langkit/length_issue/repro/build/src/mains.gpr -XBUILD_MODE=dev -XLIBRARY_TYPE=relocatable -XGPR_BUILD=relocatable -XXMLADA_BUILD=relocatable parse.adb:
Command '['gprbuild', '-p', '-j8', '-P/home/senier/tmp/langkit/length_issue/repro/build/src/mains.gpr', '-XBUILD_MODE=dev', '-XLIBRARY_TYPE=relocatable', '-XGPR_BUILD=relocatable', '-XXMLADA_BUILD=relocatable', 'parse.adb']' returned non-zero exit status 4.
Either reject Length
as AST node name or (preferably) allow it's use in the parser by fully qualifying Ada.Strings.Unbounded.Length
(maybe use
clauses should be avoided in generated code alltogether).
GNAT: Community 2020
Langkit: master (45df941)
Currently libadalang (which includes langkit) fails to build on new gnatcoll.
Source of failure appears to be ./langkit/templates/project_file.mako line: 6. If "gnatcoll_iconv" is changed to "gnat-iconv" then libadalang builds successfully, at least for me.
Alternate workaround was to put symbolic link(s) in <install_dir>/share/gpr if this falls into the category of waiting for gnatcoll to stabilize.
I am building langkit on Linux using the following command:
python manage.py build-langkit-support --library-types=static-pic
I get the following linking error:
/usr/bin/ld: -r and -pie may not be used together
collect2: error: ld returned 1 exit status
gprlib: call to linker driver /usr/bin/gcc failed
gprbuild: could not build library for project langkit_support
Traceback (most recent call last):
File "/home/tim/projects/aur/ada_language_server/src/langkit/manage.py", line 291, in <module>
args.func(args, unknown_args)
File "/home/tim/projects/aur/ada_language_server/src/langkit/manage.py", line 87, in wrapper
fn(args)
File "/home/tim/projects/aur/ada_language_server/src/langkit/manage.py", line 118, in build_langkit_support
subprocess.check_call(base_argv + [f"-XLIBRARY_TYPE={library_type}"])
File "/usr/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['gprbuild', '-P', '/home/tim/projects/aur/ada_language_server/src/langkit/support/langkit_support.gpr', '-p', '-j16', '-XBUILD_MODE=dev', '-XLIBRARY_TYPE=static-pic']' returned non-zero exit status 4.
==> ERROR: A failure occurred in build().
Aborting...
Dear adaCore,
I am missing some basic functionality.
The Value function (the inverse of image )
is not present.
A simple solution might be to add functions like
function Source_Location_Value (Source_Location_String : String) return Source_Location
is
Index_Colon : constant Natural := Index (Source_Location_String, ":");
Line : constant Line_Number :=
Line_Number'Value (Head (Source_Location_String, Index_Colon - Source_Location_String'First));
Column : constant Column_Number :=
Column_Number'Value (Tail (Source_Location_String, Source_Location_String'Last - Index_Colon));
begin
return (Line => Line,
Column => Column);
end Source_Location_Value;
function Source_Location_Range_Value (Source_Location_Range_String : String)
return Source_Location_Range
is
Index_Dash : constant Natural := Index (Source_Location_Range_String, "-");
Start_Location_String : constant String :=
Head (Source_Location_Range_String, Index_Dash - Source_Location_Range_String'First);
Start_Location : constant Source_Location := Source_Location_Value (Start_Location_String);
End_Location_String : constant String :=
Tail (Source_Location_Range_String, Source_Location_Range_String'Last - Index_Dash);
End_Location : constant Source_Location := Source_Location_Value (End_Location_String);
begin
return (Start_Line => Start_Location.Line,
End_Line => End_Location.Line,
Start_Column => Start_Location.Column,
End_Column => End_Location.Column);
end Source_Location_Range_Value;
Seems that Python changed how it handles dll dependencies in 3.8, and now extra paths need to be added explicitly:
https://docs.python.org/3/library/os.html#os.add_dll_directory
Currently it fails with a message something along the lines of:
Traceback (most recent call last):
File "C:\libadalang\tmp\name_resolution__S709-005\test.py", line 1, in <module>
import libadalang as lal
File "C:\libadalang\build\python\libadalang\__init__.py", line 94, in <module>
_c_lib = ctypes.cdll.LoadLibrary(_c_lib_path)
File "C:\Python310\lib\ctypes\__init__.py", line 452, in LoadLibrary
return self._dlltype(name)
File "C:\Python310\lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'libadalang.dll' (or one of its dependencies). Try using the full path with constructor syntax.
As a cheap and nasty hack, the following in module_py.mako just above the LoadLibrary call seems to work, but could probably be improved:
for path in os.environ['PATH'].split(';'):
if os.path.exists(path):
os.add_dll_directory(path)
Attempting to build with python 3.5+:
Traceback (most recent call last):
File "ada/manage.py", line 14, in <module>
from langkit.libmanage import ManageScript
File "/construction/libadalang/libadalang-611f857/ada/../langkit/langkit/libmanage.py", line 17, in <module>
from langkit.compile_context import Verbosity
File "/construction/libadalang/libadalang-611f857/ada/../langkit/langkit/compile_context.py", line 1358
key=lambda (s, n): n)
^
SyntaxError: invalid syntax
Python 2.7 is nearly EOL. In my opinion, no new development should target python 2.7.
At the very least, if this really is a restriction, it should be boldly proclaimed on the README as that is very important build information.
As discussed live, opening an issue for this.
For the moment we can only have properties, that apply to ast nodes. Properties are akin to methods. As a consequence, we have a lot of code that should be in functions/static methods and that in the end is on nodes.
This issue is to implement free functions in the DSL. This encompasses generating code for them, as well as making them part of the public API.
Various collections.* -> collections.abc.* aliases were removed in Python 3.10
This causes in libadalang tests like:
_Output:
_Traceback (most recent call last):
_ File "C:\libadalang\tmp\python__R918-040_rebindings\test.py", line 19, in <module>
_ ps = u.root.find(lambda n: n.text == 'Foo').parent
_ File "C:\libadalang\build\python\libadalang\__init__.py", line 2941, in find
_ return next(self.finditer(ast_type_or_pred, **kwargs))
_ File "C:\libadalang\build\python\libadalang\__init__.py", line 2972, in finditer
_ elif isinstance(ast_type_or_pred, collections.Sequence):
_AttributeError: module 'collections' has no attribute 'Sequence'
should be
elif isinstance(ast_type_or_pred, collections.abc.Sequence):
(no change of import necessary, I believe)
README.md doesn’t mention the need to call setup.py
, or how to call it (the documentation suggests using setup.py/easy_install/pip/...
, whatever ...
is, but we’ve already installed REQUIREMENTS.dev
).
Also, it says the documentation is found in langkit/doc
, but it’s actually in doc
.
People might get started quicker if eval $(./manage.py setenv)
was mentioned?
I am using the latest version of Gnat/Ada, and when I compile and run the code I get an error:
[2020-06-06 16:09:45] Could not locate executable on path: git
The project settings specify Version Control: None
Do I have something incorrectly set, and/or is there a way to suppress this message?
This patch makes Diagnostics.print_context respect EMIT_PARSABLE_ERRORS.
--- a/langkit/diagnostics.py
+++ b/langkit/diagnostics.py
@@ -178,18 +178,21 @@ def print_context(recovered=False):
# Then we'll print the context we've kept
last_file_info = ''
for ctx_msg, ctx_loc in reversed(get_structured_context(recovered)):
- # We only want to show the file information one time if it is the same
- file_info = 'File "{}", '.format(col(ctx_loc.file, Colors.CYAN))
- if last_file_info == file_info:
- file_info = ' '
+ if EMIT_PARSABLE_ERRORS:
+ print "{}:{}: {}".format(ctx_loc.file, ctx_loc.line, ctx_msg)
else:
- last_file_info = file_info
-
- print ('{file_info}line {line}, {msg}'.format(
- file_info=file_info,
- line=col(ctx_loc.line, Colors.CYAN),
- msg=ctx_msg
- ))
+ # We only want to show the file information one time if it is the same
+ file_info = 'File "{}", '.format(col(ctx_loc.file, Colors.CYAN))
+ if last_file_info == file_info:
+ file_info = ' '
+ else:
+ last_file_info = file_info
+
+ print ('{file_info}line {line}, {msg}'.format(
+ file_info=file_info,
+ line=col(ctx_loc.line, Colors.CYAN),
+ msg=ctx_msg
+ ))
def get_parsable_location():
The import of StringIO
in
It should be from io import StringIO
.
user_manual/building.rst still claims that you should run python manage.py generate
(and build, and install), but manage.py rejects those as invalid options.
During test phase I got a lot of
ModuleNotFoundError: No module named 'liblktlang'
I cannot find from where this module come
With GCC-7.4.0 using these GNATColl commit ID's
$ cd langkit
$ export PYTHONPATH=$(pwd)
$ python2.7 scripts/build-langkit_support.py generate
$ python2.7 scripts/build-langkit_support.py --library-types relocatable build --build-mode=prod --gargs="-R"
Setup
[mkdir] object directory for project Langkit_Support
[mkdir] library directory for project Langkit_Support
Compile
[Ada] langkit_support-vectors.adb
[Ada] langkit_support-lexical_env.adb
[Ada] langkit_support-tree_traversal_iterator.adb
[Ada] langkit_support-token_data_handlers.adb
[Ada] langkit_support-symbols.adb
[Ada] langkit_support-adalog-unify_one_side.adb
[Ada] langkit_support-adalog-operations.adb
[Ada] langkit_support-adalog-abstract_relation.adb
[Ada] langkit_support.ads
[Ada] langkit_support-types.ads
[Ada] langkit_support-text.adb
[Ada] langkit_support-slocs.adb
[Ada] langkit_support-relative_get.adb
[Ada] langkit_support-packrat.adb
[Ada] langkit_support-iterators.adb
[Ada] langkit_support-images.adb
[Ada] langkit_support-hashes.adb
[Ada] langkit_support-diagnostics.adb
[Ada] langkit_support-cheap_sets.adb
[Ada] langkit_support-bump_ptr.adb
[Ada] langkit_support-bump_ptr-vectors.adb
[Ada] langkit_support-boxes.adb
[Ada] langkit_support-array_utils.adb
[Ada] langkit_support-adalog.ads
[Ada] langkit_support-adalog-unify_lr.adb
[Ada] langkit_support-adalog-unify.adb
[Ada] langkit_support-adalog-relations.adb
[Ada] langkit_support-adalog-pure_relations.adb
[Ada] langkit_support-adalog-predicates.adb
[Ada] langkit_support-adalog-main_support.adb
[Ada] langkit_support-adalog-logic_var.ads
[Ada] langkit_support-adalog-logic_ref.adb
[Ada] langkit_support-adalog-eq_same.adb
[Ada] langkit_support-adalog-debug.adb
langkit_support-adalog-eq_same.ads:126:14: implicit conversion of anonymous access value not allowed
langkit_support-adalog-eq_same.ads:126:14: implicit conversion of anonymous access value not allowed
compilation of langkit_support-adalog-eq_same.adb failed
compilation of langkit_support-adalog-main_support.adb failed
gprbuild: *** compilation phase failed
Build failed: error while running gprbuild -p -j8 -Pbuild/lib/gnat/langkit_support.gpr -XBUILD_MODE=prod -XLIBRARY_TYPE=relocatable -XGPR_BUILD=relocatable -XXMLADA_BUILD=relocatable -R:
Command '['gprbuild', '-p', '-j8', '-Pbuild/lib/gnat/langkit_support.gpr', '-XBUILD_MODE=prod', '-XLIBRARY_TYPE=relocatable', '-XGPR_BUILD=relocatable', '-XXMLADA_BUILD=relocatable', '-R']' returned non-zero exit status 4
In a similar fashion to what we do for mains, it would be desirable to not copy language specific extension packages when building, but rather reference the extension directory directly.
This would make those files more tool friendly (GPS for example)
We have observed in RecordFlux that the diagnostics of our langkit-based parser is empty when python -O
is used (AdaCore/RecordFlux#603). The root cause seems to be an assertion in the Python binding (librflxlang/__init__.py
):
1120 @property
1121 def diagnostics(self):
1122 """
1123 Diagnostics for this unit.
1124 """
1125 count = _unit_diagnostic_count(self._c_value)
1126 result = []
1127 diag = Diagnostic._c_type()
1128 for i in range(count):
1129 assert _unit_diagnostic(self._c_value, i, ctypes.byref(diag))
1130 result.append(diag._wrap())
1131 return result
The function _unit_diagnostic
seems to have side effects and is not executed when -O
is used. If line 1129 is commented out, the issue also occurs without -O
.
6313 _unit_diagnostic = _import_func(
6314 "rflx_unit_diagnostic",
6315 [AnalysisUnit._c_type, ctypes.c_uint, ctypes.POINTER(Diagnostic._c_type)],
6316 ctypes.c_int,
6317 )
We use -O
for performance reasons, otherwise the assertions and contracts used in RecordFlux would make the execution significantly slower.
GNAT: Community 2020
Langkit: 21.0.0
Found that by writing the following property in GenericInstantiation
:
xref_equation = Property(
Bind(Entity.generic_entity_name, Entity.designated_generic_decl)
)
The first param should denote a logic variable, but denotes a T.Name.Entity
, and no error is issued
Thank PM :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.