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

Reads host code as Bison's scanner does: braced code, a prologue, or one unit of either.

Braces nest, the digraphs <% and %> count as braces, and braces inside comments, strings and character literals do not count. A backslash-newline, which C splices away, may fall between the two characters of /*, * /, //, <%, %> and <<, and inside a string or character literal, exactly as scan-gram.l allows.

Constants§

public const SPLICE = '(?:\\\\[ \f\t\v]*\r?\n)*'

Backslash-newlines that C splices away, as a regular expression fragment.

Methods§

public function braced(Cursor $cursor): string
public function prologue(Cursor $cursor): string

Reads the prologue the cursor is at and returns the text between %{ and %}.

Parameters

$cursorCursorPositioned at `%{`

Returns

string The code without its delimiters

Throws

SyntaxException When the file ends before `%}`
Test cases 2
Called from 1
Calls 6
public function unit(Cursor $cursor): string

Reads one unit of host code: a comment, a string, a character literal, a digraph, or one byte.

Parameters

$cursorCursorPositioned at the unit

Returns

string The unit as written

Throws

SyntaxException When a comment, string or character literal is not closed
Test cases 4
Called from 2
Calls 7
public function opens(string $unit): bool

Reports whether a unit opens a brace: { or the digraph <%, possibly spliced.

Parameters

$unitstringThe unit

Returns

bool True for an opening brace
Test cases 1
Called from 1
Calls 2
public function closes(string $unit): bool

Reports whether a unit closes a brace: } or the digraph %>, possibly spliced.

Parameters

$unitstringThe unit

Returns

bool True for a closing brace
Test cases 1
Called from 1
Calls 2

Test cases 21§

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

Dedicated tests 13
Other tests reaching this symbol 8

Relations§

Instantiated in 1
Method calls 3
Type declarations 1