mirror of
https://github.com/AdaCore/langkit.git
synced 2026-02-12 12:28:12 -08:00
31 lines
664 B
Python
31 lines
664 B
Python
import sys
|
|
|
|
import libfoolang
|
|
|
|
|
|
print("main.py: Running...")
|
|
|
|
ctx = libfoolang.AnalysisContext()
|
|
u = ctx.get_from_buffer("main.txt", "example")
|
|
if u.diagnostics:
|
|
for d in u.diagnostics:
|
|
print(d)
|
|
sys.exit(1)
|
|
|
|
for strings, separator in [
|
|
([], ""),
|
|
([], "|"),
|
|
([""], ""),
|
|
([""], "|"),
|
|
(["a"], ""),
|
|
(["a"], "|"),
|
|
(["ab", "cdef", "", "g"], ""),
|
|
(["ab", "cdef", "", "g"], "|"),
|
|
(["ab", "cdef", "", "g"], "<|>"),
|
|
]:
|
|
strings_arg = [libfoolang.Str(value=s) for s in strings]
|
|
result = u.root.p_join(strings_arg, separator)
|
|
print(f"join({strings}, {repr(separator)}) = {repr(result)}")
|
|
|
|
print("main.py: Done.")
|