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

Evaluates the expression after %if, %ifdef or %ifndef.

Lemon reads the expression left to right with no precedence: a name is true when it is defined, ! negates the next term, parentheses group, and || and && stop as soon as the answer is known.

Methods§

public function __construct(private list<string> $defines)

Parameters

$defineslist<string>The names defined on the command line
public function term(string $text, int $index, Location $location): array{bool, int}

Evaluates a parenthesised group or a name.

Parameters

$textstringThe whole expression
$indexintWhere the term begins
$locationLocationWhere the directive is, for errors

Returns

array{bool, int} The value and the index of the term's last byte

Throws

SyntaxException When the term is not a group or a name
Test cases 3
Called from 1
Calls 6
public function guard(bool $condition, string $text, int $index, Location $location): void

Raises the error unless a condition holds.

Parameters

$conditionboolWhat must hold
$textstringThe whole expression
$indexintWhere the problem is
$locationLocationWhere the directive is

Throws

SyntaxException When the condition does not hold
Test cases 1
Called from 4
Calls 1
public function error(string $text, int $index, Location $location): SyntaxException

Words the error as Lemon does.

Parameters

$textstringThe whole expression
$indexintWhere the problem is
$locationLocationWhere the directive is

Returns

SyntaxException The error
Test cases 1
Called from 3
Calls 2

Private surface 1§

Implementation details, listed for orientation only.

private list<string> $defines

Test cases 19§

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 6

Relations§

Instantiated in 1
Method calls 1
Type declarations 2