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

Reads PostgreSQL's operators and punctuation.

A user-defined operator is the longest run of operator characters that does not start a comment. A run that ends in + or - gives those up unless it also holds a character that only user-defined operators use, so that a<-1 reads as a < -1. A single character that stands for itself and the few two-character comparisons have terminals of their own.

Constants§

public const SELF = ',()[].;:+-*/%^<>='

Characters that are tokens of their own.

public const OPERATOR = '~!@#^&|`?+-*/%<>='

Characters a user-defined operator may hold.

public const KEEPS_SIGN = '~!@#^&|`?%'

Characters whose presence lets an operator keep a trailing + or -.

public const FIXED = ['::' => 'TYPECAST', '..' => 'DOT_DOT', ':=' => 'COLON_EQUALS', '=>' => 'EQUALS…

Terminals of the multi-character punctuation that is not an operator run.

Methods§

public function scan(Scan $scan): Lexeme

Reads the operator or punctuation at the cursor.

Parameters

$scanScanThe tokenization in progress

Returns

Lexeme The lexeme

Throws

LexicalException When the character starts no token at all
Test cases 3
Called from 1
Calls 8
public function operatorRun(string $source, int $offset): string|null

Answers the operator run at an offset, trimmed as the scanner trims it.

Parameters

$sourcestringThe SQL text
$offsetintWhere the run starts

Returns

string|null The run, or null when no operator character is there
Test cases 1
Called from 1
Calls 6

Test cases 6§

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

Dedicated tests 4
Other tests reaching this symbol 2

Relations§

Instantiated in 1
Method calls 1
Type declarations 1