final class Code
    implements Declaration
Public API: explicitly declared with @visibility public.

A %code directive, with the qualifier that says where the code goes.

Reading a code blockdoctest
$file = (new \BisonParser\Parser())->parse("%code requires { #include <stdint.h> }\n%%\ns: 'a';\n");
    $file->declarations[0]->qualifier // => 'requires'
    $file->declarations[0]->code // => ' #include <stdint.h> '

Properties§

public string|null $qualifier
public string $code
public Location $location

Methods§

public function __construct(
    public string|null $qualifier,
    public string $code,
    public Location $location,
)

Parameters

$qualifierstring|nullThe qualifier such as `requires`, or null for unqualified code
$codestringThe code without its braces
$locationLocationWhere the directive is written
public function location(): Location

Answers where the declaration begins.

Returns

Location Line and column of the percent sign
Test cases 1

Test cases 7§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1
Other tests reaching this symbol 6

Relations§

Instantiated in 1
Constant reads 1
Type declarations 1