mirror of
https://github.com/AdaCore/langkit.git
synced 2026-02-12 12:28:12 -08:00
Public APIs are supposed to expose entities as black boxes: there is no concept of bare node, there. For this reason, it makes no sense to have two distinct "repr"/"image" primitives for them. Remove the existing "entity_repr" primitive and make "node_repr" use the entity info for its work. For #639
37 lines
786 B
Python
37 lines
786 B
Python
import sys
|
|
|
|
import libfoolang
|
|
|
|
|
|
ctx = libfoolang.AnalysisContext()
|
|
u = ctx.get_from_buffer('main.txt', b"""
|
|
(T) foo { a b }
|
|
|
|
(T U) old_bar { c d }
|
|
(T U) new_bar { e f }
|
|
|
|
(V) old_baz { g }
|
|
(V) new_baz { h }
|
|
""")
|
|
if u.diagnostics:
|
|
for d in u.diagnostics:
|
|
print(d)
|
|
sys.exit(1)
|
|
|
|
foo, old_bar, new_bar, old_baz, new_baz = u.root
|
|
rebound1 = foo.p_rebind(old_bar, new_bar)
|
|
rebound2 = foo.p_rebind(old_bar, new_bar)
|
|
rebound3 = foo.p_rebind(old_baz, new_baz)
|
|
|
|
for e1, e2 in [
|
|
(rebound1, rebound1),
|
|
(rebound1, rebound2),
|
|
(rebound1, rebound3),
|
|
]:
|
|
print('{} vs. {}'.format(e1, e2))
|
|
print(' identity check: {}'.format(e1 is e2))
|
|
print(' equality check: {}'.format(e1 == e2))
|
|
print(' inequality check: {}'.format(e1 != e2))
|
|
|
|
print('main.py: Done.')
|