TokenDomain
MMO\core\helpers · 1 symbol · generated 5 Oct 2026
TokenDomain
Tokenizer.php:523A "grammar": a list of recognized literal tokens (each a plain string, e.g. ',' or '::') and/or nested TokenDomain instances (which the tokenizer can Tokenizer::openDomain into via their own open check). $mask is a fast pre-filter -- the set of first-characters any of this domain's tokens (including nested domains') could possibly start with, used by Tokenizer::next to quickly skip over plain text.
- Namespace
MMO\core\helpers
Index
| mask | ||
| tokens | array<id: string> | |
| addChar($char) | Register a single-character token (id auto-derived from the character's ord() value). | |
| addDomains($domains) | Register one or more nested domains (their open is checked on every Tokenizer::next call while this domain is active). | |
| addToken($id, $token) | Register a single multi-character token. | |
| addTokens($tokens) | Register several tokens/domains at once. | |
| close($tokenizer) | Check whether the tokenizer's current position closes this domain (only ever called while this domain IS the Tokenizer::currentDomain). | |
| debugName() | ||
| getAllowedTokens() | ||
| getMask() | ||
| open($tokenizer) | Check whether the tokenizer's current position starts this (nested) domain -- called on every candidate sub-domain while Tokenizer::next looks for the next token. | |
| removeToken($token) | ||
| setTokens($tokens) | Replace every registered token/domain with $tokens. | |
| updateMask() | Recompute getMask from the current token/domain list. | |
| __construct($tokens) |
Properties2
mask
- Type
- string
tokens
array<id: string>
- Type
- array
Methods13
addChar($char)
Tokenizer.php:597Register a single-character token (id auto-derived from the character's ord() value).
addDomains($domains)
Tokenizer.php:587Register one or more nested domains (their open is checked on every Tokenizer::next call while this domain is active).
| ...$domains | TokenDomain | |
| returns | void |
addToken($id, $token)
Tokenizer.php:576Register a single multi-character token.
addTokens($tokens)
Tokenizer.php:632Register several tokens/domains at once.
close($tokenizer)
Tokenizer.php:561Check whether the tokenizer's current position closes this domain (only ever called while this domain IS the Tokenizer::currentDomain). The base implementation never closes (always null); a domain that's meant to be closable (e.g. quotes, brackets) overrides this.
debugName()
Tokenizer.php:534| returns | string | the class name (override for a more specific description) |
getAllowedTokens()
Tokenizer.php:539getMask()
Tokenizer.php:566| returns | string | every first-character any token/nested-domain in this domain could start with |
open($tokenizer)
Tokenizer.php:550Check whether the tokenizer's current position starts this (nested) domain -- called on every candidate sub-domain while Tokenizer::next looks for the next token. The base implementation never opens (always null); override in a subclass that represents a nested grammar (e.g. quotes, brackets).
removeToken($token)
Tokenizer.php:606| $token | TokenDomain | string | int | an id, a token string (found by value), or a nested domain (found by identity) |
| returns | TokenDomain | string | null | the removed entry, or null if not found |
setTokens($tokens)
Tokenizer.php:619Replace every registered token/domain with $tokens.
updateMask()
Tokenizer.php:649Recompute getMask from the current token/domain list. Called automatically by every mutator above; only needs to be called directly if $tokens was somehow changed without going through them.
| returns | void |
__construct($tokens)
Tokenizer.php:529| $tokens = [] | array | id => token-string entries, plain token strings (id auto-derived), and/or TokenDomain instances |