File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -396,6 +396,26 @@ private function eat1($kind) {
396396 return new MissingToken ($ kind , $ token ->fullStart );
397397 }
398398
399+ /**
400+ * Retrieve the current token, and check that it's of the kind $kind.
401+ * If so, advance and return the token. Otherwise return a MissingToken for
402+ * the expected token.
403+ *
404+ * This is faster than calling eat() if there is a single token.
405+ *
406+ * @param int $kind
407+ * @return Token
408+ */
409+ private function eat1 ($ kind ) {
410+ $ token = $ this ->token ;
411+ if ($ token ->kind === $ kind ) {
412+ $ this ->token = $ this ->lexer ->scanNextToken ();
413+ return $ token ;
414+ }
415+ // TODO include optional grouping for token kinds
416+ return new MissingToken ($ kind , $ token ->fullStart );
417+ }
418+
399419 /**
400420 * @param int|int[] ...$kinds (Can provide a single value with a list of kinds, or multiple kinds)
401421 * @return Token|null
You can’t perform that action at this time.
0 commit comments