mirror of
https://github.com/AdaCore/gpr.git
synced 2026-02-12 12:58:39 -08:00
Main objective of the Ada parser is to determine the unit dependencies (withed unit) of a unit, and if the unit if separate from another unit. To do so, an Ada source code can be split in two separate parts: - The context clause: clause containing withed units - The library item or subunit: Both cases are processed during the same pass, and contain the unit name, and the "separate from" unit name in case of a subunit. Other information are also provided by the parser: - Is the unit generic - Nature of a unit: package, subprogram, or no body (No body is not implemented yet). - The dependencies unit and unit source location. This parser shall be faster than the current Ada parser, as it is based on a lazy lexer, which means that we only read tokens the parser needs. Test executable is built once, and is executed once for each file to parse. Test prints the withed, separate and compilation units. The output is then compared with the baseline test.out. Issue: eng/gpr/gpr-issues/issues/81
30 lines
718 B
Python
30 lines
718 B
Python
from e3.env import Env
|
|
from testsuite_support.builder_and_runner import BuilderAndRunner
|
|
import os
|
|
|
|
bnr = BuilderAndRunner()
|
|
|
|
bnr.build('test.gpr', args=['-p'])
|
|
|
|
files_to_parse_dir = "files-to-parse"
|
|
files_to_parse = os.listdir(files_to_parse_dir)
|
|
|
|
# os.listdir lists in an arbitrary order. Order
|
|
# is important here, because we compare the output with
|
|
# the expected output file test.out.
|
|
files_to_parse.sort()
|
|
|
|
first = True
|
|
for file in files_to_parse:
|
|
bnr.run(['./main', os.path.join(files_to_parse_dir, file)], output="run.out")
|
|
|
|
if first:
|
|
first = False
|
|
else:
|
|
print("")
|
|
|
|
print("===== FILE " + file + "=====")
|
|
for line in open("run.out"):
|
|
li = line[:-1]
|
|
print(li)
|