You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

560 lines
24 KiB

3 years ago
  1. <?php declare(strict_types=1);
  2. namespace PhpParser;
  3. use PhpParser\Parser\Tokens;
  4. class Lexer
  5. {
  6. protected $code;
  7. protected $tokens;
  8. protected $pos;
  9. protected $line;
  10. protected $filePos;
  11. protected $prevCloseTagHasNewline;
  12. protected $tokenMap;
  13. protected $dropTokens;
  14. protected $identifierTokens;
  15. private $attributeStartLineUsed;
  16. private $attributeEndLineUsed;
  17. private $attributeStartTokenPosUsed;
  18. private $attributeEndTokenPosUsed;
  19. private $attributeStartFilePosUsed;
  20. private $attributeEndFilePosUsed;
  21. private $attributeCommentsUsed;
  22. /**
  23. * Creates a Lexer.
  24. *
  25. * @param array $options Options array. Currently only the 'usedAttributes' option is supported,
  26. * which is an array of attributes to add to the AST nodes. Possible
  27. * attributes are: 'comments', 'startLine', 'endLine', 'startTokenPos',
  28. * 'endTokenPos', 'startFilePos', 'endFilePos'. The option defaults to the
  29. * first three. For more info see getNextToken() docs.
  30. */
  31. public function __construct(array $options = []) {
  32. // Create Map from internal tokens to PhpParser tokens.
  33. $this->defineCompatibilityTokens();
  34. $this->tokenMap = $this->createTokenMap();
  35. $this->identifierTokens = $this->createIdentifierTokenMap();
  36. // map of tokens to drop while lexing (the map is only used for isset lookup,
  37. // that's why the value is simply set to 1; the value is never actually used.)
  38. $this->dropTokens = array_fill_keys(
  39. [\T_WHITESPACE, \T_OPEN_TAG, \T_COMMENT, \T_DOC_COMMENT, \T_BAD_CHARACTER], 1
  40. );
  41. $defaultAttributes = ['comments', 'startLine', 'endLine'];
  42. $usedAttributes = array_fill_keys($options['usedAttributes'] ?? $defaultAttributes, true);
  43. // Create individual boolean properties to make these checks faster.
  44. $this->attributeStartLineUsed = isset($usedAttributes['startLine']);
  45. $this->attributeEndLineUsed = isset($usedAttributes['endLine']);
  46. $this->attributeStartTokenPosUsed = isset($usedAttributes['startTokenPos']);
  47. $this->attributeEndTokenPosUsed = isset($usedAttributes['endTokenPos']);
  48. $this->attributeStartFilePosUsed = isset($usedAttributes['startFilePos']);
  49. $this->attributeEndFilePosUsed = isset($usedAttributes['endFilePos']);
  50. $this->attributeCommentsUsed = isset($usedAttributes['comments']);
  51. }
  52. /**
  53. * Initializes the lexer for lexing the provided source code.
  54. *
  55. * This function does not throw if lexing errors occur. Instead, errors may be retrieved using
  56. * the getErrors() method.
  57. *
  58. * @param string $code The source code to lex
  59. * @param ErrorHandler|null $errorHandler Error handler to use for lexing errors. Defaults to
  60. * ErrorHandler\Throwing
  61. */
  62. public function startLexing(string $code, ErrorHandler $errorHandler = null) {
  63. if (null === $errorHandler) {
  64. $errorHandler = new ErrorHandler\Throwing();
  65. }
  66. $this->code = $code; // keep the code around for __halt_compiler() handling
  67. $this->pos = -1;
  68. $this->line = 1;
  69. $this->filePos = 0;
  70. // If inline HTML occurs without preceding code, treat it as if it had a leading newline.
  71. // This ensures proper composability, because having a newline is the "safe" assumption.
  72. $this->prevCloseTagHasNewline = true;
  73. $scream = ini_set('xdebug.scream', '0');
  74. $this->tokens = @token_get_all($code);
  75. $this->postprocessTokens($errorHandler);
  76. if (false !== $scream) {
  77. ini_set('xdebug.scream', $scream);
  78. }
  79. }
  80. private function handleInvalidCharacterRange($start, $end, $line, ErrorHandler $errorHandler) {
  81. $tokens = [];
  82. for ($i = $start; $i < $end; $i++) {
  83. $chr = $this->code[$i];
  84. if ($chr === "\0") {
  85. // PHP cuts error message after null byte, so need special case
  86. $errorMsg = 'Unexpected null byte';
  87. } else {
  88. $errorMsg = sprintf(
  89. 'Unexpected character "%s" (ASCII %d)', $chr, ord($chr)
  90. );
  91. }
  92. $tokens[] = [\T_BAD_CHARACTER, $chr, $line];
  93. $errorHandler->handleError(new Error($errorMsg, [
  94. 'startLine' => $line,
  95. 'endLine' => $line,
  96. 'startFilePos' => $i,
  97. 'endFilePos' => $i,
  98. ]));
  99. }
  100. return $tokens;
  101. }
  102. /**
  103. * Check whether comment token is unterminated.
  104. *
  105. * @return bool
  106. */
  107. private function isUnterminatedComment($token) : bool {
  108. return ($token[0] === \T_COMMENT || $token[0] === \T_DOC_COMMENT)
  109. && substr($token[1], 0, 2) === '/*'
  110. && substr($token[1], -2) !== '*/';
  111. }
  112. protected function postprocessTokens(ErrorHandler $errorHandler) {
  113. // PHP's error handling for token_get_all() is rather bad, so if we want detailed
  114. // error information we need to compute it ourselves. Invalid character errors are
  115. // detected by finding "gaps" in the token array. Unterminated comments are detected
  116. // by checking if a trailing comment has a "*/" at the end.
  117. //
  118. // Additionally, we perform a number of canonicalizations here:
  119. // * Use the PHP 8.0 comment format, which does not include trailing whitespace anymore.
  120. // * Use PHP 8.0 T_NAME_* tokens.
  121. // * Use PHP 8.1 T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG and
  122. // T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG tokens used to disambiguate intersection types.
  123. $filePos = 0;
  124. $line = 1;
  125. $numTokens = \count($this->tokens);
  126. for ($i = 0; $i < $numTokens; $i++) {
  127. $token = $this->tokens[$i];
  128. // Since PHP 7.4 invalid characters are represented by a T_BAD_CHARACTER token.
  129. // In this case we only need to emit an error.
  130. if ($token[0] === \T_BAD_CHARACTER) {
  131. $this->handleInvalidCharacterRange($filePos, $filePos + 1, $line, $errorHandler);
  132. }
  133. if ($token[0] === \T_COMMENT && substr($token[1], 0, 2) !== '/*'
  134. && preg_match('/(\r\n|\n|\r)$/D', $token[1], $matches)) {
  135. $trailingNewline = $matches[0];
  136. $token[1] = substr($token[1], 0, -strlen($trailingNewline));
  137. $this->tokens[$i] = $token;
  138. if (isset($this->tokens[$i + 1]) && $this->tokens[$i + 1][0] === \T_WHITESPACE) {
  139. // Move trailing newline into following T_WHITESPACE token, if it already exists.
  140. $this->tokens[$i + 1][1] = $trailingNewline . $this->tokens[$i + 1][1];
  141. $this->tokens[$i + 1][2]--;
  142. } else {
  143. // Otherwise, we need to create a new T_WHITESPACE token.
  144. array_splice($this->tokens, $i + 1, 0, [
  145. [\T_WHITESPACE, $trailingNewline, $line],
  146. ]);
  147. $numTokens++;
  148. }
  149. }
  150. // Emulate PHP 8 T_NAME_* tokens, by combining sequences of T_NS_SEPARATOR and T_STRING
  151. // into a single token.
  152. if (\is_array($token)
  153. && ($token[0] === \T_NS_SEPARATOR || isset($this->identifierTokens[$token[0]]))) {
  154. $lastWasSeparator = $token[0] === \T_NS_SEPARATOR;
  155. $text = $token[1];
  156. for ($j = $i + 1; isset($this->tokens[$j]); $j++) {
  157. if ($lastWasSeparator) {
  158. if (!isset($this->identifierTokens[$this->tokens[$j][0]])) {
  159. break;
  160. }
  161. $lastWasSeparator = false;
  162. } else {
  163. if ($this->tokens[$j][0] !== \T_NS_SEPARATOR) {
  164. break;
  165. }
  166. $lastWasSeparator = true;
  167. }
  168. $text .= $this->tokens[$j][1];
  169. }
  170. if ($lastWasSeparator) {
  171. // Trailing separator is not part of the name.
  172. $j--;
  173. $text = substr($text, 0, -1);
  174. }
  175. if ($j > $i + 1) {
  176. if ($token[0] === \T_NS_SEPARATOR) {
  177. $type = \T_NAME_FULLY_QUALIFIED;
  178. } else if ($token[0] === \T_NAMESPACE) {
  179. $type = \T_NAME_RELATIVE;
  180. } else {
  181. $type = \T_NAME_QUALIFIED;
  182. }
  183. $token = [$type, $text, $line];
  184. array_splice($this->tokens, $i, $j - $i, [$token]);
  185. $numTokens -= $j - $i - 1;
  186. }
  187. }
  188. if ($token === '&') {
  189. $next = $i + 1;
  190. while (isset($this->tokens[$next]) && $this->tokens[$next][0] === \T_WHITESPACE) {
  191. $next++;
  192. }
  193. $followedByVarOrVarArg = isset($this->tokens[$next]) &&
  194. ($this->tokens[$next][0] === \T_VARIABLE || $this->tokens[$next][0] === \T_ELLIPSIS);
  195. $this->tokens[$i] = $token = [
  196. $followedByVarOrVarArg
  197. ? \T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG
  198. : \T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG,
  199. '&',
  200. $line,
  201. ];
  202. }
  203. $tokenValue = \is_string($token) ? $token : $token[1];
  204. $tokenLen = \strlen($tokenValue);
  205. if (substr($this->code, $filePos, $tokenLen) !== $tokenValue) {
  206. // Something is missing, must be an invalid character
  207. $nextFilePos = strpos($this->code, $tokenValue, $filePos);
  208. $badCharTokens = $this->handleInvalidCharacterRange(
  209. $filePos, $nextFilePos, $line, $errorHandler);
  210. $filePos = (int) $nextFilePos;
  211. array_splice($this->tokens, $i, 0, $badCharTokens);
  212. $numTokens += \count($badCharTokens);
  213. $i += \count($badCharTokens);
  214. }
  215. $filePos += $tokenLen;
  216. $line += substr_count($tokenValue, "\n");
  217. }
  218. if ($filePos !== \strlen($this->code)) {
  219. if (substr($this->code, $filePos, 2) === '/*') {
  220. // Unlike PHP, HHVM will drop unterminated comments entirely
  221. $comment = substr($this->code, $filePos);
  222. $errorHandler->handleError(new Error('Unterminated comment', [
  223. 'startLine' => $line,
  224. 'endLine' => $line + substr_count($comment, "\n"),
  225. 'startFilePos' => $filePos,
  226. 'endFilePos' => $filePos + \strlen($comment),
  227. ]));
  228. // Emulate the PHP behavior
  229. $isDocComment = isset($comment[3]) && $comment[3] === '*';
  230. $this->tokens[] = [$isDocComment ? \T_DOC_COMMENT : \T_COMMENT, $comment, $line];
  231. } else {
  232. // Invalid characters at the end of the input
  233. $badCharTokens = $this->handleInvalidCharacterRange(
  234. $filePos, \strlen($this->code), $line, $errorHandler);
  235. $this->tokens = array_merge($this->tokens, $badCharTokens);
  236. }
  237. return;
  238. }
  239. if (count($this->tokens) > 0) {
  240. // Check for unterminated comment
  241. $lastToken = $this->tokens[count($this->tokens) - 1];
  242. if ($this->isUnterminatedComment($lastToken)) {
  243. $errorHandler->handleError(new Error('Unterminated comment', [
  244. 'startLine' => $line - substr_count($lastToken[1], "\n"),
  245. 'endLine' => $line,
  246. 'startFilePos' => $filePos - \strlen($lastToken[1]),
  247. 'endFilePos' => $filePos,
  248. ]));
  249. }
  250. }
  251. }
  252. /**
  253. * Fetches the next token.
  254. *
  255. * The available attributes are determined by the 'usedAttributes' option, which can
  256. * be specified in the constructor. The following attributes are supported:
  257. *
  258. * * 'comments' => Array of PhpParser\Comment or PhpParser\Comment\Doc instances,
  259. * representing all comments that occurred between the previous
  260. * non-discarded token and the current one.
  261. * * 'startLine' => Line in which the node starts.
  262. * * 'endLine' => Line in which the node ends.
  263. * * 'startTokenPos' => Offset into the token array of the first token in the node.
  264. * * 'endTokenPos' => Offset into the token array of the last token in the node.
  265. * * 'startFilePos' => Offset into the code string of the first character that is part of the node.
  266. * * 'endFilePos' => Offset into the code string of the last character that is part of the node.
  267. *
  268. * @param mixed $value Variable to store token content in
  269. * @param mixed $startAttributes Variable to store start attributes in
  270. * @param mixed $endAttributes Variable to store end attributes in
  271. *
  272. * @return int Token id
  273. */
  274. public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) : int {
  275. $startAttributes = [];
  276. $endAttributes = [];
  277. while (1) {
  278. if (isset($this->tokens[++$this->pos])) {
  279. $token = $this->tokens[$this->pos];
  280. } else {
  281. // EOF token with ID 0
  282. $token = "\0";
  283. }
  284. if ($this->attributeStartLineUsed) {
  285. $startAttributes['startLine'] = $this->line;
  286. }
  287. if ($this->attributeStartTokenPosUsed) {
  288. $startAttributes['startTokenPos'] = $this->pos;
  289. }
  290. if ($this->attributeStartFilePosUsed) {
  291. $startAttributes['startFilePos'] = $this->filePos;
  292. }
  293. if (\is_string($token)) {
  294. $value = $token;
  295. if (isset($token[1])) {
  296. // bug in token_get_all
  297. $this->filePos += 2;
  298. $id = ord('"');
  299. } else {
  300. $this->filePos += 1;
  301. $id = ord($token);
  302. }
  303. } elseif (!isset($this->dropTokens[$token[0]])) {
  304. $value = $token[1];
  305. $id = $this->tokenMap[$token[0]];
  306. if (\T_CLOSE_TAG === $token[0]) {
  307. $this->prevCloseTagHasNewline = false !== strpos($token[1], "\n")
  308. || false !== strpos($token[1], "\r");
  309. } elseif (\T_INLINE_HTML === $token[0]) {
  310. $startAttributes['hasLeadingNewline'] = $this->prevCloseTagHasNewline;
  311. }
  312. $this->line += substr_count($value, "\n");
  313. $this->filePos += \strlen($value);
  314. } else {
  315. $origLine = $this->line;
  316. $origFilePos = $this->filePos;
  317. $this->line += substr_count($token[1], "\n");
  318. $this->filePos += \strlen($token[1]);
  319. if (\T_COMMENT === $token[0] || \T_DOC_COMMENT === $token[0]) {
  320. if ($this->attributeCommentsUsed) {
  321. $comment = \T_DOC_COMMENT === $token[0]
  322. ? new Comment\Doc($token[1],
  323. $origLine, $origFilePos, $this->pos,
  324. $this->line, $this->filePos - 1, $this->pos)
  325. : new Comment($token[1],
  326. $origLine, $origFilePos, $this->pos,
  327. $this->line, $this->filePos - 1, $this->pos);
  328. $startAttributes['comments'][] = $comment;
  329. }
  330. }
  331. continue;
  332. }
  333. if ($this->attributeEndLineUsed) {
  334. $endAttributes['endLine'] = $this->line;
  335. }
  336. if ($this->attributeEndTokenPosUsed) {
  337. $endAttributes['endTokenPos'] = $this->pos;
  338. }
  339. if ($this->attributeEndFilePosUsed) {
  340. $endAttributes['endFilePos'] = $this->filePos - 1;
  341. }
  342. return $id;
  343. }
  344. throw new \RuntimeException('Reached end of lexer loop');
  345. }
  346. /**
  347. * Returns the token array for current code.
  348. *
  349. * The token array is in the same format as provided by the
  350. * token_get_all() function and does not discard tokens (i.e.
  351. * whitespace and comments are included). The token position
  352. * attributes are against this token array.
  353. *
  354. * @return array Array of tokens in token_get_all() format
  355. */
  356. public function getTokens() : array {
  357. return $this->tokens;
  358. }
  359. /**
  360. * Handles __halt_compiler() by returning the text after it.
  361. *
  362. * @return string Remaining text
  363. */
  364. public function handleHaltCompiler() : string {
  365. // text after T_HALT_COMPILER, still including ();
  366. $textAfter = substr($this->code, $this->filePos);
  367. // ensure that it is followed by ();
  368. // this simplifies the situation, by not allowing any comments
  369. // in between of the tokens.
  370. if (!preg_match('~^\s*\(\s*\)\s*(?:;|\?>\r?\n?)~', $textAfter, $matches)) {
  371. throw new Error('__HALT_COMPILER must be followed by "();"');
  372. }
  373. // prevent the lexer from returning any further tokens
  374. $this->pos = count($this->tokens);
  375. // return with (); removed
  376. return substr($textAfter, strlen($matches[0]));
  377. }
  378. private function defineCompatibilityTokens() {
  379. static $compatTokensDefined = false;
  380. if ($compatTokensDefined) {
  381. return;
  382. }
  383. $compatTokens = [
  384. // PHP 7.4
  385. 'T_BAD_CHARACTER',
  386. 'T_FN',
  387. 'T_COALESCE_EQUAL',
  388. // PHP 8.0
  389. 'T_NAME_QUALIFIED',
  390. 'T_NAME_FULLY_QUALIFIED',
  391. 'T_NAME_RELATIVE',
  392. 'T_MATCH',
  393. 'T_NULLSAFE_OBJECT_OPERATOR',
  394. 'T_ATTRIBUTE',
  395. // PHP 8.1
  396. 'T_ENUM',
  397. 'T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG',
  398. 'T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG',
  399. 'T_READONLY',
  400. ];
  401. // PHP-Parser might be used together with another library that also emulates some or all
  402. // of these tokens. Perform a sanity-check that all already defined tokens have been
  403. // assigned a unique ID.
  404. $usedTokenIds = [];
  405. foreach ($compatTokens as $token) {
  406. if (\defined($token)) {
  407. $tokenId = \constant($token);
  408. $clashingToken = $usedTokenIds[$tokenId] ?? null;
  409. if ($clashingToken !== null) {
  410. throw new \Error(sprintf(
  411. 'Token %s has same ID as token %s, ' .
  412. 'you may be using a library with broken token emulation',
  413. $token, $clashingToken
  414. ));
  415. }
  416. $usedTokenIds[$tokenId] = $token;
  417. }
  418. }
  419. // Now define any tokens that have not yet been emulated. Try to assign IDs from -1
  420. // downwards, but skip any IDs that may already be in use.
  421. $newTokenId = -1;
  422. foreach ($compatTokens as $token) {
  423. if (!\defined($token)) {
  424. while (isset($usedTokenIds[$newTokenId])) {
  425. $newTokenId--;
  426. }
  427. \define($token, $newTokenId);
  428. $newTokenId--;
  429. }
  430. }
  431. $compatTokensDefined = true;
  432. }
  433. /**
  434. * Creates the token map.
  435. *
  436. * The token map maps the PHP internal token identifiers
  437. * to the identifiers used by the Parser. Additionally it
  438. * maps T_OPEN_TAG_WITH_ECHO to T_ECHO and T_CLOSE_TAG to ';'.
  439. *
  440. * @return array The token map
  441. */
  442. protected function createTokenMap() : array {
  443. $tokenMap = [];
  444. // 256 is the minimum possible token number, as everything below
  445. // it is an ASCII value
  446. for ($i = 256; $i < 1000; ++$i) {
  447. if (\T_DOUBLE_COLON === $i) {
  448. // T_DOUBLE_COLON is equivalent to T_PAAMAYIM_NEKUDOTAYIM
  449. $tokenMap[$i] = Tokens::T_PAAMAYIM_NEKUDOTAYIM;
  450. } elseif(\T_OPEN_TAG_WITH_ECHO === $i) {
  451. // T_OPEN_TAG_WITH_ECHO with dropped T_OPEN_TAG results in T_ECHO
  452. $tokenMap[$i] = Tokens::T_ECHO;
  453. } elseif(\T_CLOSE_TAG === $i) {
  454. // T_CLOSE_TAG is equivalent to ';'
  455. $tokenMap[$i] = ord(';');
  456. } elseif ('UNKNOWN' !== $name = token_name($i)) {
  457. if ('T_HASHBANG' === $name) {
  458. // HHVM uses a special token for #! hashbang lines
  459. $tokenMap[$i] = Tokens::T_INLINE_HTML;
  460. } elseif (defined($name = Tokens::class . '::' . $name)) {
  461. // Other tokens can be mapped directly
  462. $tokenMap[$i] = constant($name);
  463. }
  464. }
  465. }
  466. // HHVM uses a special token for numbers that overflow to double
  467. if (defined('T_ONUMBER')) {
  468. $tokenMap[\T_ONUMBER] = Tokens::T_DNUMBER;
  469. }
  470. // HHVM also has a separate token for the __COMPILER_HALT_OFFSET__ constant
  471. if (defined('T_COMPILER_HALT_OFFSET')) {
  472. $tokenMap[\T_COMPILER_HALT_OFFSET] = Tokens::T_STRING;
  473. }
  474. // Assign tokens for which we define compatibility constants, as token_name() does not know them.
  475. $tokenMap[\T_FN] = Tokens::T_FN;
  476. $tokenMap[\T_COALESCE_EQUAL] = Tokens::T_COALESCE_EQUAL;
  477. $tokenMap[\T_NAME_QUALIFIED] = Tokens::T_NAME_QUALIFIED;
  478. $tokenMap[\T_NAME_FULLY_QUALIFIED] = Tokens::T_NAME_FULLY_QUALIFIED;
  479. $tokenMap[\T_NAME_RELATIVE] = Tokens::T_NAME_RELATIVE;
  480. $tokenMap[\T_MATCH] = Tokens::T_MATCH;
  481. $tokenMap[\T_NULLSAFE_OBJECT_OPERATOR] = Tokens::T_NULLSAFE_OBJECT_OPERATOR;
  482. $tokenMap[\T_ATTRIBUTE] = Tokens::T_ATTRIBUTE;
  483. $tokenMap[\T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG] = Tokens::T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG;
  484. $tokenMap[\T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG] = Tokens::T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG;
  485. $tokenMap[\T_ENUM] = Tokens::T_ENUM;
  486. $tokenMap[\T_READONLY] = Tokens::T_READONLY;
  487. return $tokenMap;
  488. }
  489. private function createIdentifierTokenMap(): array {
  490. // Based on semi_reserved production.
  491. return array_fill_keys([
  492. \T_STRING,
  493. \T_STATIC, \T_ABSTRACT, \T_FINAL, \T_PRIVATE, \T_PROTECTED, \T_PUBLIC, \T_READONLY,
  494. \T_INCLUDE, \T_INCLUDE_ONCE, \T_EVAL, \T_REQUIRE, \T_REQUIRE_ONCE, \T_LOGICAL_OR, \T_LOGICAL_XOR, \T_LOGICAL_AND,
  495. \T_INSTANCEOF, \T_NEW, \T_CLONE, \T_EXIT, \T_IF, \T_ELSEIF, \T_ELSE, \T_ENDIF, \T_ECHO, \T_DO, \T_WHILE,
  496. \T_ENDWHILE, \T_FOR, \T_ENDFOR, \T_FOREACH, \T_ENDFOREACH, \T_DECLARE, \T_ENDDECLARE, \T_AS, \T_TRY, \T_CATCH,
  497. \T_FINALLY, \T_THROW, \T_USE, \T_INSTEADOF, \T_GLOBAL, \T_VAR, \T_UNSET, \T_ISSET, \T_EMPTY, \T_CONTINUE, \T_GOTO,
  498. \T_FUNCTION, \T_CONST, \T_RETURN, \T_PRINT, \T_YIELD, \T_LIST, \T_SWITCH, \T_ENDSWITCH, \T_CASE, \T_DEFAULT,
  499. \T_BREAK, \T_ARRAY, \T_CALLABLE, \T_EXTENDS, \T_IMPLEMENTS, \T_NAMESPACE, \T_TRAIT, \T_INTERFACE, \T_CLASS,
  500. \T_CLASS_C, \T_TRAIT_C, \T_FUNC_C, \T_METHOD_C, \T_LINE, \T_FILE, \T_DIR, \T_NS_C, \T_HALT_COMPILER, \T_FN,
  501. \T_MATCH,
  502. ], true);
  503. }
  504. }