blog_functions.php 895 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. function tokenize ($str, &$out) {
  3. $out = array();
  4. while (strlen($str) > 0) {
  5. if (preg_match('/^\\/\\/.*/', $str, $matches)) {
  6. $str = substr($str, strlen($matches[0]));
  7. }
  8. else if (preg_match('/^\\s+/', $str, $matches)) {
  9. $str = substr($str, strlen($matches[0]));
  10. }
  11. else if (preg_match('/^[0-9]+/', $str, $matches)) {
  12. $out[] = array('number', $matches[0]);
  13. $str = substr($str, strlen($matches[0]));
  14. }
  15. else if (preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*/', $str, $matches)) {
  16. $out[] = array('name', $matches[0]);
  17. $str = substr($str, strlen($matches[0]));
  18. }
  19. else {
  20. return FALSE;
  21. }
  22. }
  23. return TRUE;
  24. }
  25. function fatal_error ($message)
  26. {
  27. fwrite(STDERR, "Fatal error: $message\n");
  28. ob_get_clean();
  29. exit(1);
  30. }