Token class.
Class to handle tokens, i.e. discrete pieces of the input string that has specific meaning.
MathParser\Lexing\Token::__construct |
( |
|
$value, |
|
|
|
$type, |
|
|
|
$match = null |
|
) |
| |
Public constructor.
Create a token with a given value and type, as well as an optional 'match' which is the actual character string matching the token definition. Most of the time, $value and $match are the same, but in order to handle token synonyms, they may be different.
As an example illustrating the above, the natural logarithm can be denoted ln() as well as log(). In order to standardize the token list, both inputs might generate a token with value 'log' and type TokenType::FunctionName, but the match parameter will be the actual string matched, i.e. 'log' and 'ln', respectively, so that the token knows its own length so that the rest of the input string will be handled correctly.
- Parameters
-
string | $value | Standardized value of Token |
int | $type | Token type, as defined by the TokenType class |
string | $match | Optional actual match in the input string |
static MathParser\Lexing\Token::canFactorsInImplicitMultiplication |
( |
|
$token1, |
|
|
|
$token2 |
|
) |
| |
|
static |
Helper function, determining whether a pair of tokens can form an implicit multiplication.
Mathematical shorthand writing often leaves out explicit multiplication symbols, writing "2x" instead of "2*x" or "2 \cdot x". The parser accepts implicit multiplication if the first token is a nullary operator or a a closing parenthesis, and the second token is a nullary operator or an opening parenthesis. (Unless the first token is a a function name, and the second is an opening parentheis.)
- Return values
-