classDeclarationPrinter
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
$symbols | SymbolPrinter | Writes symbols and literals |
Calls 1
- new SymbolPrinter line 38
public function print(Declaration $declaration): stringWrites one declaration.
Parameters
$declaration | Declaration | The declaration |
Returns
string The declaration textThrows
LogicException When the declaration is of a class the printer does not knowTest cases 2
Called from 2
Calls 27
- class-const Prologue::class() line 54
- class-const Flag::class() line 55
- class-const Option::class() line 56
- method-call DeclarationPrinter::option() line 56
- class-const Define::class() line 57
- method-call DeclarationPrinter::define() line 57
- class-const Expect::class() line 58
- method-call DeclarationPrinter::expect() line 58
- class-const InitialAction::class() line 59
- method-call SymbolPrinter::code() line 59
- class-const Param::class() line 60
- function-call
implodeline 60 - function-call
array_mapline 60 - class-const UnionDeclaration::class() line 61
- method-call DeclarationPrinter::union() line 61
- class-const Start::class() line 62
- method-call SymbolPrinter::symbol() line 62
- class-const CodeProps::class() line 63
- method-call DeclarationPrinter::props() line 63
- class-const Code::class() line 64
- method-call DeclarationPrinter::code() line 64
- class-const SymbolDeclaration::class() line 65
- method-call DeclarationPrinter::entries() line 65
- class-const PrecedenceDeclaration::class() line 66
- class-const Line::class() line 67
- method-call DeclarationPrinter::line() line 67
- new
LogicExceptionline 68
public function option(Option $option): stringWrites an option such as %require "3.8".
Parameters
$option | Option | The option |
Returns
string The directive as written, then its string when it has oneTest cases 1
Called from 1
Calls 1
- method-call SymbolPrinter::string() line 81
public function expect(int $count, bool $reduceReduce): stringWrites %expect N or %expect-rr N.
Parameters
$count | int | The number of conflicts expected |
$reduceReduce | bool | Whether they are reduce/reduce conflicts |
Returns
string The directiveTest cases 1
public function union(UnionDeclaration $union): stringWrites a %union.
Parameters
$union | UnionDeclaration | The union |
Returns
string `%union name { ... }`, the name left out when there is noneTest cases 1
Called from 1
Calls 1
- method-call SymbolPrinter::code() line 106
public function props(CodeProps $props): stringWrites a %destructor or %printer.
Parameters
$props | CodeProps | The declaration |
Returns
string The directive, its code and its targetsTest cases 1
Called from 1
Calls 2
- method-call SymbolPrinter::code() line 118
- method-call DeclarationPrinter::targets() line 118
public function code(Code $code): stringWrites a %code block.
Parameters
$code | Code | The declaration |
Returns
string `%code qualifier { ... }`, the qualifier left out when there is noneTest cases 1
Called from 1
Calls 1
- method-call SymbolPrinter::code() line 130
public function line(Line $line): stringWrites a #line directive.
Parameters
$line | Line | The directive |
Returns
string `#line N "file"`, or `#line N` when no file was namedTest cases 1
public function define(Define $define): stringWrites a %define.
Parameters
$define | Define | The declaration |
Returns
string The declaration textTest cases 1
Called from 1
Calls 5
- class-const DefineForm::Keyword() line 160
- class-const DefineForm::String() line 161
- method-call SymbolPrinter::string() line 161
- class-const DefineForm::Code() line 162
- method-call SymbolPrinter::code() line 162
Writes the symbols and tags of a %destructor or %printer.
Returns
string The targets separated by spacesTest cases 1
Called from 1
Calls 3
- method-call SymbolPrinter::tag() line 177
- method-call SymbolPrinter::symbol() line 177
- function-call
implodeline 180
public function entries(list<SymbolEntry> $entries): stringWrites the entries of a symbol or precedence declaration, each tag once where it takes effect.
Parameters
$entries | list<SymbolEntry> | The entries |
Returns
string The entries, each preceded by a spaceTest cases 1
Called from 2
Calls 2
- method-call SymbolPrinter::symbol() line 199
- method-call SymbolPrinter::string() line 204
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
DeclarationPrinterTest::testCodecallsDeclarationPrinterTest::testDefinecallsDeclarationPrinterTest::testEntriescallsDeclarationPrinterTest::testExpectcallsDeclarationPrinterTest::testLinecallsDeclarationPrinterTest::testOptioncallsDeclarationPrinterTest::testPrintcallsDeclarationPrinterTest::testPropscallsDeclarationPrinterTest::testTargetscallsDeclarationPrinterTest::testUnioncalls
Other tests reaching this symbol 4
BisonGrammarCompilerTestcallsBisonGrammarReaderTestcallsPrinterTestcallsRhsPrinterTestcalls