CRUDUI PHP API

Lexer
in package

FinalYes

CRUDUI expression lexer (expressions.md §1, JS Lexer parity).

Turns a condition string into a Token[] ending in EOF. WHITESPACE is consumed but never emitted. The token order, multi-char operator precedence, multi-dot handling, string escapes, and number rules mirror validator-ts Lexer exactly, because the shared fixture's tokens array is byte-compared across 4 languages.

NO regex-split / no string-split evaluation anywhere (GRAMMAR §10): this is a single forward scan. PHP identifiers are ASCII (analysis note), so byte-wise scanning is exact.

Table of Contents

Properties

$input  : string
$length  : int
$position  : int

Methods

__construct()  : mixed
Build a lexer over the given expression string.
tokenize()  : array<int, Token>
Tokenize the whole input. WHITESPACE tokens are dropped; an EOF token is always appended last.
advance()  : string
isAlpha()  : bool
isAlphaNumeric()  : bool
isAtEnd()  : bool
isDigit()  : bool
isWhitespace()  : bool
matchString()  : bool
matchWhitespace()  : bool
nextToken()  : Token
parseNumberLiteral()  : int|float
Parse a numeric literal to int or float. JS uses parseFloat (always float); for JSON byte-parity we keep an int when the source has no fractional/exponent part so the fixture's integer literals stay integers.
peek()  : string
peekNext()  : string
readIdentifier()  : Token
readNumber()  : Token
readString()  : Token

Properties

$input read-only

private string $input

$length read-only

private int $length

$position

private int $position = 0

Methods

__construct()

Build a lexer over the given expression string.

public __construct(string $input) : mixed
Parameters
$input : string

tokenize()

Tokenize the whole input. WHITESPACE tokens are dropped; an EOF token is always appended last.

public tokenize() : array<int, Token>
Return values
array<int, Token>

advance()

private advance() : string
Return values
string

isAlpha()

private isAlpha(string $c) : bool
Parameters
$c : string
Return values
bool

isAlphaNumeric()

private isAlphaNumeric(string $c) : bool
Parameters
$c : string
Return values
bool

isAtEnd()

private isAtEnd() : bool
Return values
bool

isDigit()

private isDigit(string $c) : bool
Parameters
$c : string
Return values
bool

isWhitespace()

private isWhitespace(string $c) : bool
Parameters
$c : string
Return values
bool

matchString()

private matchString(string $str) : bool
Parameters
$str : string
Return values
bool

matchWhitespace()

private matchWhitespace() : bool
Return values
bool

parseNumberLiteral()

Parse a numeric literal to int or float. JS uses parseFloat (always float); for JSON byte-parity we keep an int when the source has no fractional/exponent part so the fixture's integer literals stay integers.

private static parseNumberLiteral(string $value) : int|float
Parameters
$value : string
Return values
int|float

peek()

private peek() : string
Return values
string

peekNext()

private peekNext() : string
Return values
string
On this page

Search results