ConcreteLexer.php 881 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Doctrine\Tests\Common\Lexer;
  3. use Doctrine\Common\Lexer\AbstractLexer;
  4. class ConcreteLexer extends AbstractLexer
  5. {
  6. const INT = 'int';
  7. protected function getCatchablePatterns()
  8. {
  9. return array(
  10. '=|<|>',
  11. '[a-z]+',
  12. '\d+',
  13. );
  14. }
  15. protected function getNonCatchablePatterns()
  16. {
  17. return array(
  18. '\s+',
  19. '(.)',
  20. );
  21. }
  22. protected function getType(&$value)
  23. {
  24. if (is_numeric($value)) {
  25. $value = (int)$value;
  26. return 'int';
  27. }
  28. if (in_array($value, array('=', '<', '>'))) {
  29. return 'operator';
  30. }
  31. if (is_string($value)) {
  32. return 'string';
  33. }
  34. return;
  35. }
  36. protected function getModifiers()
  37. {
  38. return parent::getModifiers().'u';
  39. }
  40. }