cli: parse unary prefix chains iteratively

This commit is contained in:
dev committed 2026-10-10 16:32:29 +03:00
1 parent fb80413b37
commit c36b269289
5 files changed
+270 -32

No files matched your search

+19
View File
@@ -68,6 +68,25 @@ with tempfile.TemporaryDirectory(prefix='aji-grammar-') as directory:
assert result == json.loads(cli('run', '--fuel', '100000', *grants, formatted))
assert result['value'] == 42, result
# Prefix depth is a parser/formatter regression, not an acceptance bound
# or a claim that deep lowering is already iterative (Q-061).
for depth in (1024, 16384, 65536):
prefix = 'module deep\nfn main() -> bool effects [] { return ' + 'not ' * depth
deep = root / f'deep-{depth}.aji'
deep.write_text(prefix + 'false; }\n')
output = cli('fmt', deep)
assert output.count('not ') == depth and output.count('false') == 1
formatted = root / f'deep-{depth}.formatted.aji'
formatted.write_text(output)
assert cli('fmt', formatted) == output
deep.write_text(prefix + '; }\n')
error = json.loads(cli('check', deep, code=1))
assert (error['code'], error['expected'], error['found'], error['file']) == (
'E7001', 'an expression', ';', str(deep)), error
assert (error['line'], error['col']) == position(prefix, len(prefix)), error
for command in ('lower', 'run', 'report', 'explore', 'fmt'):
assert json.loads(cli(command, deep, code=1)) == error
# Imported qualifiers take the same syntax path and retain the actual file.
helper = root / 'model.aji'
helper.write_text('module app.model\nenum Value<T> { Empty, Payload(T), }\n')