Home
last modified time | relevance | path

Searched refs:token (Results 1 – 20 of 20) sorted by relevance

/PHP-Parser/test/PhpParser/
H A DTokenTest.php7 $token = new Token(\ord(','), ',');
9 $token = new Token(\T_WHITESPACE, ' ');
14 $token = new Token(\ord(','), ',');
15 $this->assertTrue($token->is(\ord(',')));
16 $this->assertFalse($token->is(\ord(';')));
17 $this->assertTrue($token->is(','));
18 $this->assertFalse($token->is(';'));
27 $token = new Token($id, $text);
42 $token = new Token(\ord(','), ',');
43 $this->assertSame(',', (string) $token);
[all …]
H A DLexerTest.php61 foreach ($tokens as $token) {
62 if ($token->id === 0 || $token->isIgnorable()) {
68 $this->assertSame($expectedToken[0], $token->id);
69 $this->assertSame($expectedToken[1], $token->text);
/PHP-Parser/lib/PhpParser/NodeVisitor/
H A DCommentAnnotatingVisitor.php28 foreach ($tokens as $i => $token) {
29 if ($token->id === \T_COMMENT || $token->id === \T_DOC_COMMENT) {
47 $token = $this->tokens[$pos];
48 if ($token->id === \T_DOC_COMMENT) {
50 $token->text, $token->line, $token->pos, $pos,
51 $token->getEndLine(), $token->getEndPos() - 1, $pos);
54 if ($token->id === \T_COMMENT) {
56 $token->text, $token->line, $token->pos, $pos,
57 $token->getEndLine(), $token->getEndPos() - 1, $pos);
60 if ($token->id !== \T_WHITESPACE) {
/PHP-Parser/lib/PhpParser/
H A Dcompatibility_tokens.php31 foreach ($compatTokens as $token) {
32 if (\defined($token)) {
33 $tokenId = \constant($token);
38 $token, \gettype($tokenId)
46 $token, $clashingToken
49 $usedTokenIds[$tokenId] = $token;
56 foreach ($compatTokens as $token) {
57 if (!\defined($token)) {
61 \define($token, $newTokenId);
H A DLexer.php42 $chr = $token->text;
53 'startLine' => $token->line,
54 'endLine' => $token->line,
55 'startFilePos' => $token->pos,
56 'endFilePos' => $token->pos,
62 && substr($token->text, 0, 2) === '/*'
63 && substr($token->text, -2) !== '*/';
84 $token = $tokens[$i];
85 if ($token->id === \T_BAD_CHARACTER) {
89 if ($token->id === \ord('&')) {
[all …]
H A DParserAbstract.php503 $token = $this->tokens[$tokenPos];
505 'startLine' => $token->line,
507 'startFilePos' => $token->pos,
508 'endLine' => $token->line,
510 'endFilePos' => $token->pos,
892 assert($token->id === \T_COMMENT || $token->id == \T_DOC_COMMENT);
894 ? new Comment\Doc($token->text, $token->line, $token->pos, $tokenPos,
895 $token->getEndLine(), $token->getEndPos() - 1, $tokenPos)
896 : new Comment($token->text, $token->line, $token->pos, $tokenPos,
897 $token->getEndLine(), $token->getEndPos() - 1, $tokenPos);
[all …]
/PHP-Parser/lib/PhpParser/Lexer/TokenEmulator/
H A DNullsafeTokenEmulator.php21 $token = $tokens[$i];
22 …if ($token->text === '?' && isset($tokens[$i + 1]) && $tokens[$i + 1]->id === \T_OBJECT_OPERATOR) {
24 new Token(\T_NULLSAFE_OBJECT_OPERATOR, '?->', $token->line, $token->pos),
31 if ($token->id === \T_ENCAPSED_AND_WHITESPACE && isset($tokens[$i - 1])
33 … && preg_match('/^\?->([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/', $token->text, $matches)
36 new Token(\T_NULLSAFE_OBJECT_OPERATOR, '?->', $token->line, $token->pos),
37 new Token(\T_STRING, $matches[1], $token->line, $token->pos + 3),
40 if ($matchLen !== \strlen($token->text)) {
43 \substr($token->text, $matchLen),
44 $token->line, $token->pos + $matchLen
H A DAsymmetricVisibilityTokenEmulator.php26 $token = $tokens[$i];
27 if (isset($map[$token->id]) && $i + 3 < $c && $tokens[$i + 1]->text === '(' &&
34 $map[$token->id], $token->text . '(' . $tokens[$i + 2]->text . ')',
35 $token->line, $token->pos),
51 $token = $tokens[$i];
52 if (isset($reverseMap[$token->id]) &&
53 \preg_match('/(public|protected|private)\((set)\)/i', $token->text, $matches)
58 new Token($reverseMap[$token->id], $modifier, $token->line, $token->pos),
59 new Token(\ord('('), '(', $token->line, $token->pos + $modifierLen),
60 new Token(\T_STRING, $set, $token->line, $token->pos + $modifierLen + 1),
[all …]
H A DKeywordEmulator.php27 foreach ($tokens as $i => $token) {
28 if ($token->id === T_STRING && strtolower($token->text) === $keywordString
30 $token->id = $this->getKeywordToken();
52 foreach ($tokens as $token) {
53 if ($token->id === $keywordToken) {
54 $token->id = \T_STRING;
H A DExplicitOctalEmulator.php19 $token = $tokens[$i];
20 if ($token->id == \T_LNUMBER && $token->text === '0' &&
26 new Token($tokenKind, '0' . $tokens[$i + 1]->text, $token->line, $token->pos),
H A DAttributeEmulator.php21 $token = $tokens[$i];
22 if ($token->text === '#' && isset($tokens[$i + 1]) && $tokens[$i + 1]->text === '[') {
24 new Token(\T_ATTRIBUTE, '#[', $token->line, $token->pos),
/PHP-Parser/grammar/
H A Dphp.y40 %token T_EXIT
41 %token T_IF
54 %token T_ECHO
55 %token T_DO
58 %token T_FOR
64 %token T_AS
74 %token T_FN
77 %token T_TRY
81 %token T_USE
88 %token T_VAR
[all …]
/PHP-Parser/lib/PhpParser/Internal/
H A DTokenStream.php65 $token = $tokens[$pos];
66 if ($token->is($expectedTokenType)) {
69 if (!$token->isIgnorable()) {
90 $token = $tokens[$pos];
91 if ($token->is($expectedTokenType)) {
94 if (!$token->isIgnorable()) {
227 $token = $tokens[$pos];
228 $id = $token->id;
229 $text = $token->text;
257 if ($token->id === \T_WHITESPACE) {
[all …]
H A DTokenPolyfill.php134 $token = $origTokens[$i];
135 if (\is_string($token)) {
136 if (\strlen($token) === 2) {
138 $tokens[] = new static(\ord('"'), $token, $line, $pos);
141 $tokens[] = new static(\ord($token), $token, $line, $pos);
145 $id = $token[0];
146 $text = $token[1];
/PHP-Parser/lib/PhpParser/Lexer/
H A DEmulative.php138 $token = $tokens[$i];
139 $pos = $token->pos;
140 $token->pos += $posDelta;
141 $token->line += $lineDelta;
143 $len = \strlen($token->text);
154 $token->text = substr_replace(
155 $token->text, '', $patchPos - $pos + $localPosDelta, $patchTextLen
162 $token->text = substr_replace(
163 $token->text, $patchText, $patchPos - $pos + $localPosDelta, 0
169 $token->text = substr_replace(
[all …]
/PHP-Parser/doc/component/
H A DLexer.markdown20 part of a following `T_WHITESPACE` token.
47 /** @var string The textual content of the token. */
49 /** @var int The 1-based starting line of the token (or -1 if unknown). */
51 /** @var int The 0-based starting position of the token (or -1 if unknown). */
59 Unlike PHP's own `PhpToken::tokenize()` output, the token array is terminated by a sentinel token w…
69 …* `startTokenPos`: Offset into the token array of the first token in the node. Used by `$node->get…
70 …* `endTokenPos`: Offset into the token array of the last token in the node. Used by `$node->getEnd…
75 token will have `startTokenPos == endTokenPos` rather than `startTokenPos + 1 == endTokenPos`. This…
78 ### Using token positions
85 The token offset information is useful if you wish to examine the exact formatting used for a node.…
[all …]
/PHP-Parser/test/PhpParser/Lexer/
H A DEmulativeTest.php123 foreach ($tokens as $token) {
124 if ($token->id === 0 || $token->isIgnorable()) {
127 $reducedTokens[] = [$token->id, $token->text];
/PHP-Parser/doc/
H A D0_Introduction.markdown14 token stream generated by [`token_get_all`][2]. The token stream is much more low level than
16 a file. On the other hand, the token stream is much harder to deal with for more complex analysis.
/PHP-Parser/
H A DUPGRADE-5.0.md471 ### Changes to token representation
488 The token array is now an array of `Token`s, rather than an array of arrays and strings.
489 Additionally, the token array is now terminated by a sentinel token with ID 0.
H A DCHANGELOG.md243 * The internal token representation now uses a `PhpParser\Token` class, which is compatible with
244 PHP 8 token representation (`PhpToken`).
412 * Fixed check for token emulation conflicts with other libraries.
426 * Fix incorrect case-sensitivity in keyword token emulation.
536 * Added end line, token position and file position information for comments.
761 * Added start token offsets to comments.
914 * `Error` nodes are now considered empty, while previously they extended until the token where the

Completed in 44 milliseconds