Documentation

EmailLexer extends AbstractLexer
in package

Base class for writing simple lexers, i.e. for creating small DSLs.

Table of Contents

ASCII_INVALID_FROM  = 127
ASCII_INVALID_TO  = 199
C_DEL  = 127
C_NUL  = 0
CRLF  = 301
GENERIC  = 300
INVALID  = 302
S_AT  = 64
S_BACKSLASH  = 92
S_BACKTICK  = 96
S_CLOSEBRACKET  = 263
S_CLOSEPARENTHESIS  = 261
S_CLOSEQBRACKET  = 277
S_COLON  = 265
S_COMMA  = 274
S_CR  = 269
S_DOT  = 46
S_DOUBLECOLON  = 266
S_DQUOTE  = 34
S_EMPTY  = null
S_GREATERTHAN  = 273
S_HTAB  = 268
S_HYPHEN  = 264
S_IPV6TAG  = 271
S_LF  = 270
S_LOWERTHAN  = 272
S_OPENBRACKET  = 262
S_OPENPARENTHESIS  = 49
S_OPENQBRACKET  = 276
S_SEMICOLON  = 275
S_SLASH  = 278
S_SP  = 267
S_SQUOTE  = 39
$lookahead  : array<string|int, mixed>|null
The next token in the input.
$token  : array<string|int, mixed>
The last matched/seen token.
$charValue  : array<string|int, mixed>
US-ASCII visible characters not valid for atext (@link http://tools.ietf.org/html/rfc5322#section-3.2.3)
$hasInvalidTokens  : bool
$previous  : array<string|int, mixed>
$input  : string
Lexer original input string.
$nullToken  : mixed
$peek  : int
Current peek of current lexer position.
$position  : int
Current lexer position in input string.
$tokens  : array<string|int, mixed>
Array of scanned tokens.
__construct()  : mixed
find()  : bool
getInputUntilPosition()  : string
Retrieve the original lexer's input until a given position.
getLiteral()  : string
Gets the literal for a given token.
getPrevious()  : array<string|int, mixed>
getPrevious
glimpse()  : array<string|int, mixed>|null
Peeks at the next token, returns it and immediately resets the peek.
hasInvalidTokens()  : bool
isA()  : bool
Checks if given value is identical to the given token.
isNextToken()  : bool
Checks whether a given token matches the current lookahead.
isNextTokenAny()  : bool
Checks whether any of the given tokens matches the current lookahead.
moveNext()  : bool
moveNext
peek()  : array<string|int, mixed>|null
Moves the lookahead token forward.
reset()  : void
Resets the lexer.
resetPeek()  : void
Resets the peek pointer to 0.
resetPosition()  : void
Resets the lexer position on the input to the given position.
setInput()  : void
Sets the input data to be tokenized.
skipUntil()  : void
Tells the lexer to skip input tokens until it sees a token with the given value.
getCatchablePatterns()  : array<string|int, string>
Lexical catchable patterns.
getModifiers()  : string
Regex modifiers
getNonCatchablePatterns()  : array<string|int, string>
Lexical non-catchable patterns.
getType()  : int
Retrieve token type. Also processes the token value if necessary.
isNullType()  : bool
isUTF8Invalid()  : bool
isValid()  : bool
scan()  : void
Scans the input string for tokens.

Constants

ASCII_INVALID_FROM

public mixed ASCII_INVALID_FROM = 127

ASCII_INVALID_TO

public mixed ASCII_INVALID_TO = 199

S_CLOSEBRACKET

public mixed S_CLOSEBRACKET = 263

S_CLOSEPARENTHESIS

public mixed S_CLOSEPARENTHESIS = 261

S_CLOSEQBRACKET

public mixed S_CLOSEQBRACKET = 277

S_OPENPARENTHESIS

public mixed S_OPENPARENTHESIS = 49

S_OPENQBRACKET

public mixed S_OPENQBRACKET = 276

Properties

$lookahead

The next token in the input.

public array<string|int, mixed>|null $lookahead

$token

The last matched/seen token.

public array<string|int, mixed> $token
Tags
psalm-var

array{value:string, type:null|int, position:int}

$charValue

US-ASCII visible characters not valid for atext (@link http://tools.ietf.org/html/rfc5322#section-3.2.3)

protected array<string|int, mixed> $charValue = array('(' => self::S_OPENPARENTHESIS, ')' => self::S_CLOSEPARENTHESIS, '<' => self::S_LOWERTHAN, '>' => self::S_GREATERTHAN, '[' => self::S_OPENBRACKET, ']' => self::S_CLOSEBRACKET, ':' => self::S_COLON, ';' => self::S_SEMICOLON, '@' => self::S_AT, '\' => self::S_BACKSLASH, '/' => self::S_SLASH, ',' => self::S_COMMA, '.' => self::S_DOT, "'" => self::S_SQUOTE, "`" => self::S_BACKTICK, '"' => self::S_DQUOTE, '-' => self::S_HYPHEN, '::' => self::S_DOUBLECOLON, ' ' => self::S_SP, " " => self::S_HTAB, " " => self::S_CR, " " => self::S_LF, " " => self::CRLF, 'IPv6' => self::S_IPV6TAG, '{' => self::S_OPENQBRACKET, '}' => self::S_CLOSEQBRACKET, '' => self::S_EMPTY, '\0' => self::C_NUL)

$hasInvalidTokens

protected bool $hasInvalidTokens = false

$previous

protected array<string|int, mixed> $previous = []
Tags
psalm-var

array{value:string, type:null|int, position:int}|array<empty, empty>

$nullToken

private static mixed $nullToken = ['value' => '', 'type' => null, 'position' => 0]
Tags
psalm-var

array{value:'', type:null, position:0}

$peek

Current peek of current lexer position.

private int $peek = 0

$position

Current lexer position in input string.

private int $position = 0

$tokens

Array of scanned tokens.

private array<string|int, mixed> $tokens = array()

Each token is an associative array containing three items:

  • 'value' : the string value of the token in the input string
  • 'type' : the type of the token (identifier, numeric, string, input parameter, none)
  • 'position' : the position of the token in the input string

Methods

__construct()

public __construct() : mixed
Return values
mixed

find()

public find(int $type) : bool
Parameters
$type : int
Tags
throws
UnexpectedValueException
psalm-suppress

InvalidScalarArgument

Return values
bool

getInputUntilPosition()

Retrieve the original lexer's input until a given position.

public getInputUntilPosition(int $position) : string
Parameters
$position : int
Return values
string

getLiteral()

Gets the literal for a given token.

public getLiteral(int $token) : string
Parameters
$token : int
Return values
string

getPrevious()

getPrevious

public getPrevious() : array<string|int, mixed>
Return values
array<string|int, mixed>

glimpse()

Peeks at the next token, returns it and immediately resets the peek.

public glimpse() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

The next token or NULL if there are no more tokens ahead.

hasInvalidTokens()

public hasInvalidTokens() : bool
Return values
bool

isA()

Checks if given value is identical to the given token.

public isA(mixed $value, int $token) : bool
Parameters
$value : mixed
$token : int
Return values
bool

isNextToken()

Checks whether a given token matches the current lookahead.

public isNextToken(int|string $token) : bool
Parameters
$token : int|string
Return values
bool

isNextTokenAny()

Checks whether any of the given tokens matches the current lookahead.

public isNextTokenAny(array<string|int, mixed> $tokens) : bool
Parameters
$tokens : array<string|int, mixed>
Return values
bool

moveNext()

moveNext

public moveNext() : bool
Return values
bool

peek()

Moves the lookahead token forward.

public peek() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

The next token or NULL if there are no more tokens ahead.

reset()

Resets the lexer.

public reset() : void
Return values
void

resetPeek()

Resets the peek pointer to 0.

public resetPeek() : void
Return values
void

resetPosition()

Resets the lexer position on the input to the given position.

public resetPosition(int $position) : void
Parameters
$position : int

Position to place the lexical scanner.

Return values
void

setInput()

Sets the input data to be tokenized.

public setInput(string $input) : void

The Lexer is immediately reset and the new input tokenized. Any unprocessed tokens from any previous input are lost.

Parameters
$input : string

The input to be tokenized.

Return values
void

skipUntil()

Tells the lexer to skip input tokens until it sees a token with the given value.

public skipUntil(string $type) : void
Parameters
$type : string

The token type to skip until.

Return values
void

getCatchablePatterns()

Lexical catchable patterns.

protected getCatchablePatterns() : array<string|int, string>
Return values
array<string|int, string>

getModifiers()

Regex modifiers

protected getModifiers() : string
Return values
string

getNonCatchablePatterns()

Lexical non-catchable patterns.

protected getNonCatchablePatterns() : array<string|int, string>
Return values
array<string|int, string>

getType()

Retrieve token type. Also processes the token value if necessary.

protected getType(string &$value) : int
Parameters
$value : string
Tags
throws
InvalidArgumentException
Return values
int

isNullType()

protected isNullType(string $value) : bool
Parameters
$value : string
Return values
bool

isUTF8Invalid()

protected isUTF8Invalid(string $value) : bool
Parameters
$value : string
Return values
bool

isValid()

protected isValid(string $value) : bool
Parameters
$value : string
Return values
bool

scan()

Scans the input string for tokens.

protected scan(string $input) : void
Parameters
$input : string

A query string.

Return values
void

Search results