classOperatorScanner
final class OperatorScanner
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§
Reads the operator or punctuation at the cursor.
Parameters
$scan | Scan | The tokenization in progress |
Returns
Lexeme The lexemeThrows
LexicalException When the character starts no token at allTest cases 3
Called from 1
Calls 8
- method-call OperatorScanner::operatorRun() line 56
- function-call
strlenline 57 - function-call
substrline 58 - class-const OperatorScanner::FIXED() line 59
- method-call Scan::lexeme() line 62
- function-call
str_containsline 65 - class-const OperatorScanner::SELF() line 65
- static-call LexicalException::unexpectedCharacter() line 71
public function operatorRun(string $source, int $offset): string|nullAnswers the operator run at an offset, trimmed as the scanner trims it.
Parameters
$source | string | The SQL text |
$offset | int | Where the run starts |
Returns
string|null The run, or null when no operator character is thereTest cases 1
Called from 1
Calls 6
- function-call
str_containsline 96 - class-const OperatorScanner::OPERATOR() line 96
- function-call
substrline 97 - function-call
strpbrkline 107 - class-const OperatorScanner::KEEPS_SIGN() line 107
- function-call
rtrimline 108
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
PostgreSqlLexerTestcallsPostgreSqlParserTestcalls