final class DeclarationPrinter
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Writes declarations the way Bison spells them.

Methods§

public function __construct(private SymbolPrinter $symbols = new \BisonParser\Printer\SymbolPrinter())

Parameters

$symbolsSymbolPrinterWrites symbols and literals
Calls 1
public function print(Declaration $declaration): string

Writes one declaration.

Parameters

$declarationDeclarationThe declaration

Returns

string The declaration text

Throws

LogicException When the declaration is of a class the printer does not know
Test cases 2
Called from 2
Calls 27
public function option(Option $option): string

Writes an option such as %require "3.8".

Parameters

$optionOptionThe option

Returns

string The directive as written, then its string when it has one
Test cases 1
Called from 1
Calls 1
public function expect(int $count, bool $reduceReduce): string

Writes %expect N or %expect-rr N.

Parameters

$countintThe number of conflicts expected
$reduceReduceboolWhether they are reduce/reduce conflicts

Returns

string The directive
Test cases 1
Called from 1
public function union(UnionDeclaration $union): string

Writes a %union.

Parameters

$unionUnionDeclarationThe union

Returns

string `%union name { ... }`, the name left out when there is none
Test cases 1
Called from 1
Calls 1
public function props(CodeProps $props): string

Writes a %destructor or %printer.

Parameters

$propsCodePropsThe declaration

Returns

string The directive, its code and its targets
Test cases 1
Called from 1
Calls 2
public function code(Code $code): string

Writes a %code block.

Parameters

$codeCodeThe declaration

Returns

string `%code qualifier { ... }`, the qualifier left out when there is none
Test cases 1
Called from 1
Calls 1
public function line(Line $line): string

Writes a #line directive.

Parameters

$lineLineThe directive

Returns

string `#line N "file"`, or `#line N` when no file was named
Test cases 1
Called from 2
public function define(Define $define): string

Writes a %define.

Parameters

$defineDefineThe declaration

Returns

string The declaration text
Test cases 1
Called from 1
Calls 5
public function targets(list<Symbol|Tag> $targets): string

Writes the symbols and tags of a %destructor or %printer.

Parameters

$targetslist<Symbol|Tag>The targets

Returns

string The targets separated by spaces
Test cases 1
Called from 1
Calls 3
public function entries(list<SymbolEntry> $entries): string

Writes the entries of a symbol or precedence declaration, each tag once where it takes effect.

Parameters

$entrieslist<SymbolEntry>The entries

Returns

string The entries, each preceded by a space
Test cases 1
Called from 2
Calls 2

Private surface 1§

Implementation details, listed for orientation only.

private SymbolPrinter $symbols = new \BisonParser\Printer\SymbolPrinter()

Test cases 14§

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

Dedicated tests 10
Other tests reaching this symbol 4

Relations§

Instantiated in 2
Method calls 3
Type declarations 2