packages/sql-faker/src/Compiler/Bison/BisonPreamble.php

1<?php
2
3declare(strict_types=1);
4
5namespace SqlFaker\Compiler\Bison;
6
7use SqlFaker\Compiler\Bison\Ast\BisonDeclaration;
8
9/**
10 * Everything a grammar file states before its rules.
11 *
12 * The prologue and the declarations are read in one pass because they are
13 * interleaved, but they are two different things to the rest of the parser, so
14 * they travel together rather than as an unlabelled pair.
15 *
16 * @visibility root
17 */
18final class BisonPreamble
19{
20    /**
21     * @param string|null $prologue Host-language code from `%{ ... %}`, or null when the file has none
22     * @param list<BisonDeclaration> $declarations Declarations in the order they were written
23     */
24    public function __construct(
25        public readonly ?string $prologue,
26        public readonly array $declarations,
27    ) {
28    }
29}
30